Prompt Details
Model
(claude-5-5-sonnet)
Token size
3,973
Example input
[DESCRIBE THE COMPLEX OBJECTIVE THE MULTIAGENT SYSTEM MUST ACCOMPLISH]: Build a multiagent AI system that handles customer queries, checks order status, identifies issues, processes eligible refunds/returns, and escalates complex cases to human support.
[DESCRIBE MAJOR TASKS, USER JOURNEYS, PROCESSES, DECISIONS, AND EXPECTED OUTPUTS]: Customer asks a question → identify intent → retrieve order information → investigate issue → decide resolution → execute permitted action → respond to customer.
[DESCRIBE REQUIRED SPECIALIZATIONS, SKILLS, KNOWLEDGE, REASONING, OR EXECUTION CAPABILITIES]: Intent classification, customer support reasoning, order investigation, policy verification, refund/return analysis, action execution, quality review.
[DESCRIBE KNOWLEDGE SOURCES, MEMORY REQUIREMENTS, SHARED STATE, TASK STATE, RAG, DATABASES, OR CONTEXT]: Customer profile, order history, product information, support policies, current workflow state, conversation context, audit logs.
[DEFINE SUCCESS, QUALITY, SAFETY, RELIABILITY, PERFORMANCE, AND ACCEPTANCE REQUIREMENTS]: Correct routing, accurate answers, policy-compliant actions, no unauthorized refunds, low duplicate execution, reliable escalation, traceable decisions.
Example output
# 🧠 PHASE 1 — SYSTEM REQUIREMENT RECONSTRUCTION
### 🎯 Primary Objective
Create a controlled multiagent customer-support system capable of:
**Customer Request → Investigation → Policy Check → Resolution → Authorized Action → Customer Response**
The system should automate routine cases while escalating ambiguous or high-impact cases.
### 👥 Users
- Customer
- Customer-support staff
- Support manager
- System administrator
### 📥 Main Inputs
- Customer message
- Customer ID
- Order ID
- Product information
- Order status
- Previous support history
### 📤 Main Outputs
- Answer to customer
- Order explanation
- Return/refund decision
- Executed authorized action
- Escalation ticket when required
- Audit record
### ⚠️ Failure Consequences
Potential failures include:
- Incorrect customer information
- Unauthorized refund
- Incorrect return decision
- Duplicate refund
- Privacy violation
- Incorrect escalation
- Customer receiving misleading information
### Explicit Requirements
- Multiple specialized capabilities are required.
- Order information must be retrieved from external systems.
- Policies must be checked before consequential actions.
- High-value refunds require human approval.
- Actions require authorization.
- Workflow state must be traceable.
### Derived Requirements
- Idempotency is required for refund actions.
- Agents should not directly modify shared state without authorization.
- Customer identity/order ownership should be validated.
- Tool failures require bounded retries.
- Agent-generated instructions must not override security policies.
### Open Decisions
- Exact refund threshold is unspecified.
- Exact SLA is unspecified.
- Exact model providers are unspecified.
- Exact database technology is unspecified.
- Exact tenant architecture is unspecified.
---
# 🧩 PHASE 2 — CAPABILITY & TASK DECOMPOSITION
| Capability | Type | Primary Owner | Failure Impact |
|---|---|---|---|
| Intent Detection | Analysis | Triage Agent | Medium |
| Customer Verification | Verification | Verification Agent | High |
| Order Investigation | Research | Order Agent | High |
| Policy Interpretation | Analysis | Policy Agent | High |
| Resolution Planning | Planning | Resolution Agent | High |
| Refund/Return Execution | Execution | Action Agent | Critical |
| Response Generation | Generation | Response Agent | Medium |
| Human Escalation | Coordination | Escalation Agent | High |
| Audit Logging | Monitoring | Platform Layer | High |
### 🔍 Multiagent Justification
Not every capability needs a separate agent.
For example:
- Intent detection can be lightweight.
- Response generation does not necessarily need an independent autonomous agent.
- Audit logging should preferably be an application/platform capability rather than an LLM agent.
The strongest separation is around **different authority and risk boundaries**.
---
# 🏗️ PHASE 3 — MULTIAGENT JUSTIFICATION
### A — Single Agent
**Advantages:**
- Simple
- Low coordination overhead
- Easier deployment
**Problems:**
- Too much authority concentration
- Harder to isolate sensitive actions
- Greater risk of unauthorized tool usage
### B — Coordinator + Specialists
**Advantages:**
- Clear ownership
- Controlled delegation
- Easier security boundaries
- Easier observability
**Assessment:** Suitable.
### C — Peer Agents
Could create unnecessary coordination complexity.
### D — Hierarchical Agents
Useful when there are multiple layers of workflows, but unnecessary for this initial system.
### E — Blackboard
Useful for shared state, but shared state should be controlled by the application rather than unrestricted agent access.
### F — Event-Driven
Useful for asynchronous operations such as escalation and long-running investigations.
### G — Hybrid
**Selected approach: Hybrid Coordinator + Specialists + Application-Controlled State + Event-Based Escalation.**
---
# 🤖 PHASE 4 — AGENT ROLE ARCHITECTURE
## 1. 🎯 Triage Agent
**Mission:** Understand the customer request and classify the workflow.
**Owns:**
- Intent classification
- Initial routing
- Required information identification
**Does Not Own:**
- Refund execution
- Customer-data modification
- Final authorization
**Tools:**
- Conversation context
- Intent classifier
**Why it exists:**
Separates routing from consequential actions.
---
## 2. 🔎 Verification & Order Agent
**Mission:** Verify customer/order information and investigate order state.
**Owns:**
- Customer verification
- Order retrieval
- Order status analysis
**Does Not Own:**
- Refund execution
- Policy override
**Tools:**
- Customer database
- Order API
---
## 3. 📜 Policy Agent
**Mission:** Determine which resolution is permitted under current support policy.
**Owns:**
- Policy interpretation
- Eligibility analysis
- Evidence requirements
**Does Not Own:**
- Final external action
**Tools:**
- Policy knowledge base
---
## 4. 🧠 Resolution Agent
**Mission:** Convert verified facts and policy results into a proposed resolution.
**Owns:**
- Resolution planning
- Recommendation generation
**Does Not Own:**
- Unauthorized execution
- Policy modification
---
## 5. ⚙️ Action Agent
**Mission:** Execute explicitly authorized external actions.
**Owns:**
- Refund initiation
- Return creation
- Support-ticket updates
**Does Not Own:**
- Policy interpretation
- Authorization creation
**Why it exists:**
The highest-risk tools are isolated behind a dedicated execution boundary.
---
## 6. 🛡️ Review/Escalation Agent
**Mission:** Detect cases requiring human intervention.
**Owns:**
- Ambiguity detection
- High-risk escalation
- Missing-evidence detection
**Does Not Own:**
- Overriding authorization
---
# 🔐 PHASE 5 — OWNERSHIP & AUTHORITY MODEL
| Task | Primary Owner | Supporting | Authorization |
|---|---|---|---|
| Intent classification | Triage | - | System |
| Customer verification | Verification | Triage | System |
| Order lookup | Order | Verification | System |
| Policy interpretation | Policy | Order | Policy rules |
| Resolution proposal | Resolution | Policy | System |
| Refund execution | Action | Resolution | Authorization layer |
| High-value refund | Action | Review | Human |
| Customer response | Response layer | All relevant agents | System |
| Audit record | Application | All agents | System |
### 🔑 Important Separation
**Capability ≠ Permission ≠ Authority ≠ Accountability**
The Resolution Agent may have the **capability** to recommend a refund.
It does not automatically receive **permission** to execute one.
The Action Agent may have **permission** to call the refund API.
It still cannot create authorization for itself.
---
# 🕸️ PHASE 6 — MULTIAGENT TOPOLOGY
### Selected Topology: Hybrid
```text
👤 Customer
│
▼
🎯 Triage Agent
│
▼
🔎 Verification Agent
│
▼
📦 Order Agent
│
▼
📜 Policy Agent
│
▼
🧠 Resolution Agent
│
┌──────┴──────┐
│ │
Low Risk High Risk
│ │
▼ ▼
⚙️ Action Agent 🛡️ Human Review
│ │
└──────┬──────┘
▼
💬 Final Response
```
### 🔄 Termination Conditions
Workflow terminates when:
- Customer question is answered.
- Authorized action succeeds.
- Human escalation is created.
- Required information cannot be obtained.
- Security violation is detected.
- Maximum retry/attempt limit is reached.
---
# 🔀 PHASE 7 — ORCHESTRATION & ROUTING
### Example Workflow
**TRIGGER:** Customer asks "My package hasn't arrived."
**SENDER:** Triage Agent
**RECEIVER:** Verification Agent
**INPUT:** Customer ID + conversation context
**ACTION:** Validate customer and identify order
**OUTPUT:** Verified customer/order reference
**NEXT STATE:** `ORDER_INVESTIGATION`
Then:
```text
ORDER_INVESTIGATION
↓
POLICY_CHECK
↓
RESOLUTION_PLANNING
↓
AUTHORIZATION_CHECK
↓
ACTION / ESCALATION
↓
FINAL_RESPONSE
```
### 🚦 Routing Rules
- Missing customer identity → Verification
- Order-status question → Order Agent
- Refund/return request → Policy Agent
- Policy ambiguity → Review/Escalation
- Authorized low-risk action → Action Agent
- High-impact action → Human approval
- Tool failure → bounded retry
- Security anomaly → terminate/escalate
Arbitrary agent-to-agent routing is prohibited.
---
# 📡 PHASE 8 — COMMUNICATION & HANDOFF CONTRACTS
Example handoff:
```json
{
"workflow_id": "WF-001",
"task_id": "TASK-004",
"sender": "order_agent",
"receiver": "policy_agent",
"purpose": "Evaluate refund eligibility",
"context": {
"order_id": "ORDER-123",
"order_status": "DELIVERED",
"delivery_date": "2026-09-28"
},
"evidence": [
"order_api_result"
],
"status": "completed",
"next_transition": "policy_evaluation"
}
```
### 🧱 Handoff Controls
Every handoff requires:
- Workflow ID
- Task ID
- Sender
- Receiver
- Purpose
- Required context
- Evidence
- Status
- Next transition
This prevents context loss and duplicate work.
---
# 🧠 PHASE 9 — MEMORY, CONTEXT & STATE
### Shared Memory
Only information legitimately required across agents:
- Customer/order reference
- Verified facts
- Policy version
- Workflow status
- Action status
### Private Agent Memory
Temporary reasoning/context specific to the agent.
### Task State
```text
RECEIVED
↓
TRIAGED
↓
VERIFIED
↓
INVESTIGATED
↓
POLICY_CHECKED
↓
RESOLUTION_PROPOSED
↓
AUTHORIZED
↓
EXECUTED
↓
RESPONDED
```
### Long-Term Memory
Potentially:
- Customer preferences
- Historical support interactions
- Approved persistent business information
Access must remain tenant/user scoped.
### 🚫 Prevent
- Customer A's data entering Customer B's workflow
- Previous workflow state leaking into a new task
- Stale refund authorization being reused
- One agent modifying another agent's private state
---
# 🛠️ PHASE 10 — TOOL & ACTION ARCHITECTURE
| Tool | Agent | Access |
|---|---|---|
| Customer DB | Verification | READ |
| Order API | Order | READ |
| Policy KB | Policy | READ |
| Refund API | Action | WRITE/EXECUTE |
| Return API | Action | WRITE/EXECUTE |
| Ticket System | Escalation/Action | WRITE |
| Audit Log | Application | WRITE |
### 🔒 Important Rule
The Triage Agent should **not** receive refund API credentials.
The Policy Agent should **not** receive refund execution permissions.
The Resolution Agent should **not** be able to directly bypass the authorization layer.
---
# ⚔️ PHASE 11 — CONFLICT RESOLUTION
### Example Conflict
Order Agent:
> Order appears delivered.
Policy Agent:
> Refund may be permitted under a delivery dispute policy.
Resolution Agent:
> Customer should receive a refund.
These are not automatically equivalent.
### Resolution Process
```text
FACT CONFLICT
↓
Evidence comparison
↓
Source freshness check
↓
Designated owner
↓
Review if unresolved
↓
Human escalation if consequential
```
For high-impact decisions, **majority voting is not sufficient**.
---
# 🚨 PHASE 12 — FAILURE & RECOVERY
### Agent Failure
**Detection:** timeout/invalid response
**Containment:** stop downstream execution
**Recovery:** bounded retry
**Fallback:** alternate approved route
**Escalation:** human support if unresolved
---
### Tool Failure
```text
Tool Error
↓
Retry 1
↓
Retry 2
↓
Circuit/Failure State
↓
Escalation
```
No unlimited retries.
---
### Duplicate Refund
Use:
- Unique transaction ID
- Idempotency key
- Action state
- Execution ledger
Before execution:
```text
Is this action already completed?
↓
YES → Do not execute
NO → Continue authorization check
```
---
# 🛡️ PHASE 13 — SECURITY & GOVERNANCE
### Authentication
Verify the identity/context associated with the customer request.
### Authorization
Check whether the current workflow and actor are permitted to perform the action.
### Least Privilege
Each agent receives only the tools required for its responsibility.
### Prompt Injection Defense
Treat:
- Customer messages
- Retrieved documents
- External tool results
- Agent-generated instructions
as potentially untrusted content.
They cannot override system-level authorization.
### Tenant Isolation
Every workflow should carry a tenant/customer scope.
```text
Tenant ID
+
User ID
+
Workflow ID
+
Authorization Context
```
must be validated before sensitive access.
### Auditability
Record:
- Agent
- Task
- Tool
- Input reference
- Output
- Authorization
- Timestamp
- Result
- Failure
---
# 🧪 PHASE 14 — EVALUATION & TESTING
## Agent-Level Tests
- Correct intent classification
- Correct order retrieval
- Correct policy interpretation
- Correct resolution proposal
- Correct tool usage
- Correct escalation
## Coordination Tests
- Correct routing
- Correct handoffs
- No duplicate work
- No circular delegation
- Correct state transitions
## Security Tests
- Unauthorized refund attempt
- Cross-customer data access
- Prompt injection
- Tool privilege escalation
- Invalid authorization
## Failure Tests
- Order API timeout
- Policy database unavailable
- Action API failure
- Malformed agent output
- Coordinator failure
- Duplicate request
- Stale workflow state
### 📊 Key Metrics
- End-to-end success rate
- Routing accuracy
- Policy compliance
- Unauthorized-action rate
- Escalation accuracy
- Duplicate-action rate
- Mean latency
- Tool failure rate
- Recovery success rate
- Cost per workflow
No test result should be claimed until actually measured.
---
# 📈 PHASE 15 — OBSERVABILITY & PRODUCTION OPERATIONS
### 🔍 Distributed Trace
```text
Workflow ID
↓
Triage
↓
Verification
↓
Order
↓
Policy
↓
Resolution
↓
Authorization
↓
Action
↓
Response
```
Each step receives a trace/span identifier.
### 📊 Monitor
- Agent latency
- Agent failures
- Tool latency
- Tool errors
- Token/model usage
- Cost
- State transitions
- Escalations
- Authorization failures
- Retry counts
- Duplicate executions
### ⚡ Optimization
Potential optimizations:
- Lightweight model for classification
- Parallel independent read operations
- Cache stable policy information
- Minimize transferred context
- Avoid unnecessary specialist agents
- Use deterministic application logic for authorization
Security and validation controls should not be removed merely to reduce cost.
---
# 🏆 PHASE 16 — FINAL MULTIAGENT SYSTEM BLUEPRINT
## 1. Executive System Summary
A **hybrid coordinator-based architecture** is selected.
The system separates:
**Understanding → Verification → Investigation → Policy → Resolution → Authorization → Execution**
The most consequential operation, refund/return execution, is isolated behind an authorization boundary.
---
## 2. Agent Roster
| Agent | Mission | Owns | Does Not Own | Tools |
|---|---|---|---|---|
| 🎯 Triage | Understand & route | Intent | Actions | Context |
| 🔎 Verification | Verify identity | Customer verification | Refund | Customer DB |
| 📦 Order | Investigate orders | Order facts | Policy override | Order API |
| 📜 Policy | Evaluate rules | Eligibility | Execution | Policy KB |
| 🧠 Resolution | Plan solution | Resolution proposal | Authorization | Verified context |
| ⚙️ Action | Execute | Authorized actions | Authorization creation | Action APIs |
| 🛡️ Review | Handle ambiguity/risk | Escalation | Security override | Ticket system |
---
# 📋 3. Capability & Responsibility Matrix
```text
Understand Request → Triage
Verify Customer → Verification
Investigate Order → Order
Interpret Policy → Policy
Design Resolution → Resolution
Authorize Action → Authorization Layer / Human
Execute Action → Action
Escalate → Review
Audit → Application Layer
```
---
# 🔐 4. Authority & Permission Matrix
| Agent | Read Customer | Read Order | Read Policy | Execute Refund | Escalate |
|---|---:|---:|---:|---:|---:|
| Triage | Limited | No | No | No | Yes |
| Verification | Yes | Limited | No | No | Yes |
| Order | No/Scoped | Yes | No | No | Yes |
| Policy | No | Required facts only | Yes | No | Yes |
| Resolution | Scoped | Scoped | Yes | No | Yes |
| Action | Scoped | Required facts | No | Yes* | Yes |
| Review | Scoped | Scoped | Yes | No | Yes |
`*` Only after authorization requirements are satisfied.
---
# 🏗️ 5. Selected Topology
**Hybrid Coordinator + Specialists + Controlled Execution + Human Escalation**
```text
Customer
↓
Triage
↓
Verification
↓
Order Investigation
↓
Policy
↓
Resolution
↓
Authorization
┌─┴─────────────┐
↓ ↓
Action Human Review
└───────┬───────┘
↓
Response
```
---
# 🔄 6. Orchestration Graph
```text
REQUEST_RECEIVED
↓
TRIAGE
↓
VERIFY
↓
INVESTIGATE
↓
POLICY_CHECK
↓
RESOLUTION
↓
AUTHORIZATION
↙ ↘
APPROVE ESCALATE
↓ ↓
ACTION HUMAN REVIEW
↓ ↓
└────┬────┘
↓
RESPONSE
↓
COMPLETED
```
---
# 💾 7. State Architecture
**Workflow State** is application-owned.
Agents can propose state transitions but cannot arbitrarily rewrite workflow history.
Every state transition records:
```text
workflow_id
task_id
previous_state
new_state
actor
authorization
timestamp
evidence
result
```
---
# ⚔️ 8. Conflict Resolution
```text
Agent disagreement
↓
Check evidence
↓
Check authoritative source
↓
Designated owner
↓
Reviewer
↓
Human escalation if consequential
```
---
# 🚨 9. Failure Architecture
| Failure | Detection | Containment | Recovery | Escalation |
|---|---|---|---|---|
| Agent timeout | Timeout | Stop transition | Bounded retry | Human |
| Tool failure | API error | Block action | Retry | Escalate |
| Bad output | Schema validation | Reject output | Regenerate | Review |
| Duplicate action | Idempotency check | Block execution | Reconcile | Operations |
| Stale state | Version check | Reject update | Refresh | Review |
| Security violation | Policy check | Terminate action | None | Security team |
| Coordinator failure | Health check | Preserve state | Resume | Operations |
---
# 🛡️ 10. Security Architecture
```text
User
↓
Identity
↓
Tenant Scope
↓
Workflow Authorization
↓
Agent Permission
↓
Tool Permission
↓
Action Authorization
↓
External System
```
No agent can skip a layer merely by instructing another agent to do so.
---
# 🧪 11. Evaluation Architecture
### Test Categories
1. Normal customer workflow
2. Ambiguous request
3. Missing order
4. Incorrect customer identity
5. Policy conflict
6. Tool timeout
7. Duplicate refund
8. Prompt injection
9. Unauthorized action
10. Cross-tenant access attempt
11. Coordinator failure
12. State recovery
13. Human escalation
14. Replay of completed workflow
### Core Acceptance Criteria
- Correct routing
- Correct state transitions
- Zero unauthorized consequential actions
- No cross-user data leakage
- Bounded retries
- Traceable actions
- Correct escalation behavior
---
# 👀 12. Observability
Every workflow should be traceable:
```text
Customer Request
↓
Workflow ID
↓
Agent Decisions
↓
Handoffs
↓
Tool Calls
↓
State Changes
↓
Authorization
↓
External Action
↓
Final Response
```
This creates end-to-end operational lineage.
---
# 🧠 Critical Architecture Decisions
| Decision | Selected Approach | Alternatives | Reason | Risk |
|---|---|---|---|---|
| Agent topology | Hybrid | Single/peer | Separates responsibilities | Coordination overhead |
| State | Application-owned | Shared agent memory | Strong consistency/control | Implementation complexity |
| Execution | Dedicated Action Agent | Every agent | Limits dangerous tools | Extra handoff |
| Authorization | Separate boundary | Agent decision | Prevents privilege confusion | Added latency |
| High-impact actions | Human approval | Full automation | Limits consequential errors | Lower automation |
| Communication | Structured contracts | Free-form messages | Traceability | Schema maintenance |
| Recovery | Bounded retry | Unlimited retry | Prevents loops | Some transient failures remain |
| Conflict | Evidence + owner + escalation | Voting | Better for consequential decisions | Review overhead |
---
# 🚀 Implementation Sequence
**Phase 1 → Foundation**
- Define workflows
- Define schemas
- Define state machine
- Define authorization boundaries
**Phase 2 → Core Capabilities**
- Triage
- Verification
- Order investigation
- Policy retrieval
**Phase 3 → Resolution**
- Resolution Agent
- Structured handoffs
- Validation
**Phase 4 → Controlled Execution**
- Action Agent
- Authorization layer
- Idempotency
**Phase 5 → Resilience**
- Retry
- Recovery
- Escalation
- Failure handling
**Phase 6 → Security**
- Tenant isolation
- Least privilege
- Injection defenses
- Audit controls
**Phase 7 → Evaluation**
- Agent tests
- Interaction tests
- Failure tests
- Security tests
**Phase 8 → Production**
- Distributed tracing
- Metrics
- Cost monitoring
- Quality monitoring
- Operational dashboards
---
# 🚨 Critical Failure Modes
| Failure | Detection | Containment | Recovery | Escalation |
|---|---|---|---|---|
| Wrong agent routing | Routing validation | Pause workflow | Re-route | Review |
| Missing context | Schema validation | Reject handoff | Retrieve required data | Escalate |
| Circular delegation | Delegation graph | Terminate loop | Return to coordinator | Operations |
| Duplicate execution | Idempotency | Block action | Reconcile | Operations |
| Unauthorized action | Authorization check | Deny | None | Security |
| Stale state | Version check | Reject write | Refresh | Review |
| Agent hallucination | Evidence validation | Reject claim | Re-query | Human |
| Tool outage | Health/error monitoring | Disable dependent action | Retry later | Human |
| Coordinator failure | Heartbeat/state check | Preserve state | Resume workflow | Operations |
---
# 🎯 Final Architecture
**OBJECTIVE**
→ Customer support and order-resolution automation
**CAPABILITIES**
→ Triage → Verification → Investigation → Policy → Resolution → Execution
**AGENTS**
→ Specialized agents with narrow ownership
**OWNERSHIP**
→ One primary owner per consequential task
**TOPOLOGY**
→ Hybrid coordinator + specialists
**ORCHESTRATION**
→ Controlled routing through explicit workflow states
**STATE**
→ Application-owned, versioned, traceable state
**TOOLS**
→ Least-privilege, capability-specific access
**SECURITY**
→ Authentication + authorization + tenant isolation + auditability
**CONFLICT RESOLUTION**
→ Evidence → designated owner → review → human escalation
**RECOVERY**
→ Detection → containment → bounded retry → fallback → escalation
**EVALUATION**
→ Agent + coordination + system + security + failure testing
**PRODUCTION**
→ End-to-end tracing + metrics + cost + latency + quality + failure monitoring
**Key architectural principle:** The system is not made reliable by adding more agents. It is made reliable by giving each agent a **clear boundary, limited authority, explicit handoff contract, controlled tools, recoverable state, and measurable responsibility**.
By purchasing this prompt, you agree to our terms of service
CLAUDE-5-5-SONNET
Designing multiple AI agents is easy. Designing a multiagent system that remains reliable, coordinated, secure, observable, and maintainable is much harder.
Turn a complex AI workflow into a complete, production-oriented multiagent system architecture.
...more
Added 1 week ago
