๐ Try the demo: https://github.com/LM-Kit/lm-kit-net-samples/tree/main/console_net/ai-agents/permissions/approval_and_resume
Approval and Resume for C# .NET Applications
๐ฏ Purpose of the Demo
An interactive console app where an agent stops before every refund it wants to issue. The run is saved as a JSON file; a person approves or denies the refund now, or after closing and reopening the program, and a fresh executor continues the run exactly where it stopped.
All inference runs on-device.
๐ฅ Industry Target Audience
- Support and back-office teams whose agents may propose payments, refunds or account changes but never execute them alone.
- Platform engineers building approval inboxes where a decision comes minutes or days later, from another process.
- Compliance-minded teams who need every write to be decided by a person, bound to the exact arguments shown.
๐ Problem Solved
An approval event that blocks the conversation works only while one process waits for one person. Real approvals come later, from elsewhere, after restarts. Resumable runs turn the wait into data: the run stops, its state is stored, and any process resumes it with the decision. A decision cannot be replayed onto other arguments, a denied call never runs, and a write in flight at a crash is never sent twice blindly.
๐ป Application Overview
Interactive menu (no command-line arguments):
| Option | What it does |
|---|---|
| A customer asks | Runs a request with DeferToolApprovals; a refund stops the run before the call and saves it under runs/. |
| Review | Lists the runs waiting for an approval, shows each pending call with its arguments, and resumes the run with your decision. |
โจ Key Features
AgentExecutionOptions.DeferToolApprovals: a call that needs approval ends the run asAwaitingApproval.AgentRunStateandFileAgentRunStore: a versioned, model-independent snapshot (history, pending round, budgets), saved at every checkpoint.AgentExecutor.ResumeAsyncwithToolApprovalDecision: approve, deny with a reason, or approve edited arguments; each decision is bound to its call and arguments hash.- Idempotency keys:
AgentRunContext.Current.IdempotencyKeyis stable across resumes, for tools that write to systems which deduplicate.
๐ง Models
qwen3.5:4b(about 3 GB of VRAM, tool calling).
๐ ๏ธ Getting Started
๐ Prerequisites
- .NET 8.0 or later
โถ๏ธ Running the Application
git clone https://github.com/LM-Kit/lm-kit-net-samples
cd lm-kit-net-samples/console_net/ai-agents/permissions/approval_and_resume
dotnet run
Type 1 and a customer request, then 2 to approve or deny. Quit before deciding and start again: the run is still waiting.