Human-in-the-Loop Agents in Pure Dart: Genkit, MCP and an Approval Gate on Cloud Run
1. The problem: an agent that can spend money Most agent demos stop at "the model called a...
First seen by Oriel on .
AI summary
This article builds a pure-Dart dispatch agent using Genkit, MCP, Flutter, and Cloud Run, with middleware pausing money-costing tools for human approval.
- The agent uses MCP tools for work-order lookup, visit scheduling, and spare-part ordering, while toolApproval requires approval before paid actions.
- Approvals interrupt generation, store the conversation under a single-use approvalId, and resume or decline the pending tool request.
- Genkit Dart 1.0.1 failed to resume namespaced MCP tools; the author patched it locally and filed fixes in genkit-ai/genkit-dart#657 and #658.
- Fourteen tests cover lookup, approval, decline, and duplicate-answer flows using a fake model, with no Gemini key or external network.
- A native Dart deployment packages the agent, MCP server, and HTTP router into a 20.7 MB scratch image, but in-memory approvals do not survive restarts.
Generated by gpt-5.6-sol. Check the original for details.
Metric trends
Last 30 days · Up to 120 recorded samples per source and metric, with reposts kept separate · First and latest retained
Reactions
Total public reactions reported by the source; distinct from points and likes.
- DEV Community: 14, latest observation ; 0 over observed period since
Comments
Comment count reported by the source.
- DEV Community: 11, latest observation ; +6 over observed period since
Aliases
| Source | External ID | URL |
|---|---|---|
| DEV Community | 4927297 | https://dev.to/gde/human-in-the-loop-agents-in-pure-dart-genkit-mcp-and-an-approval-gate-on-cloud-run-4gmc Read discussion |