Connecting Multiple Agents (Workflows)
Why is Connecting Agents in Workflows Useful?
Connecting Agents allows you to evaluate the overall combined product of the multiple agents, instead of just the individual agents in a vacuum. This means you can evaluate the cumulative product of all agents, or debug an entire workflow, instead of having to look at just isolated pieces of the workflow individually.
A workflow is just a sequence of two or more AI agents working together to accomplish a complex task. Workflow structures can vary, but here are a couple simple examples of what a workflow may look like:
- Two or more agents work sequentially, where the output of one agent becomes the input for the next agent. For example: one agent extracts data from a document, a second agent summarizes it, and a third agent translates it into another language.
- Two or more agents work in parallel and their results are combined at the end. For example: two agents are given the same meeting transcript. One agent is responsible for generating a summary of the meeting and the other is responsible for extracting todo items from the transcript.
To learn more and see additional examples, we recommend checking out Anthropic's guide on building effective agents.
Setting up Workflows
You can use agent metadata to add the key value pairs you'd like to connect agents as workflows.
You can ask your AI assistant to create a workflow for you, like this:
I need to add workflow tracking to the following AnotherAI agents so I can connect
them together as a workflow and monitor them as a group.
I have these agents that work together:
- anotherai/agent/your-agent-name-1
- anotherai/agent/your-agent-name-2
- anotherai/agent/your-agent-name-3
Please update the code for all these agents to include workflow tracking metadata:
1. A "trace_id" that uses a UUID (specifically uuid.uuid7() for Python or uuidv7() for TypeScript)
2. A "workflow_name" that is [your-workflow-name]
Here's what I need:
- Generate the trace_id once at the beginning when I start the workflow and pass the same trace_id
to all three agents during that workflow execution
- Set the workflow_name to "[your-workflow-name]" for all agents in this workflow type
- Add both of these to the metadata section of all my agent calls alongside the existing agent_id
The goal is so that when I run these agents together as part of the same workflow, they all share
the same trace_id and workflow_name, which will let me see them grouped
together in AnotherAI's monitoring views.Monitoring Workflows
Once you have your agents running with shared metadata, you can create custom views to monitor and analyze the workflows. Here are some examples of views that could be useful:
General workflow monitoring
To see all completions across all agents in the workflow.
You can ask your AI assistant to create a custom view, like this:
Show me all the completions for the workflow 'meeting-analysis', ordered by trace_id, created_at
so I can see each workflow instance with its agents in chronological order.
Workflow performance analytics
See daily cost for a specific workflow across all agents involved.
Create a graph showing daily cost for workflow_name='meeting-analysis'
How is this guide?