Agent Cooperation
One of Simple Agent Designer's most powerful features is the ability for multiple agents to work together on complex tasks. This page explains how agent cooperation works and how to design multi-agent workflows.
How Agents Cooperate
Agent cooperation is managed by the orchestration engine — a singleton codeunit that coordinates message passing between agents during workload processing.
The Message Queue
When an agent wants to hand work to another agent, it emits a fenced json code block in its response. The block contains a to field (the target Agent ID) and a payload` object with the message for that agent:
{ "to": "AGENT_B", "payload": { "task": "Please look up customer data for CUST001" } }
The orchestration engine then:
- Parses the fenced
blocks in the response and reads the JSONtoandpayload` values - Confirms
tomatches a configured agent (if not, an error is queued back into the conversation) - Adds the payload to the Ask Queue — a list of pending messages with target Agent ID, message content, and the requesting worker's ID
- After the current agent finishes processing, calls NextToGo() to send the queued messages
Message Flow
Agent A (Coordinator)
↓ Response includes a json block:
↓ { "to": "AGENT_B", "payload": { "task": "Look up customer data" } }
↓
Orchestration Engine
↓ Parses the json block, reads "to" and "payload"
↓ Queues the payload for Agent B
↓ Calls Agent B.Ask({ "task": "Please look up customer data" })
↓
Agent B (Data Lookup)
↓ Queries BC, returns results
↓ Results queued back to Agent A
↓
Orchestration Engine
↓ Calls Agent A.Ask("Reply from AGENT_B: {customer data}")
↓
Agent A (Coordinator)
↓ Continues processing with the returned data
Designing Multi-Agent Workflows
Step 1: Identify the Roles
Break your task into distinct responsibilities:
| Role | Agent Type | Purpose |
|---|---|---|
| Coordinator | AI | Receives the workload, decides what to do, delegates |
| Data Finder | DataAI or AI with tools | Looks up information from Business Central |
| Document Creator | EntryAI / SalesEntryAI / PurchaseEntryAI | Creates business documents |
| Reviewer | AI | Validates results and flags issues |
Step 2: Create the Agents
Create each agent with:
- A clear Agent ID that other agents can reference in the
tofield of a delegation block - A Type appropriate for its role
- Instructions that explain the agent's specialty
Step 3: Configure the Coordinator
The coordinator agent needs instructions that tell it about the available agents:
You are a workload coordinator. You work with these agents:
- DATAQUERY: Looks up customer, vendor, and item data in Business Central
- GLPOSTER: Creates general ledger journal entries
- REVIEWER: Validates journal entries before posting
When you receive a task:
1. Analyze what data you need
2. Ask DATAQUERY for any Business Central data you require
3. Once you have the data, prepare the journal entry details
4. Send the entry details to GLPOSTER for creation
5. Ask REVIEWER to validate the result
To delegate, emit a json block with the target Agent ID in "to" and the request in "payload".
You do not need to spell out the JSON syntax in every instruction — most models emit the delegation block automatically once they know the available Agent IDs and their roles. Optionally, including one worked example in the instructions makes delegation more reliable, for example:
{ "to": "DATAQUERY", "payload": { "task": "Get the default GL accounts for vendor V10000" } }
Step 4: Set the Workload Type
Configure the workload type with:
- Initial Worker set to your coordinator agent
- Operation set appropriately (PayloadBased or DataBased)
- Posting settings configured if document creation is involved
Cooperation Patterns
Hub and Spoke
One coordinator agent delegates to multiple specialists:
┌─── Data Agent
│
Coordinator ─── Entry Agent
│
└─── Review Agent
When to use: Most common pattern. The coordinator understands the overall task and delegates specific operations.
Pipeline
Agents process work in sequence, each passing results to the next:
Analyzer → Categorizer → Entry Creator → Validator
When to use: When each step transforms or enriches data for the next step. Each agent adds value to the result.
Parallel Delegation
The coordinator sends requests to multiple agents simultaneously:
┌─── Customer Lookup
Coordinator ──┤
└─── Vendor Lookup
(Results return to Coordinator)
When to use: When the coordinator needs data from multiple sources before making a decision.
Message Handling
Consecutive Messages
When the orchestration engine detects multiple consecutive messages from the same requestor to the same target worker, it combines them into a single message. This prevents unnecessary AI calls and maintains context.
Worker Persistence
Workers remain active within a processing session. If a coordinator sends multiple requests to the same agent during one workload, the agent retains its conversation history between calls. This means:
- The data lookup agent remembers previous queries
- The entry creator agent maintains context about previously created entries
- Each agent's conversation builds naturally over the workload
Result Formatting
When results are returned from one agent to another, they are formatted using the ReplyFrom system prompt:
Reply from [AgentID]: [result content]
This helps the receiving agent understand where the information came from.
Example: Invoice Processing Workflow
Agents
| Agent ID | Type | Title |
|---|---|---|
| INVOICEMGR | AI | Invoice Processing Manager |
| VENDORLOOKUP | AI (with tools) | Vendor Data Lookup |
| GLCREATOR | EntryAI | GL Journal Creator |
INVOICEMGR Instructions
You manage invoice processing. For each invoice:
1. Extract vendor name, invoice number, date, and amount
2. Ask VENDORLOOKUP to find the vendor in our system and get their default GL accounts
3. Using the vendor data, prepare the journal entry:
- Debit the expense account
- Credit accounts payable
4. Send the entry details to GLCREATOR
5. Report the final result
VENDORLOOKUP Instructions
You look up vendor information in Business Central.
When asked about a vendor, use your tools to:
1. Search the Vendor table by name
2. Return the vendor number, name, and default payment terms
3. If the vendor is not found, report "VENDOR NOT FOUND"
GLCREATOR Instructions
You create general journal entries.
When you receive entry details:
1. Create the journal line with the provided accounts and amounts
2. Verify debits equal credits
3. Report the document number of the created entry
Processing Flow
- User creates a workload with invoice details
- INVOICEMGR receives the workload and extracts invoice data
- INVOICEMGR asks VENDORLOOKUP: "Find vendor Contoso Ltd"
- VENDORLOOKUP queries BC and returns: "Vendor V10000, Net 30 terms"
- INVOICEMGR prepares entry details and sends to GLCREATOR
- GLCREATOR creates the journal line and reports: "Created entry DOC-001"
- INVOICEMGR provides final summary: "Invoice processed, journal DOC-001 created"
Debugging Cooperation
Process Chat
Use the Debug Run action on a workload to open the Process Chat page, which shows real-time agent communication:
- Each message shows which agent sent it
- Tool calls are visible in the activity log
- You can see the full conversation flow between agents
View AI Stack
During processing, use View AI Stack in the Process Chat to see all currently active workers and their state.
Activity History
After processing, use View Last Run to review the complete activity log, including all inter-agent messages.
Tips and Best Practices
- Start with two agents (coordinator + specialist) before building larger chains
- Give each agent a clear, non-overlapping responsibility
- Use descriptive Agent IDs so the
tofield in delegation blocks is clear - Test agent cooperation with simple tasks before running complex workloads
- Review the process activity log to understand how agents are communicating
- If cooperation seems to loop, check that agents are not sending tasks back and forth without resolving
- The more specific your coordinator's instructions about when to delegate, the better the workflow will function
- Consider token costs — each inter-agent message involves AI calls for both sender and receiver