Skip to content

perf(server): fit the core tools/list in the 6,000-token budget - #854

Merged
sumithr merged 6 commits into
mainfrom
feat/issue-808-core-budget-6000
Oct 7, 2026
Merged

sumithr merged 6 commits into
mainfrom
feat/issue-808-core-budget-6000

Conversation

@sumithr

@sumithr sumithr commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fits the core profile's serialized tools/list inside the 6,000 estimated-token target from #808. Core goes from 9,261 to 5,999 tokens and full from 12,161 to 8,899. A test enforces the target.

The 15 core plumbing-tool descriptions (test data, repo map, diff impact, ledger, context bundle, scorecard, report, coverage and mutation records, review-feedback memory, load_skill_context) now carry short, self-contained selection text. They keep every argument shape and allowed-value list a host needs, plus the safety rules. Dropped: issue references, design rationale, and the "Common natural-language phrasings that map to this tool" block that 13 tools repeated. The long-form argument detail is in docs/TOOLS.md and the per-feature docs it links, for example docs/TEST-DATA.md for find_test_data paging. Input schemas are unchanged: scripts/regen_tools_list_snapshot.py produces no diff. Nothing was merged into a mega-tool.

The 20 workflow tools still serve their SKILL.md frontmatter unchanged. Those descriptions drive native skill triggering and are the first hop on hosts that drop server instructions.

Related issue

Closes #808

Changes

  • src/sumo_qa/server.py: rewrote the 15 core plumbing-tool docstrings, which are the served descriptions. No code change: the module is AST-equal to main ignoring docstrings.
  • pyproject.toml: tools_list = { core = 6000, full = 9000 }. Core's budget is the target; full's is a ratchet just above its measurement.
  • tests/test_audit_context_budget.py: test_core_tools_list_stays_within_the_6000_token_target pins the shipped core budget at no more than 6,000, so raising it in pyproject.toml fails the suite.
  • tests/test_server_format_qa_scorecard_tool.py: the scorecard description must name every required ledger-row field and the full evidence_status / residual value lists. A host can load the scorecard without the ledger tool.
  • tests/test_server.py: the review-feedback description must keep its rules: every write needs the user's explicit confirmation, nothing is auto-captured, sensitive input is rejected, and entry needs its own scope.
  • docs/DEVELOPMENT.md: the test list names the new test.

Headroom: core is 1 token under its budget. Any new or longer core description now needs a matching cut, or a deliberate budget decision on #515.

Fixes made during merge review

  • 63676fd4: the review-feedback description said scope is an entry key and then described the top-level scope argument, so haiku passed scope only at the top level and its first capture failed validation in 3 of 3 runs, where main got it right in 2 of 2. The description now says entry needs its own scope; 4 of 4 first captures succeed.
  • 8d4c85bc: the trimmed description limited the confirmation rule to a capture. Update and delete also persist and the tool does not gate them, so the rule now covers every write, as main's did.

How it was verified

Budget audit (python scripts/audit_context_budget.py, main 9d7ea94 vs head 8d4c85b):

before after budget
core tools/list (40 tools) 9,261 5,999 6,000
full tools/list (50 tools) 12,161 8,899 9,000
execution_evidence group, descriptions 2,447 744 report-only
end-to-end business-logic review, core 27,481 24,219 report-only

context budget: OK. Raising core to 6,100 fails the new test (assert 6100 <= 6000); padding one core description by about 28 tokens fails the audit (6027 > budget 6000).

