Skip to content

Reduce default-mode primer overhead and avoid discovery rounds #489

Description

@justrach

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

  1. Distill duplicated base-prompt prose while retaining every behavioral invariant.
  2. Compact heavyweight built-in tool descriptions/schema property prose, especially delegation/workflow metadata.
  3. Align deferred-tool guidance with inline auto-load for known names/arguments; retain explicit loading for discovery.
  4. Evaluate a task-sensitive repo map (named-file tasks vs broad multi-file work).
  5. Compress presence for unrelated repositories while preserving a polished, visible same-worktree ownership callout.
  6. Integrate provider-exact cumulative terminal usage into the release branch and SDKs; keep context_tokens clearly separate as a window meter.
  7. 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:

  1. Current normal mode
  2. Distilled base prompt
  3. Compact tool descriptions/schemas
  4. 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions