AutoGen Integration

Trace AutoGen multi-agent conversations. Each initiate_chat() becomes a trace, and individual reply turns are captured as spans.

Installation

pip install twosignal[autogen]

Usage

from twosignal import TwoSignal
from twosignal.wrappers.autogen import wrap_autogen
import autogen

ts = TwoSignal()

assistant = autogen.AssistantAgent(
    "assistant",
    llm_config={"model": "gpt-4o"},
)

user = autogen.UserProxyAgent(
    "user",
    human_input_mode="NEVER",
    max_consecutive_auto_reply=3,
)

# wrap both agents
wrap_autogen(assistant)
wrap_autogen(user)

# the conversation is traced end-to-end
user.initiate_chat(assistant, message="Write a hello world in Python")

What Gets Traced

EventSpan TypeDetails
initiate_chatAGENTInitiator, recipient, message, conversation summary
generate_replyAGENTAgent name, input message, reply output

Group Chat

manager = autogen.GroupChatManager(
    groupchat=autogen.GroupChat(
        agents=[assistant, coder, reviewer],
        messages=[],
    ),
)

wrap_autogen(manager)
user.initiate_chat(manager, message="Build a REST API")

How It Works

wrap_autogen(agent) patches initiate_chat() and generate_reply() on each agent. Wrap all agents in a conversation to capture every turn. The initiating chat becomes the top-level span, with reply turns nested inside.

Have questions? Join our community!

Connect with other developers and the 2Signal team.

Join Discord