Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add ychampion/cskill-agents --skill withheld-max-output-token-errorsgit clone --depth 1 https://github.com/ychampion/cskill-agentsWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/ychampion/cskill-agents/withheld-max-output-token-errors)<a href="https://agentmods.dev/skills/ychampion/cskill-agents/withheld-max-output-token-errors"><img src="https://agentmods.dev/badge/skills/ychampion/cskill-agents/withheld-max-output-token-errors/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/ychampion/cskill-agents/withheld-max-output-token-errors"><img src="https://agentmods.dev/badge/skills/ychampion/cskill-agents/withheld-max-output-token-errors.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00027 | $0.00469 |
| Opus 5 | $0.00014 | $0.00234 |
| Sonnet 5 | $0.00005 | $0.00094 |
| Haiku 4.5 | $0.00003 | $0.00047 |
Grade A, and why
withheld-max-output-token-errors scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 29 lines — stays where its author put it; the contents beside it link to each section on GitHub.
SKILL: Withheld Max Output Token Errors
Domain: tool-orchestration
Trigger: Use this when a user turn hits the max-output-token limit but the system keeps retrying so the recovery loop should finish before reporting an error.
Source Pattern: Distilled from reviewed tool-loop and result-shaping patterns.
Core Method
Detect the API’s max_output_tokens error inside the streaming loop, suppress it while recovery continues, and only expose it once all retries settle. During that delay, emit placeholder tool_result messages that say each tool is missing so the user sees a focused failure summary instead of a raw API error. This keeps recovery logic intact while still surfacing helpful, per-tool diagnostics after the recovery path finishes.
Key Rules
- Guard every assistant message against
apiError === 'max_output_tokens'and only mark it for reporting once the recovery loop decides no more progress can happen. - Track tool_use IDs for the assistant messages that triggered the error and emit sanitized messages with the standard
tool_resultshape so downstream components can handle them like any other tool failure. - Log the withheld message only after
isWithheldMaxOutputTokensreturns true; do not surface the API error early or the SDK context may terminate the session. - Keep the placeholder text short, include the original error message, and mark
is_error: trueso tooling knows it’s still an error. - Preserve the tool ID so any transcripts or sidecars referencing the tool use still match the replayed replacement.
Example Application
When the per-turn token budget is exceeded while streaming a multi-tool answer, let the recovery loop run; once it fails, emit one user-facing tool_result block per tool use with the stored error message instead of leaking the API’s max_output_tokens field.
Anti-Patterns (What NOT to do)
- Do not throw or propagate the API error immediately; SDK callers might abort and the recovery path would never execute.
- Do not drop the tool_use IDs when rewriting the error, or transcripts/resumes will lose their references.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 8d ago First seen · 29 lines · 27 tokens per session scan A 5600072a5aa8
withheld-max-output-token-errors is a skill published in the GitHub repository ychampion/cskill-agents (36 stars, last pushed 5mo ago), licensed MIT. It adds 27 tokens to every session and 469 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.
Other skills, from other repositories
fix
Dispatch fix subagent for FIX-FIRST gaps from review, re-review, then diagnose unresolved failures after 2 loops.
report
Investigate bugs comprehensively — cascade through trace, capture browser evidence, extract observability data, and prepare or explicitly create a GitHub issue with grounded findings.
trace
Dispatch trace subagent to investigate unknown issues — reproduces, traces, and reports root cause for fix handoff.
perf
Use when auditing performance in any codebase — cold starts, hot paths, dependency weight, storage query patterns. Assess by default, optimize on request; measure, don't guess, and every number carries the command that produced it.
use-ivygrep
Gather focused local repository context with ivygrep before implementing, debugging, reviewing, or explaining code. Use for coding tasks involving unfamiliar paths, branch changes, stack traces, architectural relationships, callers, dependents, tests, configuration, or documentation. Prefer one bounded context pack…
grape
Use Grape MCP for Codex context continuity in coding repositories. Use when a task needs repeated-turn context, omitted context restore, stale-context checks, invalidation checks, or safe continuity across branch and dirty-worktree changes.