Metadata-Version: 2.4
Name: charm-adapter-ag2
Version: 0.1.0
Summary: AG2 multi-agent adapter for the Charm agent framework.
Author: 
License: MIT
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# charm-adapter-ag2

`charm-adapter-ag2` is the AG2 multi-agent adapter for the
[Charm](https://docs.charmos.io) agent framework. AG2 (formerly AutoGen's
multi-agent runtime) orchestrates conversational agents that exchange messages in a
group; this adapter exposes that runtime to Charm as a first-class backend, so a
Charm application can spawn, route, and observe AG2 group chats with the same
typed primitives it uses for any other executor. It is for teams already on Charm
who want AG2's round-robin / selector patterns without writing glue code, and for
AG2 users who want Charm's scheduling, tracing, and policy layer on top.

## Features

- Maps AG2 `GroupChat`, `AssistantAgent`, and `UserProxyAgent` to Charm's
  `Executor`/`Agent` interfaces with full message-flow tracing.
- Supports both `round_robin` and `auto` (LLM-based speaker selection) group-chat
  modes; selection prompts are surfaced through Charm's observability hooks.
- Two-way streaming: AG2 messages flow into Charm streams and Charm control
  events (pause, cancel, redirect) propagate back into the AG2 run.
- Built-in compatibility shim pins against tested AG2 versions so adapter upgrades
  and AG2 upgrades are released in lockstep.
- Async-native; integrates with Charm's `@charm.task` decorators and
  `Runtime.submit(...)` API.

## Installation

```bash
pip install charm-adapter-ag2
# pulls in charm-core and a pinned ag2 release
pip install "charm-adapter-ag2[openai]"   # adds the OpenAI client AG2 uses by default
```

## Quick start

```python
import charm
from charm_adapter_ag2 import AG2GroupChat, AG2Assistant

with charm.Runtime("charm.yaml") as rt:
    planner = AG2Assistant("planner", system_prompt="Break the task into steps.")
    coder   = AG2Assistant("coder",   system_prompt="Write the code.")
    chat = AG2GroupChat([planner, coder], mode="round_robin")

    result = rt.submit(chat, message="Build a fizzbuzz CLI in Python.")
    print(result.final_message)
```

## API

- `AG2Assistant(name, *, system_prompt, llm_config=None)` — a Charm `Agent` backed
  by an AG2 `AssistantAgent`.
- `AG2GroupChat(agents, *, mode="round_robin"|"auto", max_turns=12)` — a Charm
  `Executor` that runs an AG2 group chat.
- `from charm_adapter_ag2 import AG2_VERSION` — the pinned AG2 version string.

## Configuration

`charm.yaml` accepts an `ag2:` section for default `llm_config`, timeout, and
tracing level. Environment variables `AG2_MODEL` and `AG2_API_KEY` are forwarded to
AG2's config when `llm_config` is omitted.

## License

MIT
