Wire shape aligned budgeting

From ychampion/cskill-agents · View interactive version

Wire shape aligned budgeting is an AI agent skill from the GitHub repository ychampion/cskill-agents. Keep each wire message’s aggregate tool_result size within the configured budget by compacting the largest fresh results first.

How to use this skill

Skill file

SKILL: Wire-Shape Aligned Budgeting

Domain: tool-result-budget

Trigger: Apply this when building user messages that include multiple tool_result blocks to ensure the total stays under max tool results per message chars before the API call.

Source Pattern: Distilled from reviewed tool execution, streaming, persistence, and output-budget implementations.

Core Method

Apply budgeting at the same level the wire protocol actually sends data: one outbound user message at a time. For each message, find the tool-result blocks that are eligible for replacement, immediately reapply any replacement decisions that were already frozen on earlier turns, and then compact the smallest number of newly oversized results needed to get under the limit. Persist or offload those large results, replace them with stable previews, and record the decision so retries, resumes, and forks keep producing the same message shape.

Key Rules

Example Application

If a single user message contains several large tool results, run this budgeting pass before the API call. The largest fresh results get persisted and replaced with previews until the message fits, while already-compacted results keep their exact prior preview text.

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.