> ## Documentation Index
> Fetch the complete documentation index at: https://developers.agentx.so/llms.txt
> Use this file to discover all available pages before exploring further.

# AutoGen / AG2

> Evaluate a conversation between AutoGen (or AG2) ConversableAgents

Install:

```bash theme={null}
pip install agentx-python pyautogen
```

<Note>
  AG2 is the actively-maintained fork of AutoGen. If you're on AG2, install `ag2` instead of `pyautogen`; the `autogen` import name and API shown below are the same either way.
</Note>

## Usage

```python theme={null}
from agentx import AgentX
from autogen import ConversableAgent

client = AgentX.from_env()

assistant = ConversableAgent(
    name="assistant",
    system_message="You are a helpful customer support agent.",
    llm_config={"config_list": [{"model": "gpt-4o-mini"}]},
)
user_proxy = ConversableAgent(
    name="user_proxy",
    human_input_mode="NEVER",
    max_consecutive_auto_reply=1,
    llm_config=False,
)

def autogen_agent(case):
    chat_result = user_proxy.initiate_chat(
        assistant,
        message=case.query,
        max_turns=1,
    )
    output = chat_result.chat_history[-1]["content"]
    return {"output": output, "metadata": {"model": "gpt-4o-mini"}}

run_context = (
    client.evaluations
    .run(dataset_id="...", subject={"kind": "custom_agent", "displayName": "Support Assistant", "framework": "autogen"})
    .execute(autogen_agent)
    .finalize()
)
print(f"Average rating: {run_context.average_rating:.2f}")
```

Returning `metadata: {"model": ...}` records which model produced each response, powering the Sovereignty & Portability breakdown in the report. For a full Execution Timeline, use the [AutoGen tracing integration](/sdk/integrations/autogen) (steps named by the speaking agent, tool calls captured), or wrap calls in [`tracer.trace(..., sync=True)`](/sdk/tracing#linking-a-trace-to-an-evaluation-result) yourself, the same way the [OpenAI example](/sdk/evaluations/examples/openai) does.

A complete working example, including a multi-agent `GroupChat` variant with a researcher/writer split, is available as [`autogen_eval.py`](https://github.com/AgentX-ai/AgentX-Python/blob/main/examples/evaluations/autogen_eval.py) in the AgentX-Python repository.