Real host, clean install (uv build --wheel of 8d4c85b, a clean venv, profile core, claude -p --model haiku --strict-mcp-config, Bash/Write/Edit/Skill denied, tool search off, run in a clone of this repo with its real .sumo-qa artifacts), 10 prompts, main vs branch:

  • Every changed tool was called correctly from its description: risk ledger (1 uncovered blocker), scorecard (BLOCKED), security bundle in one load_skill_context call, repo-map query, diff impact (14 tests, no unmapped risk surface), test-data requirements, QA report, coverage record, review-feedback list and capture.
  • The router and load_classifications give the same result on both builds.
  • Per-turn context is lower on the branch for all 10 prompts, about 53.7k to 50.0k tokens; the 10-prompt total is 1,999,031 on main and 1,731,856 on the branch.
  • Main stopped at routing on the scorecard prompt; the branch answered it.

Tests:

  • Full suite in the pre-push hook on 8d4c85b: 6283 passed, 17 skipped, 1 xfailed; Required test coverage of 100% reached.
  • CI on 8d4c85b: every check green, including mypy (static type check).

Mutation: the Linux mutation.yml dispatch on 8d4c85b (run 37327270954) is green.

Review passes:

  • sumo-qa-reviewing-before-merge per changed file, over origin/main...8d4c85b: every file SAFE, no high or medium findings.
  • /code-review high on each fix delta (fresh agents): 86d6261..63676fd and 63676fd..8d4c85b, no findings.
  • Earlier rounds before the PR opened: origin/main..9e2b3f5 (5 medium, 4 low, 8 fixed in 8e7be95), 9e2b3f5..8e7be95 (2 low fixed in 86d6261), 8e7be95..86d6261 (no findings).
  • Known low gaps left as they are: the generate_qa_report description no longer points to the ledger and bundle shapes for its override arguments; the scorecard's coverage / mutation dict fields are not named; format_context_bundle does not list its optional captured_at / detail fields.

Evals: none run. No skills/*/SKILL.md or tests/evals/promptfoo/*.yaml changed. The live haiku runs above exercise the changed descriptions.

Checklist

  • PR title follows Conventional Commits
  • Tests pass locally (pytest) and lint/type checks are green (pre-commit run --all-files, python -m mypy)
  • Added or updated tests covering the change
  • Updated the relevant docs in this same PR
  • No breaking changes (or they are called out above)

Rewrite the 15 core plumbing-tool descriptions as short, self-contained
selection text that keeps each argument shape and safety guarantee, and
drop the issue references, design rationale and repeated "Common
natural-language phrasings" blocks (docs/TOOLS.md carries the full
detail). Input schemas are unchanged.

Core tools/list: 9,261 -> 5,943 estimated tokens; full: 12,161 -> 8,843.
The core budget is now the 6,000 target, pinned in the audit test as
well as pyproject.toml; full's ratchet moves to 9,000.

Refs #808
State that only a relative write_to is confined to root, when the diff
impact map is persisted, the freshness, evidence_status, residual and
confidence values, the test-data product_id/sku duplicate keys, exact
classification matching and the repo-map match cap. Trim output lists the
response schemas already carry to stay in budget (core 5,989).

Refs #808
The trimmed description listed scope as an entry key and then described
the top-level scope argument, so haiku passed scope only at the top level
and every first capture failed validation (3 of 3 runs; main 2 of 2 got it
right). The description now says the entry needs its own scope; 3 of 3
haiku runs capture on the first call. Core tools/list stays at 5,998.
Main's description said never to persist without explicit user
confirmation; the trimmed text limited that to a capture, so update and
delete, which also persist, lost the rule the host enforces. Core
tools/list is 5,999.
@sumithr
sumithr merged commit be1faa2 into main Oct 7, 2026
31 checks passed
@sumithr
sumithr deleted the feat/issue-808-core-budget-6000 branch October 7, 2026 13:49
sumithr added a commit that referenced this pull request Oct 7, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.76.1](v0.76.0...v0.76.1)
(2026-10-07)


### Performance Improvements

* **server:** fit the core tools/list in the 6,000-token budget
([#854](#854))
([be1faa2](be1faa2))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: release-please[bot] <release-please[bot]@users.noreply.github.com>
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.

[Task]: token audit and core tools/list budget per profile

1 participant