Api round message grouping

From ychampion/cskill-agents · View interactive version

Api round message grouping is an AI agent skill from the GitHub repository ychampion/cskill-agents. Split conversation history into API-round buckets so compaction retries cut only the chunks tied to the failed round.

How to use this skill

Skill file

SKILL: API Round Message Grouping

Domain: context-management

Trigger: When compacting or retrying requests, use API-round boundaries instead of human-turn heuristics to determine what past messages belong together.

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

Core Method

Walk 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.

Key Rules

Example Application

When 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.

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.