Withheld max output token errors

From ychampion/cskill-agents · View interactive version

Withheld max output token errors is an AI agent skill from the GitHub repository ychampion/cskill-agents. Delay surfacing max-output-token failures until the recovery loop completes, then emit sanitized tool_result errors.

How to use this skill

Skill file

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

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)

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.