# AutoGen ATI Example

This example demonstrates how to instrument AutoGen agents with IOcane ATI.

## Prerequisites

- Python 3.10+
- An IOcane account (run `iocane connect` to setup your environment)

## Setup

1.  **Install Dependencies**
    ```bash
    pip install pyautogen
    pip install opentelemetry-sdk opentelemetry-exporter-otlp
    # Install ATI SDK and Integration
    pip install ati-sdk ati-integrations-autogen
    ```

2.  **Configure Environment**
    Get your API Key and Environment ID from `.env.iocane` (generated by `iocane connect`) or the IOcane Dashboard.

    ```bash
    # Linux/Mac
    export OPENAI_API_KEY="sk-..." 
    export OTEL_SERVICE_NAME="autogen-example"
    export OTEL_EXPORTER_OTLP_ENDPOINT="https://api.iocane.ai/v1/traces"
    export OTEL_EXPORTER_OTLP_HEADERS="x-iocane-key=<YOUR_KEY>,x-ati-env=<YOUR_ENV_ID>"
    ```

## Running the Example

```bash
python simple_agent.py
```

## Expected Output

You should see the chat interaction in the console.
In the IOcane Dashboard:
- **Agent Spans via `on_messages`**: Each time an agent processes/replies to a message, a span is created.
- **Attributes**: `ati.span.type=agent`, `ati.agent.id=<agent_name>`.
