{
 "schema_version": 1,
 "generated": "2026-10-26",
 "id": "cocoyes-zhizhi-agent-runtime--gate-email-send-behind-confirmation",
 "repo": "cocoyes/zhizhi-agent-runtime",
 "repo_url": "https://github.com/cocoyes/zhizhi-agent-runtime",
 "repo_slug": "cocoyes-zhizhi-agent-runtime",
 "title": "Gate an email-sending tool behind confirmation and a guard",
 "page_title": "How to gate an email-sending tool behind confirmation and a guard with Zhizhi Agent Runtime",
 "summary": "Declare a high-risk write tool so it runs only after an explicit approval and leaves a receipt.",
 "who": "A developer building an agent that can send messages on behalf of a user and must not send without approval.",
 "problem": "An 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.",
 "outcome": "A send-email tool that returns CONFIRMATION_REQUIRED until approved, and resumes from a checkpoint after approval without repeating completed writes.",
 "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."
 ],
 "agent_prompt": "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.",
 "agents": [
  "any"
 ],
 "difficulty": "Advanced",
 "time": "2 hours",
 "basis": "readme",
 "caveat": "Without a durable checkpoint store the default store is process-local, so a suspended approval is lost if the process restarts.",
 "category": "Software and DevOps",
 "tags": [
  "Software and DevOps"
 ],
 "lang": "go",
 "requirements": [
  "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"
 ],
 "risk": "none",
 "seen_in_the_wild": false,
 "mentioned_publicly": false,
 "risks": [],
 "best": false,
 "score": 0.8,
 "evidence": [],
 "url": "https://dedupedai.com/use-cases/cocoyes-zhizhi-agent-runtime/gate-email-send-behind-confirmation/",
 "md": "https://dedupedai.com/use-cases/cocoyes-zhizhi-agent-runtime/gate-email-send-behind-confirmation/index.md",
 "disclaimer": "Deduped lists open-source repositories that belong to other people. We do not own, maintain, audit, or vouch for any of them, and a repo appearing here is not an endorsement or a safety check. The use cases, steps, and prompts are written by AI and may be incomplete, outdated, or just wrong. Where a use case is marked \"Seen in the wild\", we link to public posts where someone described something similar, but we have not verified those posts and the use case itself is still our AI's own write-up. Use all of this at your own risk. Only run code, commands, or agents on systems and accounts you are authorized to use, and read the code and every command before you run it, especially anything that touches credentials, files, or the network. Nothing here is professional, security, legal, or financial advice. All trademarks and project names belong to their respective owners, and their use here does not imply affiliation. Content is provided as is, without warranties of any kind. Found a mistake, a safety problem, or something you want removed? Email hello@dedupedai.com and we will look at it promptly.",
 "api": "https://dedupedai.com/api/v1/usecases/cocoyes-zhizhi-agent-runtime--gate-email-send-behind-confirmation.json",
 "api_version": "v1"
}
