DEDUPED Hot AI repos, turned into use cases Get the Monday 5

How to gate an email-sending tool behind confirmation and a guard with Zhizhi Agent Runtime

Declare a high-risk write tool so it runs only after an explicit approval and leaves a receipt.

Short answer: 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); then build the agent with zhizhi.WithGuard(authorize), zhizhi.WithConfirmation(askUser), and a durable zhizhi.WithCheckpointStore(durableStore) in production. All steps.

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

  1. 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).
  2. Build the agent with zhizhi.WithGuard(authorize), zhizhi.WithConfirmation(askUser), and a durable zhizhi.WithCheckpointStore(durableStore) in production.
  3. Run the request. If pending.Suspended is true, show the approval request to the user and keep pending.RunID and pending.Checkpoint.
  4. After approval, call agent.Resume with zhizhi.ResumeRequest containing RunID, Checkpoint, and Decision set to true, passing the same request-scoped tools.
  5. 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

Cursor, ChatGPT, others

Share: X LinkedIn Hacker News Email Copy link

Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer