{"id":"b6a37a9e-9261-4a51-ba2a-a757d0df26f6","shortId":"cbCfdJ","kind":"skill","title":"api-round-message-grouping","tagline":"Split conversation history into API-round buckets so compaction retries cut only the chunks tied to the failed round.","description":"# SKILL: API Round Message Grouping\n**Domain:** context-management\n**Trigger:** When compacting or retrying requests, use API-round boundaries instead of human-turn heuristics to determine what past messages belong together.\n**Source Pattern:** Distilled from reviewed session memory, compaction, and context-budgeting implementations.\n\n## Core Method\nWalk the message stream and emit a new bucket every time a fresh assistant message with a new message id starts. This respects the API contract that all tool results complete before the next assistant response, so each bucket represents exactly one API round-trip; malformed conversations still fall through because the grouping only fires when a real assistant boundary appears. Downstream compaction retries can then drop or replay whole rounds without breaking tool-result pairing.\n\n## Key Rules\n- Track the last assistant message id and start a new group only when it changes while at least one message is already buffered.\n- Push the final bucket at the end so the last API round isn’t lost.\n- Do not split mid-assistant stream (IDs stay constant across streaming chunks), keeping each API response intact.\n- Let dangling tool uses remain in the same group rather than inventing extra boundaries; downstream helpers (ensureToolResultPairing) repair them only when needed.\n- Name each bucket explicitly when logging so retry diagnostics can report the round that triggered the fallback.\n\n## Example Application\nWhen a compaction attempt hits prompt-too-long, first group the transcript into API rounds, identify the round that introduced the oversized assistant response, and drop or compact only that round before retrying.\n\n## Anti-Patterns (What NOT to do)\n- Do not group by user turns or by time because API chunks can span multiple user messages and tool results.\n- Do not start a new group on every assistant chunk; the streaming assistant may emit multiple chunks with the same `id`, and splitting them would leave incomplete tool-result pairs.","tags":["api","round","message","grouping","cskill","agents","ychampion","agent-skills","ai-agents","cli","coding-agents","context-engineering"],"capabilities":["skill","source-ychampion","skill-api-round-message-grouping","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-message-grouping","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,007 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.701Z","embedding":null,"createdAt":"2026-04-18T22:19:42.936Z","updatedAt":"2026-04-22T06:56:44.701Z","lastSeenAt":"2026-04-22T06:56:44.701Z","tsv":"'across':202 'alreadi':175 'anti':286 'anti-pattern':285 'api':2,11,27,43,98,116,187,207,265,302 'api-round':10,42 'api-round-message-group':1 'appear':135 'applic':250 'assist':87,108,133,157,197,274,320,324 'attempt':254 'belong':57 'boundari':45,134,223 'break':147 'bucket':13,82,112,180,234 'budget':70 'buffer':176 'chang':168 'chunk':20,204,303,321,328 'compact':15,37,66,137,253,279 'complet':104 'constant':201 'context':33,69 'context-budget':68 'context-manag':32 'contract':99 'convers':7,121 'core':72 'cut':17 'dangl':211 'determin':53 'diagnost':240 'distil':61 'domain':31 'downstream':136,224 'drop':141,277 'emit':79,326 'end':183 'ensuretoolresultpair':226 'everi':83,319 'exact':114 'exampl':249 'explicit':235 'extra':222 'fail':24 'fall':123 'fallback':248 'final':179 'fire':129 'first':260 'fresh':86 'group':5,30,127,164,218,261,294,317 'helper':225 'heurist':51 'histori':8 'hit':255 'human':49 'human-turn':48 'id':93,159,199,332 'identifi':267 'implement':71 'incomplet':338 'instead':46 'intact':209 'introduc':271 'invent':221 'isn':189 'keep':205 'key':152 'last':156,186 'least':171 'leav':337 'let':210 'log':237 'long':259 'lost':191 'malform':120 'manag':34 'may':325 'memori':65 'messag':4,29,56,76,88,92,158,173,308 'method':73 'mid':196 'mid-assist':195 'multipl':306,327 'name':232 'need':231 'new':81,91,163,316 'next':107 'one':115,172 'overs':273 'pair':151,342 'past':55 'pattern':60,287 'prompt':257 'prompt-too-long':256 'push':177 'rather':219 'real':132 'remain':214 'repair':227 'replay':143 'report':242 'repres':113 'request':40 'respect':96 'respons':109,208,275 'result':103,150,311,341 'retri':16,39,138,239,284 'review':63 'round':3,12,25,28,44,118,145,188,244,266,269,282 'round-trip':117 'rule':153 'session':64 'skill':26 'skill-api-round-message-grouping' 'sourc':59 'source-ychampion' 'span':305 'split':6,194,334 'start':94,161,314 'stay':200 'still':122 'stream':77,198,203,323 'tie':21 'time':84,300 'togeth':58 'tool':102,149,212,310,340 'tool-result':148,339 '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' 'track':154 'transcript':263 'trigger':35,246 'trip':119 'turn':50,297 'use':41,213 'user':296,307 'walk':74 'whole':144 'without':146 'would':336","prices":[{"id":"3c8828af-9caa-49c4-aa42-2656a843b403","listingId":"b6a37a9e-9261-4a51-ba2a-a757d0df26f6","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:42.936Z"}],"sources":[{"listingId":"b6a37a9e-9261-4a51-ba2a-a757d0df26f6","source":"github","sourceId":"ychampion/cskill-agents/api-round-message-grouping","sourceUrl":"https://github.com/ychampion/cskill-agents/tree/main/skills/api-round-message-grouping","isPrimary":false,"firstSeenAt":"2026-04-18T22:19:42.936Z","lastSeenAt":"2026-04-22T06:56:44.701Z"}],"details":{"listingId":"b6a37a9e-9261-4a51-ba2a-a757d0df26f6","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"ychampion","slug":"api-round-message-grouping","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":"bda6abaefea427dc925ab103448ab79878fb5d08","skill_md_path":"skills/api-round-message-grouping/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/ychampion/cskill-agents/tree/main/skills/api-round-message-grouping"},"layout":"multi","source":"github","category":"cskill-agents","frontmatter":{"name":"api-round-message-grouping","description":"Split conversation history into API-round buckets so compaction retries cut only the chunks tied to the failed round."},"skills_sh_url":"https://skills.sh/ychampion/cskill-agents/api-round-message-grouping"},"updatedAt":"2026-04-22T06:56:44.701Z"}}