{"id":"a60f92e2-6dbb-49e3-b655-43a21766698c","shortId":"zT28mq","kind":"skill","title":"api-round-ptl-retry-truncation","tagline":"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.","description":"# SKILL: API-Round PTL Retry Truncation\n**Domain:** compaction\n**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.\n**Source Pattern:** Distilled from reviewed session memory, compaction, and context-budgeting implementations.\n\n## Core Method\nRecover 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.\n\n## Key Rules\n- Group by assistant-response boundaries, not raw human turns, so each dropped unit preserves tool-use pairing semantics as much as possible.\n- Strip any prior synthetic retry marker before regrouping so repeated retries keep making progress instead of dropping only the marker.\n- Keep at least one group after truncation; return `null` when nothing safe remains to summarize.\n- Use the parsed token gap when available, but fall back to a deterministic percentage when the provider error format does not expose it.\n- Repair assistant-first retries with a synthetic user preamble so the request remains API-valid after head truncation.\n\n## Example Application\nIf 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.\n\n## Anti-Patterns (What NOT to do)\n- Do not trim arbitrary individual messages from the head; you can strand tool-use sequences and create invalid retry payloads.\n- Do not keep reusing the previous retry marker as part of the grouped history or each retry can stall without reducing real context.","tags":["api","round","ptl","retry","truncation","cskill","agents","ychampion","agent-skills","ai-agents","cli","coding-agents"],"capabilities":["skill","source-ychampion","skill-api-round-ptl-retry-truncation","topic-agent-skills","topic-ai-agents","topic-cli","topic-coding-agents","topic-context-engineering","topic-developer-tools","topic-mcp","topic-multi-agent","topic-terminal-ui"],"categories":["cskill-agents"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/ychampion/cskill-agents/api-round-ptl-retry-truncation","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add ychampion/cskill-agents","source_repo":"https://github.com/ychampion/cskill-agents","install_from":"skills.sh"}},"qualityScore":"0.467","qualityRationale":"deterministic score 0.47 from registry signals: · indexed on github topic:agent-skills · 34 github stars · SKILL.md body (2,093 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-04-22T06:56:44.792Z","embedding":null,"createdAt":"2026-04-18T22:19:43.666Z","updatedAt":"2026-04-22T06:56:44.792Z","lastSeenAt":"2026-04-22T06:56:44.792Z","tsv":"'anti':330 'anti-pattern':329 'api':2,17,37,71,102,166,271,298 'api-round':16,36,101 'api-round-ptl-retry-trunc':1 'api-valid':270 'appli':45 'applic':277 'arbitrari':115,339 'assist':152,177,258,327 'assistant-first':257 'assistant-respons':176 'attempt':97 'avail':126,239 'back':242 'block':328 'boundari':179 'break':70 'budget':85 'call':281 'compact':43,48,81,280 'context':68,84,379 'context-budget':83 'contract':171 'core':87 'cover':309 'creat':353 'determinist':245 'distil':76 'domain':42 'drop':13,119,186,214,300 'error':250 'estim':306 'exampl':276 'exceed':291 'expos':254 'fall':241 'fallback':130 'first':20,170,259 'format':251 'fraction':131 'gap':124,237,307 'group':19,104,142,174,222,294,369 'head':107,274,344 'histori':370 'hit':51 'human':182 'implement':86 'individu':340 'inject':22 'instead':112,212 'invalid':354 'keep':137,209,218,359 'key':172 'last':61 'last-resort':60 'least':139,220 'leav':145 'limit':293 'line':317 'list':111,148 'long':11,55,95,284 'make':210 'marker':158,203,217,364 'memori':80 'messag':72,110,116,147,341 'meta':315 'method':88 'much':195 'need':28,58 'next':161 'noth':228 'null':226 'old':67 'oldest':15,302 'one':140,221 'otherwis':323 'pair':192 'pars':235 'part':366 'path':64 'pattern':75,331 'payload':356 'percentag':246 'possibl':197 'preambl':26,265 'prepend':154 'preserv':188 'previous':362 'prior':200 'progress':211 'prompt':9,53,93 'prompt-too-long':8,52,92 'provid':249 'ptl':4,39 'raw':181 'real':378 'recov':89 'reduc':377 'regroup':205 'remain':230,269,320 'remov':66 'repair':256 'repeat':207 'report':122 'request':32,49,268 'resort':62 'respons':178 'retri':5,12,40,63,162,202,208,260,311,355,363,373 'return':225 'reus':360 'review':78 'round':3,18,38,103,299,303 'rule':173 'safe':229 'satisfi':164 'semant':193 'sequenc':351 'session':79,289 'singl':286 'single-user-turn':285 'size':117 'skill':35 'skill-api-round-ptl-retry-truncation' 'slice':114 'sourc':74 'source-ychampion' 'stall':375 'start':149,324 'stay':33 'still':163,290 'strand':347 'strip':198 'summar':31,232 'summari':96 'summariz':141 'synthet':24,156,201,263,314 'token':123,236 'tool':190,349 'tool-us':189,348 'topic-agent-skills' 'topic-ai-agents' 'topic-cli' 'topic-coding-agents' 'topic-context-engineering' 'topic-developer-tools' 'topic-mcp' 'topic-multi-agent' 'topic-terminal-ui' 'transcript':296,321 'trigger':44 'trim':99,144,338 'truncat':6,41,224,275 'turn':153,183,288 'unit':187 'use':191,233,350 'user':25,157,169,264,287,316 'user-first':168 'valid':34,73,272 'whole':100 'without':69,376 'would':322","prices":[{"id":"0163fa98-e80d-419c-8d61-6095cdb1bd0c","listingId":"a60f92e2-6dbb-49e3-b655-43a21766698c","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"ychampion","category":"cskill-agents","install_from":"skills.sh"},"createdAt":"2026-04-18T22:19:43.666Z"}],"sources":[{"listingId":"a60f92e2-6dbb-49e3-b655-43a21766698c","source":"github","sourceId":"ychampion/cskill-agents/api-round-ptl-retry-truncation","sourceUrl":"https://github.com/ychampion/cskill-agents/tree/main/skills/api-round-ptl-retry-truncation","isPrimary":false,"firstSeenAt":"2026-04-18T22:19:43.666Z","lastSeenAt":"2026-04-22T06:56:44.792Z"}],"details":{"listingId":"a60f92e2-6dbb-49e3-b655-43a21766698c","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"ychampion","slug":"api-round-ptl-retry-truncation","github":{"repo":"ychampion/cskill-agents","stars":34,"topics":["agent-skills","ai-agents","cli","coding-agents","context-engineering","developer-tools","mcp","multi-agent","terminal-ui"],"license":"mit","html_url":"https://github.com/ychampion/cskill-agents","pushed_at":"2026-04-04T14:13:23Z","description":"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!","skill_md_sha":"df2c2b6890440a8ad857eae180cc4f3d972502f4","skill_md_path":"skills/api-round-ptl-retry-truncation/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/ychampion/cskill-agents/tree/main/skills/api-round-ptl-retry-truncation"},"layout":"multi","source":"github","category":"cskill-agents","frontmatter":{"name":"api-round-ptl-retry-truncation","description":"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."},"skills_sh_url":"https://skills.sh/ychampion/cskill-agents/api-round-ptl-retry-truncation"},"updatedAt":"2026-04-22T06:56:44.792Z"}}