Skip to content

Commit d4dc754

Browse files
authored
Merge pull request #23926 from dvdksn/cagent-docfixer-improvements
agent: improvements to cagent issue fixer workflow
2 parents b9dfbbd + e628c62 commit d4dc754

File tree

3 files changed

+70
-153
lines changed

3 files changed

+70
-153
lines changed

.github/workflows/agent.yml

Lines changed: 35 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,9 @@ jobs:
2121
- name: Set up Docker Buildx
2222
uses: docker/setup-buildx-action@v3
2323

24-
- name: Configure Git
25-
run: |
26-
git config user.name "github-actions[bot]"
27-
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
28-
2924
- name: Install dependencies
3025
run: npm ci
3126

32-
- name: Create branch
33-
run: |
34-
git checkout -b agent/issue-${{ github.event.issue.number }}
35-
3627
- name: Run agent
3728
uses: docker/[email protected]
3829
timeout-minutes: 15
@@ -44,27 +35,50 @@ jobs:
4435
Work on GitHub issue: ${{ github.event.issue.html_url }}
4536
4637
Fetch the issue, analyze what documentation changes are needed, and
47-
implement them following your standard workflow.
38+
implement them.
39+
40+
When complete, write .pr-body.md following this structure:
4841
49-
If you identify any upstream coordination issues (broken links from
50-
vendored content, missing CLI flags, etc.), document them in
51-
.upstream-issues.md as specified in your instructions.
42+
## Summary
43+
One sentence describing what was fixed/added/changed.
44+
45+
## Changes
46+
Bulleted list of specific changes (be concise, focus on what matters).
47+
48+
## Upstream coordination needed
49+
Only include this section if there are issues requiring fixes in upstream
50+
repos (docker/cli, moby/moby, etc.). Otherwise omit it entirely.
51+
52+
Fixes #${{ github.event.issue.number }}
53+
54+
---
55+
🤖 Generated with [cagent](https://github.com/docker/cagent)
56+
57+
Keep the PR body brief and practical. Don't over-explain or add sections
58+
that aren't needed.
5259
env:
5360
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
5461
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5562

5663
- name: Check for changes
5764
id: changes
5865
run: |
59-
if [[ -n $(git status --porcelain) ]]; then
60-
echo "has_changes=true" >> $GITHUB_OUTPUT
61-
else
66+
if git diff --quiet; then
6267
echo "has_changes=false" >> $GITHUB_OUTPUT
68+
else
69+
echo "has_changes=true" >> $GITHUB_OUTPUT
6370
fi
6471
65-
- name: Commit changes
72+
- name: Commit and push
6673
if: steps.changes.outputs.has_changes == 'true'
74+
env:
75+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6776
run: |
77+
git config user.name "github-actions[bot]"
78+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
79+
80+
BRANCH="agent/issue-${{ github.event.issue.number }}"
81+
git checkout -b "$BRANCH"
6882
git add .
6983
git commit -m "docs: address issue #${{ github.event.issue.number }}
7084
@@ -73,41 +87,17 @@ jobs:
7387
7488
🤖 Generated with cagent"
7589
76-
- name: Push changes
77-
if: steps.changes.outputs.has_changes == 'true'
78-
run: |
79-
git push -u origin agent/issue-${{ github.event.issue.number }}
90+
git push origin "$BRANCH"
8091
8192
- name: Create pull request
8293
if: steps.changes.outputs.has_changes == 'true'
8394
env:
84-
GH_TOKEN: ${{ github.token }}
85-
PR_BODY: |
86-
## Summary
87-
88-
This PR addresses #${{ github.event.issue.number }}.
89-
90-
## Changes
91-
92-
The documentation agent team analyzed the issue and implemented the requested changes.
93-
94-
🤖 Generated with [cagent](https://github.com/docker/cagent)
95-
96-
Closes #${{ github.event.issue.number }}
95+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9796
run: |
98-
# Add upstream coordination section if file exists
99-
if [[ -f .upstream-issues.md ]]; then
100-
UPSTREAM_SECTION=$(cat .upstream-issues.md)
101-
FULL_PR_BODY="${PR_BODY/Closes #/$UPSTREAM_SECTION\n\nCloses #}"
102-
else
103-
FULL_PR_BODY="$PR_BODY"
104-
fi
105-
10697
gh pr create \
10798
--title "docs: address issue #${{ github.event.issue.number }}" \
108-
--body "$FULL_PR_BODY" \
109-
--base main \
110-
--head agent/issue-${{ github.event.issue.number }}
99+
--body-file .pr-body.md \
100+
--label agent/generated
111101
112102
- name: Comment on issue (success)
113103
if: steps.changes.outputs.has_changes == 'true'

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ tmp
1515
cagent
1616
# cagent tmp files
1717
.cagent
18-
.upstream-issues.md
18+
.pr-body.md
1919
.validation.log

agent.yml

Lines changed: 34 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,23 @@ agents:
2626
3. **Read for context**: Use filesystem tools to read specific files and
2727
understand the current state.
2828
29-
4. **Hand off to writer**: Use the handoff tool to switch to the writer
30-
agent with clear task description:
29+
4. **Delegate to writer**: Delegate to the writer sub-agent with clear
30+
instructions:
3131
- What needs to be written/updated
3232
- Which files are involved
3333
- Related docs to consider
3434
- Any specific requirements
3535
36-
The writer will hand off directly to editor, who will hand off to
37-
reviewer. You'll be involved again if issues need triage or the work is
38-
complete.
36+
5. **Delegate to editor**: After the writer completes their work, delegate
37+
to the editor sub-agent to polish, validate, and fix any issues.
3938
40-
5. **Handle completion**: When the reviewer is done, analyze results:
39+
6. **Handle completion**: When the editor is done, analyze results:
4140
- **Validation passed**: Work is complete
42-
- **Local issues remain**: Coordinate fixes (rare - editor should
43-
handle)
41+
- **Local issues remain**: Delegate back to editor to fix
4442
- **Upstream coordination issues**: Document for follow-up, don't block
4543
completion
4644
47-
6. **Complete**: When validation passes OR only upstream issues remain,
45+
7. **Complete**: When validation passes OR only upstream issues remain,
4846
the work is done
4947
5048
## Documentation context
@@ -103,21 +101,9 @@ agents:
103101
104102
**When you identify upstream issues:**
105103
1. Verify it's truly an upstream issue (check file path and source)
106-
2. Document what upstream work is needed:
107-
- Which repo owns the content (docker/cli, docker/buildx, moby/moby)
108-
- What needs to be fixed (broken link, missing anchor, etc.)
109-
- The specific file/command involved
110-
3. Write upstream issues to `.upstream-issues.md` in this format:
111-
```markdown
112-
## Upstream coordination needed
113-
114-
### [Repo name]
115-
116-
- **Issue**: Brief description
117-
- **Location**: Specific file/command
118-
- **Action needed**: What needs to be fixed upstream
119-
```
120-
4. **Do not block completion** - if local changes are correct, upstream
104+
2. Note briefly what upstream work is needed (which repo, what needs
105+
fixing)
106+
3. **Do not block completion** - if local changes are correct, upstream
121107
work is separate
122108
123109
**How to identify upstream vs local issues:**
@@ -141,13 +127,6 @@ agents:
141127
- Dockerfile reference → moby/buildkit
142128
- Engine API reference → moby/moby
143129
144-
## Tracking work
145-
146-
Use the todo toolset for multi-step work:
147-
- Create todos for each major step before starting
148-
- Update status as work progresses
149-
- Check list_todos regularly to ensure nothing is missed
150-
151130
toolsets:
152131
- type: filesystem
153132
- type: todo
@@ -156,11 +135,6 @@ agents:
156135
sub_agents:
157136
- writer
158137
- editor
159-
- reviewer
160-
handoffs:
161-
- writer
162-
- editor
163-
- reviewer
164138

165139
writer:
166140
model: sonnet
@@ -251,39 +225,27 @@ agents:
251225
252226
1. If updating existing content, read it first
253227
2. Understand the topic and what needs to be documented
254-
3. Search for related content and examples (use your RAG search tool)
228+
3. Use filesystem tools (glob, grep, read) to find related content and
229+
examples
255230
4. Write clear, conversational content following the principles above
256231
5. Focus on content - the editor handles formatting, syntax, and style
257-
6. When done, hand off to the editor using the handoff tool
232+
6. When done, your work returns to the root agent
258233
259234
Write files directly. Don't just provide drafts.
260235
261-
## Using the RAG search tool
262-
263-
You have access to search the documentation repository. Use it to:
264-
- Find how similar topics are documented
265-
- Learn from well-written examples
266-
- Discover patterns and conventions
267-
- Check what already exists
268-
269-
Search by concept ("how to document prerequisites") or exact terms
270-
("Docker Compose").
271-
272236
toolsets:
273237
- type: filesystem
274238
- type: shell
275-
rag:
276-
- docs
277-
handoffs:
278-
- editor
279-
- root
239+
# rag:
240+
# - docs # Disabled: queries sometimes hang, needs investigation
280241

281242
editor:
282243
model: sonnet
283-
description: Editor that polishes documentation for formatting and style
244+
description: Editor that polishes, validates, and fixes documentation
284245
instruction: |
285-
You polish documentation to meet strict formatting and style standards.
286-
The writer creates content; you make it perfect.
246+
You polish documentation to meet strict formatting and style standards,
247+
then validate it passes all automated checks. The writer creates content;
248+
you make it perfect and ensure it's ready to ship.
287249
288250
## What you fix
289251
@@ -347,64 +309,32 @@ agents:
347309
5. Polish style (voice, tense, punctuation, conciseness)
348310
6. Run prettier: `npx prettier --write <file>`
349311
7. Write the polished version
350-
8. Hand off to the reviewer using the handoff tool
312+
8. Use the validate tool to run automated checks
313+
9. Read the validation log at .validation.log (first 2000 lines to start)
314+
10. If validation passes: Report success and return to root agent
315+
11. If validation fails: Fix the issues and repeat from step 8
351316
352317
Be thorough but don't change the meaning or add new content. You're
353318
polishing what the writer created, not rewriting it.
354319
355-
The complete style guide is in content/contribute/style/ if you need
356-
reference.
357-
358-
toolsets:
359-
- type: filesystem
360-
- type: shell
361-
handoffs:
362-
- reviewer
363-
- writer
364-
- root
365-
366-
reviewer:
367-
model: haiku
368-
description: Documentation validator that runs automated checks
369-
instruction: |
370-
You validate documentation by running the validation suite. The writer
371-
creates content, the editor polishes it, and you verify it passes all
372-
automated checks.
373-
374-
## Your workflow
375-
376-
When asked to review documentation:
377-
378-
1. Run validation and save output to a file in the working directory:
379-
`docker buildx bake validate > .validation.log 2>&1`
380-
381-
2. Read the log file to check for errors.
382-
The file can be large - read the first 2000 lines to start.
383-
384-
3. Analyze results:
385-
- **No errors**: Confirm validation passed and explain that work is
386-
complete
387-
- **Errors found**: Report them with specific details (file names, line
388-
numbers, what's wrong)
389-
390-
4. For errors, suggest next steps:
391-
- **Fixable locally**: Hand off to editor to fix
392-
- **Unclear if upstream**: Explain the issue so root agent can triage
393-
394-
The validate target runs markdownlint, HTML validation, link checking, and
320+
The validate tool runs markdownlint, HTML validation, link checking, and
395321
other structural checks. Vale (prose linting) runs separately in CI and
396322
is not included to avoid excessive output.
397323
398-
If you need to see more of the log, use the Read tool with offset/limit
399-
parameters.
324+
If you need to see more of the validation log, use the Read tool with
325+
offset/limit parameters.
326+
327+
The complete style guide is in content/contribute/style/ if you need
328+
reference.
400329
401330
toolsets:
402331
- type: filesystem
403332
- type: shell
404-
handoffs:
405-
- editor
406-
- writer
407-
- root
333+
- type: script
334+
shell:
335+
validate:
336+
cmd: "docker buildx bake validate > .validation.log 2>&1"
337+
description: Run documentation validation checks (markdownlint, HTML validation, link checking)
408338

409339
rag:
410340
docs:
@@ -421,9 +351,6 @@ rag:
421351
limit: 10
422352

423353
models:
424-
haiku:
425-
provider: anthropic
426-
model: claude-haiku-4-5
427354
sonnet:
428355
provider: anthropic
429356
model: claude-sonnet-4-5

0 commit comments

Comments
 (0)