agentsclimarketplace

Api round ptl retry truncation

Skill ychampion/cskill-agents/agents/claude-code/skills/api-round-ptl-retry-truncation

Agent skills for coding CLIs, multi-agent runtimes, context engines, MCP extensions, and terminal tooling. Instead of using claude code's source code, give your agent skills to create your own!

Install
npx -y skills add ychampion/cskill-agents --skill api-round-ptl-retry-truncation

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

What its author says it does

Copied from the file, not written here

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.

SKILL.md

2.3 KB, as published. Nobody here has run it

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

  • Group by assistant-response boundaries, not raw human turns, so each dropped unit preserves tool-use pairing semantics as much as possible.
  • Strip any prior synthetic retry marker before regrouping so repeated retries keep making progress instead of dropping only the marker.
  • Keep at least one group after truncation; return null when nothing safe remains to summarize.
  • Use the parsed token gap when available, but fall back to a deterministic percentage when the provider error format does not expose it.
  • Repair assistant-first retries with a synthetic user preamble so the request remains API-valid after head truncation.

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)

  • Do not trim arbitrary individual messages from the head; you can strand tool-use sequences and create invalid retry payloads.
  • Do not keep reusing the previous retry marker as part of the grouped history or each retry can stall without reducing real context.

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.