Multi-Agent Example
How to track events from multiple different agents
View Notebook on Github
Multi-Agent Support
This is an example implementation of tracking events from two separate agents
First let’s install the required packages
Then import them
Next, we’ll set our API keys. There are several ways to do this, the code below is just the most foolproof way for the purposes of this notebook. It accounts for both users who use environment variables and those who just want to set the API Key here in this notebook.
-
Create an environment variable in a .env file or other method. By default, the AgentOps
init()
function will look for an environment variable namedAGENTOPS_API_KEY
. Or… -
Replace
<your_agentops_key>
below and pass in the optionalapi_key
parameter to the AgentOpsinit(api_key=...)
function. Remember not to commit your API key to a public repo!
Now lets create a few agents!
Now we have our agents and we tagged them with the @track_agent
decorator. Any LLM calls that go through this class will now be tagged as agent calls in AgentOps.
Let’s use these agents!
Perfect! It generated the code as expected, and in the DEBUG logs, you can see that the calls were made by agents named “engineer” and “qa”!
Let’s verify one more thing! If we make an LLM call outside of the context of a tracked agent, we want to make sure it gets assigned to the Default Agent.
You’ll notice that we didn’t log an agent name, so the AgentOps backend will assign it to the Default Agent for the session!