perf(draft-cache): order the draft prompt static -> project-stable -> task-specific - #622
Merged
Merged
Conversation
… task-specific (AGT-4300) buildDraftPrompt emitted, in order: static intro -> Task (title/ description) -> Operator Feedback -> Codebase State -> Impact Analysis -> File Health -> peer issues -> Output Format. Every task drafted against the same project during one scheduling pass shares Codebase State (project stats) and peer issues, but the per-task title/ description opened the prompt, so nothing after it could ever be a shared prefix across different tasks -- AGT-4286 measured only the ~378-token static template and concluded "nothing to hoist" without noticing this. Reordered to: static intro -> Codebase State -> peer issues (both project-stable) -> Task -> Operator Feedback -> Impact Analysis -> File Health -> Output Format. Layer-2 review caught a real defect in the first draft: File Health looked project-stable but collectCodebaseState() actually seeds it from impactAnalysis.directModules (THIS task's affected files, keyword-matched against its title/description), only falling back to project-wide high-risk entities when fewer than 3 files matched -- hoisting it ahead of Task would not have delivered the claimed benefit in the common case, and the round-1 test's synthetic project path happened to always produce a null impactAnalysis, hiding the gap. Fixed by leaving File Health in the task-specific section next to Impact Analysis (the data it actually shares), and added a test that mocks a real ImpactAnalysis + registry fileBrief to exercise the branch the round-1 test structurally could not reach. Round-2 re-review confirmed the fix and flagged only a documentation nit (peer issues are "nearly" identical across tasks, not byte-identical -- production excludes each task's own record from its own list), addressed in comments. TSC=0, LINT=0 (0 new warnings), BUILD=0, full vitest suite green. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
buildDraftPromptemitted static intro -> Task (title/description) -> ... -> Codebase State/peer issues (project-stable) -> Output Format. The per-task title/description opened the prompt, so nothing after it could ever be shared across different tasks drafted against the same project.impactAnalysis.directModules(this task's own affected files) — fixed by keeping it in the task-specific section next to Impact Analysis, with a new test exercising the real code path the round-1 test's synthetic fixture couldn't reach. Round 2 clean apart from a comment-wording nit (addressed).Test plan
npx tsc --noEmit/ lint (0 new warnings) / build / full vitest suite greendraftstage cache rate (part of the standing 80%-cache goal)🤖 Generated with Claude Code