Problem
After fixing the licensed-CodeDB exact-key route, default-mode Graff now matches Pi's minimal lookup trajectory (2 model calls / 1 tool call), so the remaining fixed cost is much easier to see.
On GPT-5.6 Luna at high effort, with fresh matched fixtures and no --lean:
- Graff primer: 4,108 provider-exact input tokens
- Pi 0.84.1 primer: 1,311 input tokens
- OpenCode 1.15.12 primer: 7,736 input tokens
- Graff composed system prompt: 10,907 characters
- Graff serialized primer request: 20.4 KB
A live ablation replaced only the built-in base policy while retaining normal tools, MCP, skills, presence, and high effort. It remained correct and reduced:
- Provider-exact input: 4,108 → 2,456 (-40.2%)
- Serialized request: 20.4 KB → 12.9 KB (-36.8%)
This proves meaningful headroom exists, but the minimal ablation is not shippable by itself: the production prompt must retain edit safety, verification, worktree ownership, user constraints, release/commit rules, and autonomous completion behavior.
There is a second round-cost issue: deferred-tool guidance still says unloaded tools cannot be called and should be loaded first, while dispatch now auto-loads a confident provider-legal call inline. That stale contract can induce an avoidable load_tool_schemas model/tool round.
Why this approach
Optimize measured context and rounds rather than startup or local tool execution:
- Graff reaches ready in about 0.10s.
- The exact lookup tool takes roughly 1–6ms.
- Provider calls dominate wall time.
- Prompt/schema bytes are paid again on every uncached model call.
The work should proceed as controlled prompt/schema variants with correctness gates, not ad-hoc deletion. Broad repo maps and explicit safety policy have demonstrated value on long tasks, so the goal is task-sensitive or compact representation—not removing capability.
Proposed work
- Distill duplicated base-prompt prose while retaining every behavioral invariant.
- Compact heavyweight built-in tool descriptions/schema property prose, especially delegation/workflow metadata.
- Align deferred-tool guidance with inline auto-load for known names/arguments; retain explicit loading for discovery.
- Evaluate a task-sensitive repo map (named-file tasks vs broad multi-file work).
- Compress presence for unrelated repositories while preserving a polished, visible same-worktree ownership callout.
- Integrate provider-exact cumulative terminal usage into the release branch and SDKs; keep
context_tokens clearly separate as a window meter.
- Add debug-only prompt-component/request-size and redirect-target telemetry.
Acceptance criteria
- Normal/default mode; no requirement to pass
--lean.
- Full Tier 1 green, including the 600-line ceiling, reachability, build, unit suite, invariants, and SDK drift.
- Full scripted Tier 2 green.
- Exact-key lookup remains 5/5 correct and exactly 2 model / 1 tool call.
- Existing expensive hidden-correctness tasks do not regress.
- Primer provider-exact input improves by at least 25% from the 4,108-token baseline, measured over matched repetitions.
- No increase in median model/tool rounds on representative code-reading and editing tasks.
- Same-worktree collision ownership remains visible as a polished callout.
- Published v0.0.248 is not mutated; changes ship in a follow-up release.
Measurement
Use a four-arm comparison:
- Current normal mode
- Distilled base prompt
- Compact tool descriptions/schemas
- Both
For each arm capture provider-exact trajectory input (uncached_tokens + cache_read_tokens), serialized request bytes, latency, model calls, tool calls, and exact correctness. Run primer, exact lookup, broad multi-file implementation, and the complete Tier 2 behavior set.
Problem
After fixing the licensed-CodeDB exact-key route, default-mode Graff now matches Pi's minimal lookup trajectory (2 model calls / 1 tool call), so the remaining fixed cost is much easier to see.
On GPT-5.6 Luna at high effort, with fresh matched fixtures and no
--lean:A live ablation replaced only the built-in base policy while retaining normal tools, MCP, skills, presence, and high effort. It remained correct and reduced:
This proves meaningful headroom exists, but the minimal ablation is not shippable by itself: the production prompt must retain edit safety, verification, worktree ownership, user constraints, release/commit rules, and autonomous completion behavior.
There is a second round-cost issue: deferred-tool guidance still says unloaded tools cannot be called and should be loaded first, while dispatch now auto-loads a confident provider-legal call inline. That stale contract can induce an avoidable
load_tool_schemasmodel/tool round.Why this approach
Optimize measured context and rounds rather than startup or local tool execution:
The work should proceed as controlled prompt/schema variants with correctness gates, not ad-hoc deletion. Broad repo maps and explicit safety policy have demonstrated value on long tasks, so the goal is task-sensitive or compact representation—not removing capability.
Proposed work
context_tokensclearly separate as a window meter.Acceptance criteria
--lean.Measurement
Use a four-arm comparison:
For each arm capture provider-exact trajectory input (
uncached_tokens + cache_read_tokens), serialized request bytes, latency, model calls, tool calls, and exact correctness. Run primer, exact lookup, broad multi-file implementation, and the complete Tier 2 behavior set.