perf(meta-phases): let the model decide when to browse, not the prompt - #20
Merged
Merged
Conversation
…the prompt
The meta_semantic / meta_mechanical / meta_systemic phases were burning
15–40 minutes apiece in production, even though Kimi K2.6 is fast
per-turn. Profiling traced this back to the prompts themselves: each
phase had an "Investigation Protocol" section that *mandated* browsing
the actual source files, and a "Quality Gate" that *rejected*
diff-only answers ("If your rationale says 'visible in the diff' or
'based on the patches', you have not investigated enough").
That language turned every phase into a 20–40 turn opencode session
of file reads, when the diff patches plus the intake/anatomy summary
already contain almost everything these phases need to produce
dimensions. The model wasn't slow — it was being instructed to do
expensive exploration before it was allowed to answer.
Replaced the mandate with neutral framing:
- "Working with Context": diff + intake/anatomy is usually enough.
Repo access is available; use it sparingly, only when the diff
genuinely doesn't show what you need.
- "Quality Bar": dimensions must be specific (named files, line
ranges). The diff already carries those; a dimension grounded in
the diff is good. Vague dimensions are still rejected.
Each lens keeps its specific bullets (semantic = logic/contracts,
mechanical = signatures/imports, systemic = patterns/coverage) and
its target_files requirement. The output schema is unchanged. What
changes is the model is no longer penalized for producing a correct
answer from the diff in 2 turns instead of 30.
Also bumped the in-code default model openrouter/moonshotai/kimi-k2.5
→ k2.6 to match what's actually deployed in production. Local dev was
silently running on an older model than prod.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4 tasks
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.
Why
Each meta-phase (
meta_semantic,meta_mechanical,meta_systemic) was burning 15–40 minutes apiece in production, even though Kimi K2.6 is fast per-turn. Profiling traced this back to the prompts themselves, not to the model or harness.Two pieces of prompt language were doing the damage in all three lenses:
That turned every phase into a 20–40 turn opencode session of file reads, when the diff patches plus the intake/anatomy summary already contain almost everything these phases need to produce dimensions. The model wasn't slow — it was being instructed to do expensive exploration before it was allowed to answer.
What
Replaced the mandate with neutral framing in all three meta-phase prompts:
cwd=repo_path); use it sparingly, only when the diff genuinely doesn't show what you need (e.g., to confirm an unchanged caller's signature).Each lens keeps its existing bullets (semantic = logic/contracts/concurrency/security, mechanical = signatures/imports/decorators, systemic = patterns/coverage/migrations), the
target_filesrequirement, and the output schema. The structural contract is unchanged.Also in this PR
Bumped the in-code default model
openrouter/moonshotai/kimi-k2.5→kimi-k2.6inconfig.pyand.env.exampleto match what's actually deployed via Railway env. Local dev was silently running on an older model than prod.Expected impact
This is one half of a two-PR change. The other half (in
agentfield) addresses three orthogonal harness issues:TRANSIENT_PATTERNSincludes"timeout", so a 10-min timeout silently triggers up to 3 more 10-min retries)This PR alone should chop meta-phase wall time roughly in half by simply not forcing useless exploration. With the agentfield fixes layered on top, total review runtime should drop from 60–110+ min to well under an hour for typical PRs.
Test plan
PYTHONPATH=src pytest— 25 passed (1 pre-existingtest_cost_trackerfailure onmain, unrelated to this PR)anatomy_phase,meta_semantic,meta_mechanical,meta_systemicresolve cleanly🤖 Generated with Claude Code