Idempotent tool result persistence

From ychampion/cskill-agents · View interactive version

Idempotent tool result persistence is an AI agent skill from the GitHub repository ychampion/cskill-agents. Persist tool results once, avoid re-writing duplicates, and summarize via previews so long outputs stay accessible yet capped.

How to use this skill

Skill file

SKILL: Idempotent Tool Result Persistence

Domain: persistence

Trigger: Use this when tool result blocks exceed their configured thresholds and you want to persist them once while still returning a preview.

Source Pattern: Distilled from reviewed tool execution, streaming, persistence, and output-budget implementations.

Core Method

Persist oversized tool outputs to a deterministic artifact path derived from the tool call ID and content type. Create that artifact with exclusive-write semantics so retries and concurrent writers cannot clobber or duplicate the same payload. After the first successful write, return a compact preview plus metadata pointing at the persisted artifact; later retries should reuse the existing file and regenerate the same preview without rewriting the payload. This keeps large outputs accessible while making persistence safe and repeatable.

Key Rules

Example Application

When a log-reading tool returns 60 KB of text, write it once to a stable artifact file such as tool-results/<tool-call-id>.txt, then send only a short preview plus the saved path. If the same result is replayed on retry, skip the write and reuse the same artifact reference.

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.