Skip to content

fix: serve over-cap skill bodies as a progressive-loading pointer (#393) - #450

Merged
sumithr merged 2 commits into
mainfrom
fix/issue-393-oversize-skill-response
Jun 21, 2026
Merged

sumithr merged 2 commits into
mainfrom
fix/issue-393-oversize-skill-response

Conversation

@sumithr

@sumithr sumithr commented Jun 21, 2026 •

Copy link
Copy Markdown
Owner

Closes #393.

Problem

A full-body skill MCP response above the host's per-response token cap is refused by the host and saved to a file, so the canonical load fails opaquely (result ... exceeds maximum allowed tokens). The heaviest skill, sumo-qa-reviewing-before-merge (~17,812 est. tokens), is the first to cross that wall. Surfaced while dogfooding /work-issue, where the self-review step loads the reviewing discipline via its full-body tool.

Fix

Both full-body entry paths now detect an over-cap body and return a compact, actionable pointer to the progressive-loading slices instead of the oversized content:

  • the per-skill zero-argument tool (skill_prompts._make_skill_callable) returns a pointer string naming the sumo_qa_load_skill_context manifest / section / module route;
  • load_skill_context(mode="full") (skill_manifest) returns an oversize envelope (no content) carrying the section/module index plus content_hash and estimated_tokens (the full-body estimate, parity with the normal full slice so a client reading full["estimated_tokens"] does not break on the over-cap skill), and still honouring known_hash change-detection.

Under-cap skills stay byte-for-byte unchanged. The detection threshold resolves explicit param > SUMO_QA_SKILL_RESPONSE_TOKEN_CAP env var > documented default (12,000 est-tokens, set conservatively below the observed reject point of ~16,623 est-tokens / 66,492 chars), so tests inject it and a differently-capped host can override it, rather than hard-coding an undocumented host constant.

Acceptance criteria

  • Loading the reviewing-before-merge discipline via sumo-qa never returns an over-cap error: both paths degrade to a pointer (test_reviewing_before_merge_is_the_over_cap_skill, test_no_served_full_body_exceeds_the_default_cap).
  • An over-cap body returns an actionable pointer to the progressive-loading slices rather than failing (test_per_skill_tool_one_token_over_cap_returns_pointer, test_loader_full_over_cap_returns_pointer_envelope_without_body).
  • A test asserts no skill's served full-body response exceeds the cap, or degrades gracefully (test_no_served_full_body_exceeds_the_default_cap, over both entry paths for every bundled skill).

Token savings (real measurement, before vs after)

before after
sumo-qa-reviewing-before-merge per load 17,812 205 (98.8% saved)
cumulative (load every skill once) 64,752 47,145 (27.2% saved)

All 17 other skills are byte-for-byte identical. "Before" is asserted in the test equal to the raw on-disk body (exactly what main serves).

Tests and evidence

  • New tests/test_skill_response_oversize.py: the > cap boundary (at-cap stays full, one token over degrades), a decision table over entry-path x size, env-var / override resolution, the AC guard over the real library, known_hash on the oversize path, and contract parity that the oversize envelope carries estimated_tokens (test_loader_full_over_cap_carries_estimated_tokens).
  • Updated the existing byte-for-byte and structural assertions to the new contract (under-cap byte-identical, over-cap degrades), including the cumulative-saving suite, which now sources the full-body baseline from estimated_tokens_full (the real on-disk weight, so the >=50% saving floor is unchanged).
  • Docs updated: docs/TOOLS.md, docs/SKILLS.md, docs/ARCHITECTURE.md.
  • Full suite: 2443 passed, 4 skipped, 1 xfailed, 100% coverage.
  • Self-reviewed via sumo-qa-reviewing-before-merge, then three adversarial codex passes (which found a known_hash gap on the oversize path, a stale resource description, and a missing estimated_tokens field on the oversize full envelope - all fixed; re-review clean).

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0fade22ca0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/sumo_qa/skill_manifest.py Resolved
sumithrjl and others added 2 commits June 21, 2026 16:00
A full-body skill response above the host's per-response token cap is
refused by the host and saved to a file, so the canonical load fails
opaquely ("result ... exceeds maximum allowed tokens"). The heaviest
skill, sumo-qa-reviewing-before-merge (~17.8k est. tokens), is the first
to cross that wall.

Both full-body entry paths now detect an over-cap body and return a
compact, actionable pointer to the progressive-loading slices
(manifest/section/module) instead of the oversized content:
- the per-skill zero-argument tool (skill_prompts)
- load_skill_context(mode="full") (skill_manifest)

Under-cap skills stay byte-for-byte unchanged. The detection threshold is
configurable (SUMO_QA_SKILL_RESPONSE_TOKEN_CAP env var > injected param >
documented default) so tests inject it and a differently-capped host can
override it, rather than hard-coding an undocumented host constant.

reviewing-before-merge per-load: 17,812 -> 205 est-tokens (98.8%);
cumulative load-every-skill-once: 64,752 -> 47,145 (27.2%).
The over-cap mode="full" pointer omitted estimated_tokens, which every
normal full slice returns and docs/TOOLS.md advertises for all
section/module/full slices. A client reading full["estimated_tokens"]
uniformly broke only for over-cap skills. Carry it as the full-body
estimate (parity with estimated_tokens_full); the body stays omitted.
@sumithr
sumithr force-pushed the fix/issue-393-oversize-skill-response branch from 0fade22 to 2fe58f5 Compare June 21, 2026 14:16
@sumithr
sumithr merged commit 13f51aa into main Jun 21, 2026
32 checks passed
@sumithr
sumithr deleted the fix/issue-393-oversize-skill-response branch June 21, 2026 16:49
sumithr added a commit that referenced this pull request Jun 21, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.50.3](v0.50.2...v0.50.3)
(2026-06-21)


### Bug Fixes

* serve over-cap skill bodies as a progressive-loading pointer
([#393](#393))
([#450](#450))
([13f51aa](13f51aa))

---
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]: full-body skill MCP tools can exceed the host per-response token cap (reviewing-before-merge)

2 participants