@agent decorator to associate operations with specific agents.
Using the Agent Decorator
For structured tracking in complex applications, you can use the@agent decorator to explicitly identify different agents in your system:
Basic Agent Tracking (Simple Applications)
For simple applications, AgentOps will automatically track your LLM calls without additional configuration:Multi-Agent Systems
For complex multi-agent systems, you can organize multiple agents within a single trace:Agent Communication and Coordination
You can track complex agent interactions and communication patterns:Dashboard Visualization
All operations are automatically associated with the agent that originated them. Agents are given a name which is what you will see in the dashboard.
Operations are labeled with the name of the Agent that originated them
Best Practices
-
Start Simple: For most applications, just using
agentops.init()is sufficient. -
Use Decorators When Needed: Add the
@agentdecorator when you need to clearly distinguish between multiple agents in your system. - Meaningful Names: Choose descriptive names for your agents to make them easier to identify in the dashboard.
-
Organize with Traces: Use the
@tracedecorator to group related agent operations into logical workflows. -
Track Costs: Use the
@tooldecorator with cost parameters to track the expenses associated with agent operations. - Agent Specialization: Create specialized agents for different types of tasks to improve observability and maintainability.
Migration from Session Decorator
If you’re migrating from the legacy@session decorator, replace it with the @trace decorator:
@trace decorator provides the same functionality as the legacy @session decorator but with more flexibility and better integration with the new trace management features.
