View Python Example on Github This example demonstrates a complete Xpander coding agent implementation with AgentOps instrumentation using callback handlers. The example shows how to build a single-file agent that combines the MyAgent class and XpanderEventListener for comprehensive monitoring.

Key Features

  • Single-file implementation combining agent logic and event handling
  • Callback-based instrumentation using XpanderEventListener
  • Async tool execution with proper error handling and logging
  • AgentOps integration with custom trace names and tags

Running the Example

  1. Set up your environment variables in a .env file or export them:
    AGENTOPS_API_KEY=your_agentops_api_key
    XPANDER_API_KEY=your_xpander_api_key  
    XPANDER_AGENT_ID=your_agent_id
    OPENAI_API_KEY=your_openai_api_key
    
  2. Run the agent:
    python examples/xpander/coding_agent.py
    
The agent will start an interactive session where you can ask coding questions and see the results tracked in your AgentOps dashboard.