Summary
Closes #3107
Add an AG2Agent Haystack component that wraps AG2 (formerly AutoGen) multi-agent conversations, allowing Haystack pipelines to leverage AG2's multi-agent orchestration.
What's included
AG2Agent — a Haystack @component wrapping AG2 multi-agent conversations
- Full serialization support (
to_dict / from_dict)
- Configurable: model, system message, API type, code execution, auto-reply limits
- Unit tests with mocked dependencies
- README with standalone and pipeline usage examples
How it works
On each run(), the component creates an AG2 AssistantAgent and UserProxyAgent, executes the conversation via user_proxy.run(assistant, message=query).process(), and returns the final reply along with the full message history.
from haystack import Pipeline
from haystack_integrations.components.agents.ag2 import AG2Agent
pipeline = Pipeline()
pipeline.add_component("agent", AG2Agent(model="gpt-4o-mini"))
result = pipeline.run({"agent": {"query": "Explain RAG."}})
print(result["agent"]["reply"])
Summary
Closes #3107
Add an
AG2AgentHaystack component that wraps AG2 (formerly AutoGen) multi-agent conversations, allowing Haystack pipelines to leverage AG2's multi-agent orchestration.What's included
AG2Agent— a Haystack@componentwrapping AG2 multi-agent conversationsto_dict/from_dict)How it works
On each
run(), the component creates an AG2AssistantAgentandUserProxyAgent, executes the conversation viauser_proxy.run(assistant, message=query).process(), and returns the final reply along with the full message history.