Who it is forA developer building an agent that can send messages on behalf of a user and must not send without approval.
The problemAn LLM can pick a write tool on its own. You need the runtime to block the side effect until a person or policy approves it.
The outcomeA send-email tool that returns CONFIRMATION_REQUIRED until approved, and resumes from a checkpoint after approval without repeating completed writes.
What you need first
- Go 1.25 or newer
- An OpenAI-compatible Chat Completions endpoint with a base URL, API key, and model name
- A clone of the repo or a Go module that imports github.com/cocoyes/zhizhi-agent-runtime
Steps
- Define the write function with tool.Func and mark it with tool.WithSideEffect(tool.SideEffectWriteNonIdempotent), tool.WithIdempotency(tool.IdempotencyNonIdempotent), tool.WithRisk(tool.RiskHigh), and tool.WithConfirmation(tool.ConfirmationAlways).
- Build the agent with zhizhi.WithGuard(authorize), zhizhi.WithConfirmation(askUser), and a durable zhizhi.WithCheckpointStore(durableStore) in production.
- Run the request. If pending.Suspended is true, show the approval request to the user and keep pending.RunID and pending.Checkpoint.
- After approval, call agent.Resume with zhizhi.ResumeRequest containing RunID, Checkpoint, and Decision set to true, passing the same request-scoped tools.
- Check the ActionReceipt in the response. Treat UNKNOWN receipts as not successful and do not retry them.
Prompt for your agent
Using github.com/cocoyes/zhizhi-agent-runtime, register a <send-email> tool with SideEffectWriteNonIdempotent, RiskHigh, and ConfirmationAlways, and wire WithGuard and WithConfirmation. Run a request that asks to send one message and confirm the response contains CONFIRMATION_REQUIRED before approval. Then resume with Decision true and report the ActionReceipt.
Caveat. Without a durable checkpoint store the default store is process-local, so a suspended approval is lost if the process restarts.
Use this in your AI agent
Ask your agent
Using the Deduped MCP, get the setup steps for cocoyes/zhizhi-agent-runtime and "Gate an email-sending tool behind confirmation and a guard"
Add Deduped to Claude Code once
claude mcp add --transport http deduped https://dedupedai.com/mcp
Every Monday: the 5 hottest repos and exactly how to use them. Free, one email a week, unsubscribe anytime.
Get them freeShare: X LinkedIn Hacker News Email Copy link
Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer