Optimize Documentation Maintainer token usage and prompt/cache behavior#3202
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
This PR updates the Documentation Maintainer agent workflow to reduce token usage by switching to a smaller Copilot model and attempting to precompute change context for the agent prompt.
Changes:
- Sets the Documentation Maintainer engine to Copilot with
claude-haiku-4-5. - Adds pre-agent steps for source-change detection, recent diffs, and affected-doc candidates.
- Reorders prompt context so run-specific data is appended near the end.
Show a summary per file
| File | Description |
|---|---|
.github/workflows/doc-maintainer.md |
Updates workflow source configuration, precomputed git context steps, and prompt instructions/context. |
.github/workflows/doc-maintainer.lock.yml |
Regenerated compiled workflow reflecting model, prompt substitutions, and new pre-agent steps. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comments suppressed due to low confidence (1)
.github/workflows/doc-maintainer.md:65
- The
AFFECTED_DOCSbody is also printed to stdout instead of$GITHUB_OUTPUT, so the output will be empty even when relevant files exist. The multiline output needs to append the command output between the heredoc markers.
echo "AFFECTED_DOCS<<EOF" >> $GITHUB_OUTPUT
git log --since="7 days ago" --name-only --format="" -- src/ containers/ scripts/ | \
grep -v '^$' | sort -u | head -30
- Files reviewed: 2/2 changed files
- Comments generated: 7
| git log --since="7 days ago" --format="%H %s" -- src/ containers/ scripts/ | \ | ||
| while read -r sha title; do | ||
| echo "=== Commit $sha: $title ===" | ||
| git show --stat --unified=3 "$sha" -- src/ containers/ scripts/ docs/ '*.md' 2>/dev/null | head -150 | ||
| done | head -500 |
| GH_AW_EXPR_4072EBFD: ${{ steps.has-changes.outputs.has_changes }} | ||
| GH_AW_EXPR_8CF6695E: ${{ steps.has-changes.outputs.changed_count }} | ||
| GH_AW_EXPR_8F5D95B0: ${{ steps.git-changes.outputs.RECENT_DIFFS }} | ||
| GH_AW_EXPR_FAA4E739: ${{ steps.affected-docs.outputs.AFFECTED_DOCS }} |
| - name: Check for relevant changes | ||
| id: has-changes | ||
| run: | | ||
| COUNT=$(git log --since="7 days ago" --oneline -- src/ containers/ scripts/ | wc -l) |
| git log --since="7 days ago" --name-only --format="" -- src/ containers/ scripts/ | \ | ||
| grep -v '^$' | sort -u | head -30 |
| echo "RECENT_DIFFS<<EOF" >> $GITHUB_OUTPUT | ||
| git log --since="7 days ago" --format="%H %s" -- src/ containers/ scripts/ | \ | ||
| while read -r sha title; do | ||
| echo "=== Commit $sha: $title ===" | ||
| git show --stat --unified=3 "$sha" -- src/ containers/ scripts/ docs/ '*.md' 2>/dev/null | head -150 | ||
| done | head -500 | ||
| echo "EOF" >> $GITHUB_OUTPUT |
| ### 3. Review Current Documentation | ||
|
|
||
| Read the documentation files listed above that are likely affected by the recent changes. | ||
| Start with the prioritized list from `${{ steps.affected-docs.outputs.AFFECTED_DOCS }}`. Review the broader documentation list only when there is a clear link to the recent source changes. |
| ### 1. Analyze Pre-computed Changes | ||
|
|
||
| Review the git commit list above. For commits that touch source code (`src/`, `containers/`, `scripts/`), use `git show <sha>` to examine the actual diffs and understand what changed. | ||
| If `${{ steps.has-changes.outputs.has_changes }}` is `false`, exit immediately using a no-op result without editing files or creating a PR. |
|
@copilot address review feedback |
Addressed in 80a8b78. I fixed the workflow review items: robust |
Smoke Test ResultsTest Summary: 2/3 PASS (1 FAIL)
Note: GitHub API test failed due to gh CLI authentication in this environment. Playwright and file verification tests passed successfully.
|
Smoke Test: Copilot BYOK (Offline) Mode
Running in BYOK offline mode ( Overall: FAIL — GitHub MCP returned 401 and pre-step outputs were not injected.
|
🔬 Smoke Test Results
Overall: FAIL — GitHub MCP returned 401; workflow template variables (
|
Smoke TestPRs: Cap Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "registry.npmjs.org"See Network Configuration for more information.
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
|
Smoke test in progress... Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "localhost"See Network Configuration for more information.
|
Smoke Test Results — FAIL ❌
|
✨ Enhancement
The
Documentation Maintainerworkflow was consuming ~1.17M tokens/run with 28 LLM requests, driven largely by repeated bash round-trips (git showper commit) and unstable prompt caching. This change restructures the workflow to reduce request fan-out, shift work into precomputed step outputs, and run on a smaller model.Model sizing
claude-haiku-4-5for lower-cost doc maintenance tasks.Precomputed change context (fewer tool round-trips)
git-changesnow emitsRECENT_DIFFSwith bounded unified diffs forsrc/,containers/,scripts/(+ relevant doc paths).affected-docsstep to emit prioritized candidate files (AFFECTED_DOCS) from recent source-touching paths.has-changesstep to emithas_changes/changed_countfor explicit no-op handling.Prompt structure + execution guidance (cache/write and scope control)
has_changes=falseRECENT_DIFFSas primary inputAFFECTED_DOCSbefore broad doc reviewgit showunless strictly necessaryRelated failure context
CLAUDE.mdprotected-file modification), independent of this token-optimization flow.