{"id":"75a261e4-c135-47f3-ac99-ce5a90a039bd","shortId":"LfUrfL","kind":"skill","title":"orphaned-tool-call-sanitizer","tagline":"Remove assistant messages that reference tools without recorded results before feeding the history back into runAgent.","description":"# SKILL: Orphaned Tool Call Sanitizer\n**Domain:** messaging\n**Trigger:** When replaying history for a subagent, make sure assistant tool_use blocks never refer to tool_use_ids that lack results.\n**Source Pattern:** Distilled from reviewed subagent orchestration, isolation, and lifecycle implementations.\n\n## Core Method\nCollect every `tool_use_id` emitted inside `tool_result` blocks on user messages, then drop any assistant message whose content includes a `tool_use` block that references an ID missing from that set. Non-assistant messages and assistant messages without tool_use blocks pass through unchanged, so only the incomplete invocations are pruned before query runs.\n\n## Key Rules\n- Build the tool use ids with results set exclusively from user-side `tool_result` blocks, since assistant messages can mention tool_use IDs that never resolved.\n- Treat every assistant message containing a `tool_use` entry whose `id` is absent from the result set as unsafe and remove it entirely.\n- Preserve progress, system, and clean assistant messages so the downstream agent still sees the rest of the context.\n- Run this sanitizer before providing initial messages to run agent so the async call path never sees an orphaned invocation.\n\n## Example Application\nWhen the main agent forks to an Explore or Plan subagent, sanitize the shared history first so the subagent never inherits an assistant tool_use record that was never followed by a tool_result. The downstream query call then succeeds without rejecting the payload.\n\n## Anti-Patterns (What NOT to do)\n- Forwarding assistant messages with tool_use blocks that lack corresponding results; such payloads trigger API validation errors.\n- Waiting until after the query to drop the offending message, which already fails or leaves the transcript poisoned.","tags":["orphaned","tool","call","sanitizer","cskill","agents","ychampion","agent-skills","ai-agents","cli","coding-agents","context-engineering"],"capabilities":["skill","source-ychampion","skill-orphaned-tool-call-sanitizer","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/orphaned-tool-call-sanitizer","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 (1,810 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-22T00:56:53.517Z","embedding":null,"createdAt":"2026-04-18T22:20:51.829Z","updatedAt":"2026-04-22T00:56:53.517Z","lastSeenAt":"2026-04-22T00:56:53.517Z","tsv":"'absent':162 'agent':183,200,216 'alreadi':292 'anti':258 'anti-pattern':257 'api':278 'applic':212 'assist':7,38,80,99,102,140,152,178,235,265 'async':203 'back':19 'block':41,73,88,107,138,270 'build':123 'call':4,25,204,250 'clean':177 'collect':64 'contain':154 'content':83 'context':190 'core':62 'correspond':273 'distil':53 'domain':27 'downstream':182,248 'drop':78,287 'emit':69 'entir':172 'entri':158 'error':280 'everi':65,151 'exampl':211 'exclus':131 'explor':220 'fail':293 'feed':16 'first':228 'follow':242 'fork':217 'forward':264 'histori':18,32,227 'id':47,68,92,127,146,160 'implement':61 'includ':84 'incomplet':114 'inherit':233 'initi':196 'insid':70 'invoc':115,210 'isol':58 'key':121 'lack':49,272 'leav':295 'lifecycl':60 'main':215 'make':36 'mention':143 'messag':8,28,76,81,100,103,141,153,179,197,266,290 'method':63 'miss':93 'never':42,148,206,232,241 'non':98 'non-assist':97 'offend':289 'orchestr':57 'orphan':2,23,209 'orphaned-tool-call-sanit':1 'pass':108 'path':205 'pattern':52,259 'payload':256,276 'plan':222 'poison':298 'preserv':173 'progress':174 'provid':195 'prune':117 'queri':119,249,285 'record':13,238 'refer':10,43,90 'reject':254 'remov':6,170 'replay':31 'resolv':149 'rest':187 'result':14,50,72,129,137,165,246,274 'review':55 'rule':122 'run':120,191,199 'runag':21 'sanit':5,26,193,224 'see':185,207 'set':96,130,166 'share':226 'side':135 'sinc':139 'skill':22 'skill-orphaned-tool-call-sanitizer' 'sourc':51 'source-ychampion' 'still':184 'subag':35,56,223,231 'succeed':252 'sure':37 'system':175 'tool':3,11,24,39,45,66,71,86,105,125,136,144,156,236,245,268 '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':297 'treat':150 'trigger':29,277 'unchang':110 'unsaf':168 'use':40,46,67,87,106,126,145,157,237,269 'user':75,134 'user-sid':133 'valid':279 'wait':281 'whose':82,159 'without':12,104,253","prices":[{"id":"ed0a2c8a-002a-4fc2-8a20-33d1b9ebd0d0","listingId":"75a261e4-c135-47f3-ac99-ce5a90a039bd","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:20:51.829Z"}],"sources":[{"listingId":"75a261e4-c135-47f3-ac99-ce5a90a039bd","source":"github","sourceId":"ychampion/cskill-agents/orphaned-tool-call-sanitizer","sourceUrl":"https://github.com/ychampion/cskill-agents/tree/main/skills/orphaned-tool-call-sanitizer","isPrimary":false,"firstSeenAt":"2026-04-18T22:20:51.829Z","lastSeenAt":"2026-04-22T00:56:53.517Z"}],"details":{"listingId":"75a261e4-c135-47f3-ac99-ce5a90a039bd","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"ychampion","slug":"orphaned-tool-call-sanitizer","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":"1893c0b413a46bb2dc1a1fa7b7b10b0b47778d63","skill_md_path":"skills/orphaned-tool-call-sanitizer/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/ychampion/cskill-agents/tree/main/skills/orphaned-tool-call-sanitizer"},"layout":"multi","source":"github","category":"cskill-agents","frontmatter":{"name":"orphaned-tool-call-sanitizer","description":"Remove assistant messages that reference tools without recorded results before feeding the history back into runAgent."},"skills_sh_url":"https://skills.sh/ychampion/cskill-agents/orphaned-tool-call-sanitizer"},"updatedAt":"2026-04-22T00:56:53.517Z"}}