Prompt
How do I set up a multi-step agent workflow for internal ops tasks?
Latest observation
A good multi-step agent workflow for internal ops usually looks like: triage → gather context → plan → execute tools → verify → escalate/record. The key is to keep each step narrow, observable, and permissioned.
1) Define the workflow stages
For internal ops tasks, a reliable pattern is:
-
Intake / Triage
- Classify the request
- Check urgency, owner, and required approvals
- Decide whether it can be handled automatically
-
Context gathering
- Pull relevant data from systems of record
- Example: tickets, HRIS, CRM, finance tools, logs, docs
-
Plan
- Break the task into explicit substeps
- Choose tools needed for each substep
- Identify risks and approval points
-
Execute
- Perform actions via tools/APIs
- Keep each action small and reversible where possible
-
Verify
- Confirm the result using a separate check
- Compare expected vs actual output
-
Escalate / handoff
- If confidence is low or policy requires approval, route to a human
- Provide a concise summary, evidence, and recommended next action
-
Record / audit
- Log inputs, tool calls, outputs, and final resolution
- Useful for compliance and debugging
2) Use an orchestrator, not one “do-everything” prompt
The most maintainable setup is a controller/orchestrator that routes work to specialized steps or agents.
Common structure:
- Router agent: identifies task type
- Planner agent: decomposes task into steps
- Executor agent: calls tools
- Verifier agent: checks results
- Policy gate: blocks unsafe actions
- Human approval step: when needed
This can be implemented as:
- a single application with a state machine, or
- separate agent services connected by a queue/workflow engine.
3) Make state explicit
Store workflow state in a durable object, not in chat history alone.
Example state fields:
task_idrequest_typepriorityassigned_ownerpermissions_requiredcurrent_steptool_outputsapproval_statusverification_statusaudit_log
This makes retries, restarts, and handoffs much safer.
4) Put hard guardrails around tools
For internal ops, tool access should be constrained:
- Allowlist tools only
- Per-tool permissions
- Read-only by default
- Human approval for destructive actions
- Scoped credentials
- Rate limits and timeouts
- Idempotency keys for actions like creating or updating records
Examples:
- Read user info: allowed automatically
- Disable account: requires approval
- Issue refund: requires policy check + approval
- Send external email: verify recipient and content
5) Design prompts by role
Avoid one giant prompt. Use separate instructions per role.
Planner prompt
- Goal: decompose request
- Output: ordered steps, needed tools, risks, approval points
- Must not execute actions
Executor prompt
- Goal: perform one step at a time
- Must use only allowed tools
- Must report raw outputs
Verifier prompt
- Goal: inspect evidence and confirm success
- Should not assume success from execution alone
Triage prompt
- Goal: classify task and route correctly
- Should be fast and conservative
6) Example workflow for an internal ops request
Suppose a user says: “Please onboard Jane Doe, starting Monday.”
Step 1: Triage
- Identify as HR/IT onboarding
- Check start date, manager, department, location
- Determine required systems: HRIS, identity management, Slack, payroll, equipment
Step 2: Gather context
- Pull employee record
- Confirm access policy
- Check whether manager approval exists
- Check whether equipment has been assigned
Step 3: Plan
- Create checklist:
- Create user account
- Assign group memberships
- Provision mailbox
- Create onboarding ticket
- Order equipment
- Identify that account creation is allowed; payroll changes require approval
Step 4: Execute
- Call directory API
- Create ticket
- Send equipment request
- Queue payroll task for human approval
Step 5: Verify
- Confirm account exists
- Confirm groups assigned correctly
- Confirm ticket created
- Confirm pending approval item logged
Step 6: Escalate if needed
- If employee data is incomplete, ask human
- If a tool call fails, retry once or hand off with context
7) Recommended technical architecture
A practical stack:
- Frontend / intake form
- Workflow engine: Temporal, Airflow, Step Functions, Prefect, or a custom state machine
- Agent services:
- router
- planner
- executor
- verifier
- Tool layer:
- internal APIs
- database access
- ticketing systems
- identity and messaging APIs
- Policy service
- Audit logging
- Human review UI
If you want reliability, use a workflow engine rather than a fully free-form agent loop.
8) Best practices
- Keep steps deterministic where possible
- Prefer structured outputs like JSON
- Require citations or evidence from tools
- Validate all tool inputs
- Use retries with backoff
- Separate read and write permissions
- Log every action
- Add “stop conditions” to prevent loops
- Measure success rate, latency, and human escalation rate
9) A simple JSON workflow example
{
"task_id": "ops-1234",
"type": "onboarding",
"state": "planning",
"steps": [
{"name": "collect_context", "status": "done"},
{"name": "build_plan", "status": "done"},
{"name": "provision_account", "status": "pending"},
{"name": "assign_access", "status": "pending"},
{"name": "verify", "status": "pending"},
{"name": "handoff_or_complete", "status": "pending"}
],
"approvals": {
"manager_approval": true,
"security_approval": false
},
"audit": []
}
10) Start small
Begin with one high-volume, low-risk use case:
- onboarding
- ticket triage
- password reset routing
- access request processing
- FAQ + internal routing
Then expand once you have:
- good logs
- clear rollback paths
- safe approvals
- verified success metrics
If you want, I can give you:
- a reference architecture diagram,
- a LangGraph / Temporal example, or
- a prompt + JSON schema template for this workflow.