Skip to content

limit token usage#123

Merged
derekmisler merged 1 commit intodocker:mainfrom
derekmisler:limit-token-usage
Apr 7, 2026
Merged

limit token usage#123
derekmisler merged 1 commit intodocker:mainfrom
derekmisler:limit-token-usage

Conversation

@derekmisler
Copy link
Copy Markdown
Contributor

@derekmisler derekmisler commented Apr 7, 2026

Related Issues

Closes: https://github.com/docker/gordon/issues/363

Summary

Reduces token usage in the review-pr action by condensing verbose multi-paragraph instructions in pr-review.yaml into tighter prose, and by extracting the large jq-based GitHub posting template out of the agent prompt and into a dedicated reference file (posting-format.md) that is copied to /tmp at runtime. This keeps the agent prompt lean without losing any operational detail.

Token Reduction Estimate

Instruction text: ~6,606 → ~5,334 tokens per call (~19% reduction)

The system prompt is resent on every API roundtrip (tool calls, delegations). Based on a real review run (pinata, single-file PR), the pipeline made ~22 tool-call roundtrips:

Agent Tokens Saved/Call Roundtrips Total Saved
root (pre-delegation) 805 13 10,465
drafter 359 3 1,077
root (post-delegation) 805 4 3,220
verifier 107 ~2 214
Total ~22 ~15,000

~15K input tokens saved per review on a small PR. Larger PRs with multiple chunks and findings would see 30-40 roundtrips, pushing savings to ~20-25K tokens per review.


Tip

Comment /review to trigger the PR Reviewer agent for automated feedback.
Comment /describe to generate a PR description.

@derekmisler derekmisler self-assigned this Apr 7, 2026
Signed-off-by: Derek Misler <derek.misler@docker.com>
@derekmisler derekmisler requested a review from a team April 7, 2026 16:05
@derekmisler derekmisler marked this pull request as ready for review April 7, 2026 16:05
Copy link
Copy Markdown
Contributor

@docker-agent docker-agent bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

This PR successfully reduces token usage by condensing verbose multi-paragraph instructions into tighter prose and extracting the large jq-based GitHub posting template into a dedicated reference file (posting-format.md). The refactoring maintains all operational details while making the agent prompt more efficient.

Changes reviewed:

  • ✅ Condensed instructions in pr-review.yaml (removed redundant explanations)
  • ✅ Extracted posting format template to review-pr/agents/refs/posting-format.md
  • ✅ Added step in action.yml to copy reference file to /tmp/posting_format.md
  • ✅ Removed auto-merge labels from release workflow (unrelated cleanup)
  • ✅ Added --method GET to gh api call (explicit method specification)

No bugs found in the added code. All changes are documentation/configuration refactoring with no impact on runtime behavior.

@derekmisler derekmisler merged commit 5adb558 into docker:main Apr 7, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants