Prompt
How do I set up a multi-agent management platform for state persistence and human-in-the-loop approvals?
Latest observation
Here’s a practical way to set up a multi-agent management platform with state persistence and human-in-the-loop (HITL) approvals.
1) Define the core architecture
You usually want these components:
- Orchestrator / Supervisor
- Coordinates agents
- Decides which agent acts next
- Maintains workflow state
- Specialized agents
- e.g. Research, Planner, Executor, Reviewer, Compliance
- Persistent state store
- Saves conversation/task state, agent outputs, approval status, and checkpoints
- Approval gateway
- Pauses execution when a human decision is required
- Event bus / queue
- Helps agents communicate asynchronously
- Audit log
- Tracks every action, message, tool call, and approval
A good pattern is:
User request → Orchestrator → Agents → State store → Approval checkpoint → Human approval/rejection → Resume
2) Choose a state model
Persist everything needed to resume execution safely.
Typical state fields:
workflow_idrun_idcurrent_stepactive_agenttask_descriptionagent_messagestool_callsartifactsapproval_required: true/falseapproval_status: pending/approved/rejectedapproval_reasontimestampsretry_countfinal_result
Store state in one of:
- PostgreSQL for structured workflows and auditability
- Redis for fast ephemeral state
- MongoDB / document store for flexible agent transcripts
- Object storage for larger artifacts
A common setup:
- PostgreSQL for workflow metadata and approvals
- Redis for runtime/session state
- S3/blob storage for files and large outputs
3) Make agents stateless, state lives outside them
This is important for reliability.
Each agent should:
- Read the current state from the store
- Perform its role
- Emit result + next-step suggestion
- Write updates back to the store
Avoid relying on in-memory state inside an agent process, because:
- processes can crash
- you may scale horizontally
- you need resumability
4) Implement workflow checkpoints
A checkpoint is a save point before risky or human-sensitive actions.
Example checkpoints:
- Sending an email
- Making a purchase
- Modifying production data
- Deploying code
- Releasing a report to a customer
At a checkpoint:
- Agent prepares proposed action
- Orchestrator stores it
- Approval gateway flags it as
pending - Human reviews in UI
- Human approves/rejects
- Workflow resumes or branches
5) Build a human approval interface
Your UI should show:
- Current workflow status
- Agent reasoning summary
- Proposed action
- Supporting evidence/artifacts
- Approve / Reject / Edit / Request changes buttons
- Comments field
- History of prior approvals
For safety and traceability:
- Include who approved
- When they approved
- What exactly was approved
- A diff if the human modified the action
6) Use a message/event-driven flow
Instead of direct synchronous calls between agents, use events such as:
task.createdagent.completedapproval.requestedapproval.grantedapproval.deniedworkflow.resumed
This makes it easier to:
- retry failed steps
- scale agents independently
- monitor execution
- replay workflows
Tools often used:
- RabbitMQ
- Kafka
- Celery / Redis queue
- AWS SQS/SNS
- Temporal for durable workflows
7) Recommended control logic
A simple orchestration loop:
- Receive user request
- Create workflow state
- Assign first agent
- Agent completes work
- Orchestrator checks if approval is needed
- If yes, pause and notify human
- Wait for decision
- If approved, continue with next agent/action
- If rejected, revise or terminate
- Persist final outcome
Pseudo-logic:
if state.approval_required and state.approval_status == "pending":
pause_workflow()
elif approval_received:
resume_workflow()
else:
route_to_next_agent()
8) Add guardrails
For production systems, include:
- Role-based access control
- Approval thresholds based on risk or cost
- Prompt/tool input validation
- Action allowlists
- Rate limits
- Secrets management
- Full audit trail
- Fallback/rollback strategies
Examples:
- Require 2 approvals for spend > $1,000
- Block production DB writes without manual confirmation
- Prevent agents from accessing secrets directly
9) Persist conversations and artifacts
Store:
- full chat history
- agent outputs
- prompt versions
- model versions
- tool inputs/outputs
- generated files
- approval records
This helps with:
- debugging
- compliance
- reproducibility
- evaluation
10) A practical technology stack
One example stack:
- Backend: Python + FastAPI
- Workflow engine: Temporal or Celery
- DB: PostgreSQL
- Cache/session state: Redis
- Artifacts: S3
- Frontend: React/Next.js
- Auth: OAuth2 / SSO
- Logging/monitoring: OpenTelemetry + Grafana + Loki
- Agent framework: LangGraph, AutoGen, CrewAI, or custom
If you want durable orchestration and HITL, Temporal is especially strong.
11) Example data model
{
"workflow_id": "wf_123",
"status": "waiting_for_approval",
"current_step": "send_email",
"active_agent": "executor",
"task": "Draft and send outreach email",
"approval_required": true,
"approval_status": "pending",
"proposed_action": {
"type": "send_email",
"recipient": "client@example.com",
"subject": "Follow-up",
"body": "..."
},
"history": [
{
"step": "research",
"agent": "researcher",
"output": "..."
}
]
}
12) Minimal implementation pattern
If you’re building from scratch:
- Orchestrator stores workflow state in PostgreSQL
- Agents are worker services that fetch tasks
- Before risky operations, write an approval request record
- UI polls or subscribes to approval events
- On human approval, orchestrator updates state and enqueues the next task
13) Best practice: separate “thinking” from “acting”
A strong pattern is:
- Planner agent: decides what should happen
- Executor agent: prepares the action
- Reviewer agent: checks for issues
- Human approver: authorizes real-world effects
This reduces the chance that one agent directly performs unsafe actions.
If you want, I can also give you:
- a reference architecture diagram,
- a PostgreSQL schema for workflow persistence and approvals, or
- a FastAPI + Temporal example for implementing this.
Observation history
Unlock observation history
Create a free Obsurfable account to unlock historical responses, model comparisons, and deeper brand intelligence.
How did Obsurfable measure this prompt?
Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.
Which AI systems does Obsurfable collect answers from?
OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, and Meta AI.