Api round ptl retry truncation

From ychampion/cskill-agents · View interactive version

Api round ptl retry truncation is an AI agent skill from the GitHub repository ychampion/cskill-agents. On prompt-too-long retries, drop the oldest API-round groups first and inject a synthetic user preamble when needed so the summarize request stays valid.

How to use this skill

Skill file

SKILL: API-Round PTL Retry Truncation

Domain: compaction

Trigger: Apply when the compaction request itself hits prompt-too-long and you need a last-resort retry path that removes old context without breaking API message validity.

Source Pattern: Distilled from reviewed session memory, compaction, and context-budgeting implementations.

Core Method

Recover from a prompt-too-long summary attempt by trimming whole API-round groups from the head of the message list instead of slicing arbitrary messages. Size the drop by the reported token gap when available, or by a fallback fraction when it is not, and keep at least one summarizeable group. If trimming leaves the message list starting with an assistant turn, prepend a synthetic user marker so the next retry still satisfies the API's user-first contract.

Key Rules

Example Application

If a compaction call on a long single-user-turn session still exceeds the limit, group the transcript by API rounds, drop the oldest rounds until the estimated gap is covered, and retry with a synthetic meta user line when the remaining transcript would otherwise start with an assistant block.

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.