Metadata-Version: 2.4
Name: zespan-autogen
Version: 1.2.0
Summary: Zespan observability middleware for Microsoft AutoGen
License-Expression: Apache-2.0
Requires-Python: >=3.10
Requires-Dist: requests>=2.28
Provides-Extra: agentchat
Requires-Dist: autogen-agentchat>=0.4; extra == 'agentchat'
Provides-Extra: dev
Requires-Dist: autogen-agentchat>=0.4; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Provides-Extra: legacy
Requires-Dist: pyautogen>=0.2; extra == 'legacy'
Description-Content-Type: text/markdown

# zespan-autogen

Observability middleware for [Microsoft AutoGen](https://microsoft.github.io/autogen/) via Zespan.

## Install

```bash
# For AutoGen v0.4 (autogen-agentchat)
pip install 'zespan-autogen[agentchat]'

# For AutoGen v0.2 (pyautogen / ag2)
pip install 'zespan-autogen[legacy]'
```

## AutoGen v0.4 — `run_with_tracing()`

Replace `await team.run(task=...)` with `await run_with_tracing(team, task, ...)`:

```python
from zespan_autogen import run_with_tracing
from autogen_agentchat.teams import RoundRobinGroupChat
from autogen_agentchat.conditions import MaxMessageTermination
from autogen_ext.models.openai import OpenAIChatCompletionClient
from autogen_agentchat.agents import AssistantAgent

model = OpenAIChatCompletionClient(model="gpt-4o")
agent = AssistantAgent("assistant", model_client=model)
team = RoundRobinGroupChat([agent], termination_condition=MaxMessageTermination(5))

trace_id = await run_with_tracing(
    team=team,
    task="Analyze the sales data",
    api_key="zsp_your_key",
    project_id="your_project_id",
)
```

## AutoGen v0.4 — `ZespanModelClient` (per-LLM-call tracing)

```python
from zespan_autogen import ZespanModelClient
from autogen_ext.models.openai import OpenAIChatCompletionClient

base = OpenAIChatCompletionClient(model="gpt-4o")
model = ZespanModelClient(base, api_key="zsp_your_key", project_id="proj_id")
agent = AssistantAgent("assistant", model_client=model)
```

## AutoGen v0.2 — `register_hooks()`

```python
from autogen import AssistantAgent, UserProxyAgent
from zespan_autogen import register_hooks

assistant = AssistantAgent("assistant", llm_config={"config_list": [...]})
user = UserProxyAgent("user", human_input_mode="NEVER")

register_hooks(assistant, user, api_key="zsp_your_key", project_id="proj_id")
user.initiate_chat(assistant, message="Research quantum computing trends")
```

## What's captured

- All agent messages (source, content, token counts)
- Tool call requests and execution results
- Agent handoffs and delegation
- Internal reasoning/thought events (thinking models)
- Memory query events
- Raw LLM request/response (via `ZespanModelClient`)
