Skip to content

New Integration: AG2 multi-agent framework #3107

@faridun-ag2

Description

@faridun-ag2

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"])

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3new integrationDiscuss the creation of a new integration in Core

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions