Agency Swarm v1.x represents a complete architectural rewrite built on the OpenAI Agents SDK, introducing significant API changes and powerful new capabilities.
v1.x is currently in beta preview. v0.x remains the recommended production version until we reach feature parity and mark v1.0 as generally available.

Installation

Agency Swarm v1.x (Beta)

You can install Agency Swarm v1.x beta from PyPI:
pip install -U "agency-swarm>=1.0.0-beta.1"
If you encounter any issues, please create an issue in GitHub using the v1.x beta label. This will help us actively monitor and track errors, and continue to improve the library’s performance.

Agency Swarm v0.x (Production)

Agency Swarm v0.x is still the recommended version for production use, offering stable, battle-tested functionality. If you need to continue using the latest Agency Swarm v0.x, you can install it with:
pip install "agency-swarm<1.0.0"
v0.x documentation is available at the current documentation site until v1.0 reaches general availability.

New Features & Capabilities

Responses API Integration & New Models

  • Web Search & Computer Use: Native support for OpenAI’s Search and Computer Use capabilities through the Responses API
  • Latest Models: Full support for o3, o4-mini, and future OpenAI models via Responses API
  • Third-Party Model Providers: Use any model provider that adheres to the Chat Completions API standard
  • Direct Control: No more black-box Assistants API - Agency Swarm now has direct control over threads and runs through the Agents SDK

Architectural Improvements

  • Orchestrator Pattern on New Foundation: Agency Swarm’s proven orchestrator-workers pattern now runs on the OpenAI Agents SDK foundation
  • Async-first Architecture: Native async execution for better performance
  • Full Conversation Persistence: Complete conversation history management (not just thread IDs) for robust session handling
  • Enhanced Communication: Agents communicate through defined communication_flows pathways for coordinated multi-agent execution

Enhanced Developer Experience

  • Structured Outputs: Native Pydantic model support for agent outputs via output_type
  • Modern Tool System: @function_tool decorator replaces BaseTool classes for cleaner tool definitions
  • Better Validation: output_guardrails and input_guardrails replace the old response_validator system
  • Real-time Streaming: Improved streaming capabilities with async response handling

Why These Changes? (Architectural Context)

The migration from v0.x to v1.x represents a fundamental shift in how Agency Swarm operates:

Execution Core

  • v0.x: Used OpenAI Assistants API runs directly
  • v1.x: Uses agents.Runner from OpenAI Agents SDK for more control

State Management

  • v0.x: Relied on Assistant/Thread objects managed by OpenAI
  • v1.x: Uses ThreadManager and ConversationThread managed via RunHooks and shared MasterContext

Agent Definition

  • v0.x: Custom Agent class with Assistants API integration
  • v1.x: agency_swarm.Agent extends agents.Agent, incorporating tools, subagent registration, and file handling

Conversation History Persistence

This is an important architectural difference between versions:
  • v0.x (Assistants API): Required thread callbacks for production to persist OpenAI Assistant/Thread IDs. OpenAI managed conversation history server-side.
  • v1.x (Agents SDK): Required thread callbacks for production to persist complete conversation histories locally. You manage the full conversation state.
Key Changes:
  • Callback Structure: threads_callbacks dict → separate load_threads_callback and save_threads_callback parameters
  • Data Format: Thread IDs only → Complete conversation histories
  • Callback Signatures: Unchanged (both use no-parameter callbacks with closure)
# v0.x
def load_threads(chat_id):
    return load_threads_from_db(chat_id)  # Returns thread IDs

def save_threads(new_threads):
    save_threads_to_db(new_threads)  # Saves thread IDs

agency = Agency(
    agents,
    threads_callbacks={
        'load': lambda: load_threads(chat_id),
        'save': lambda new_threads: save_threads(new_threads)
    }
)

# v1.x
def load_threads(chat_id):
    # Load complete conversation history instead of just thread IDs
    return load_conversation_history(chat_id)

def save_threads(new_threads):
    # Save complete conversation histories
    save_conversation_history(new_threads)

agency = Agency(
    entry_agent,
    load_threads_callback=lambda: load_threads(chat_id),
    save_threads_callback=lambda new_threads: save_threads(new_threads)
)
Production Deployment: Thread callbacks are required in both v0.x and v1.x for production deployment to persist conversation state. The callback signatures remain the same, but the data format changes.

Breaking Changes

These changes will cause your v0.x code to crash in v1.x and require immediate attention:
  1. response_format parameter: Now throws NotImplementedError - must migrate to Agent-level output_type
  2. response_validator parameter: Completely removed from Agent class - must migrate to output_guardrails
  3. Thread callbacks data format: Now stores complete conversation histories instead of thread IDs
  4. Async-only methods: get_response() and get_response_stream() are async and required await

Quick-Migration Checklist

For a concise overview, consult the table below. See the Step-by-Step Migration section for full details.
What you used in v0.xStill works?Action required in v1.x
get_completion() (sync)Yes – kept for nowNothing • Recommended: rename to await get_response()
get_completion_stream()NoReplace with await get_response_stream() (async only)
response_format={...}NoDelete this arg and set output_type=PydanticModel on the Agent
response_validator=...NoMove your logic to output_guardrails / input_guardrails
threads_callbacks={...} (persistence)NoSplit into load_threads_callback & save_threads_callback and store full histories
1

Upgrade your dependencies

See the Installation section above for package installation commands.
2

Replace response_format

agency.get_completion("Hi", response_format={"type": "json_schema", ...})
3

Move response_validator logic

agent = Agent(response_validator=my_check, ...)
4

Update streaming & async calls

result = agency.get_completion_stream("Hello")

Step-by-Step Migration

1

Update Dependencies

Update your requirements.txt or pyproject.toml using the installation commands in the Installation section above.
2

Update Agency Constructor (Persistence)

Update how you pass persistence callbacks to the Agency constructor. See the Conversation History Persistence section above for detailed architectural context and code examples.What Changed:
  • Parameter structure: threads_callbacks dict → separate load_threads_callback and save_threads_callback parameters
  • Data format stored: Thread IDs → Complete conversation histories
  • Your callback functions remain identical
3

Update Agency Initialization

agency = Agency(
    entry_point_agent,  # Positional argument
    communication_flows=[(agent1, agent2)],
    load_threads_callback=load_threads_callback,
    save_threads_callback=save_threads_callback
)
4

Update Agent Definitions

Model Settings:
# v0.x
agent = Agent(temperature=0.7, top_p=1.0, max_completion_tokens=1000)

# v1.x (recommended)
agent = Agent(
    model="gpt-4o",
    model_settings=ModelSettings(
        temperature=0.7,
        top_p=1.0,
        max_completion_tokens=1000,
    )
)
Structured Outputs - See Breaking Changes for details:
# v0.x - This will CRASH in v1.x
completion = agency.get_completion(
    message="...",
    response_format={"type": "json_schema", "json_schema": {...}}
)
# NotImplementedError: response_format parameter is no longer supported

# v1.x - Required migration
class TaskOutput(BaseModel):
    task_name: str
    status: str

agent = Agent(output_type=TaskOutput, ...)
result = await agency.get_response(message="...", recipient_agent="AgentName")
5

Convert Tools

v0.x Tool:
class MyTool(BaseTool):
    arg1: str = Field(..., description="Description")

    def run(self):
        return f"Result: {self.arg1}"
v1.x Tool (using @function_tool decorator):
@function_tool
def my_tool(arg1: str) -> str:
    """Tool description."""
    return f"Result: {arg1}"

# Optional: Tool with context access (if you need shared state)
@function_tool
async def my_tool_with_context(ctx: RunContextWrapper[Any], arg1: str) -> str:
    """Tool with context access."""
    # Access: ctx.context.agents, ctx.context.thread_manager
    return f"Result: {arg1}"
6

Update Interaction Calls (Optional)

result = agency.get_completion("Hello", recipient_agent="Agent1")
7

Update response validation

class TestAgent(Agent):
    def __init__(self):
        super().__init__(
            name="TestAgent",
            description="..."
        )

    @override
    def response_validator(self, message):
        # User-defined validation function
        if self.check_errors(message):
            raise ValueError("Error processing message")

        # Returns original message if no errors are raised
        return message
What Changed:
  • Breaking Change: response_validator parameter is completely removed from Agent class - See Breaking Changes for details
  • Validation is now passed using output_guardrails and input_guardrails
  • Retry validation logic is no longer incorporated within the library. Users have to implement their own retry logic by catching respective errors.

Parameter Reference Tables

Changes to Agency Class

v0.x Methodv1.x Method (Recommended)Status
agency_chart parameterPositional arguments for entry points + communication_flows parameterDeprecated but works
threads_callbacksload_threads_callback + save_threads_callbackBreaking change
get_completion()get_response() (async)Backward compatible
get_completion_stream()get_response_stream() (async)NotImplementedError
Agency Structure Definition:
  • v0.x: Used agency_chart parameter where standalone agents were entry points and lists defined communication paths
  • v1.x: Entry points passed as positional arguments; communication flows via communication_flows parameter

Changes to Agent Class

v0.x Parameterv1.x ParameterNotes
Individual model params (temperature, top_p, etc.)model_settings=ModelSettings(...)Individual params deprecated but still work
response_validatoroutput_guardrails, input_guardrailsCompletely removed
examplesPrepended to instructionsAutomatic migration with warning
id, tool_resourcesRemovedUse files_folder and upload_file instead

Changes to Tools

v0.xv1.x
BaseTool (Pydantic models) with run() method@function_tool decorator (recommended) or direct FunctionTool instantiation (advanced)
BaseTool is temporarily retained for backward compatibility during migration.

Changes to Communication

v0.x Patternv1.x Pattern
Various SendMessage variantsAutomatic send_message tool (request-response)
Manual handoffsSDK handoffs parameter on agents (experimental)
SendMessage Variants: Several v0.x SendMessage variants (SendMessageQuick, SendMessageAsyncThreading, SendMessageSwarm) are temporarily unavailable in v1.x until we reach feature parity.

Structured Outputs

v0.x Methodv1.x Method
response_format={"type": "json_schema", ...}output_type=PydanticModel on Agent
get_completion(response_format=...)Agent-level output_type configuration

Complete Before/After Example

from agency_swarm import Agency, Agent, BaseTool
from pydantic import Field

# Tool Definition
class ProcessingTool(BaseTool):
    """Processes data."""
    input_data: str = Field(..., description="Data to process")

    def run(self):
        return f"Processed: {self.input_data}"

# Agent with validation
class AnalysisAgent(Agent):
    def __init__(self):
        super().__init__(
            name="AnalysisAgent",
            description="Analyzes data",
            instructions="Process and analyze input data.",
            tools=[ProcessingTool],
            temperature=0.7,
            max_completion_tokens=1000
        )

    def response_validator(self, message):
        if "error" in message.lower():
            raise ValueError("Invalid response detected")
        return message

# Persistence functions
def load_threads(chat_id):
    return load_threads_from_db(chat_id)  # Returns thread IDs

def save_threads(new_threads):
    save_threads_to_db(new_threads)  # Saves thread IDs

# Agency Setup
analyst = AnalysisAgent()
reporter = Agent(
    name="Reporter",
    description="Creates reports",
    instructions="Generate reports from analysis.",
    temperature=0.3
)

agency = Agency(
    agency_chart=[
        analyst,  # Entry point
        [analyst, reporter]  # Communication flow
    ],
    threads_callbacks={
        'load': lambda: load_threads(chat_id),
        'save': lambda threads: save_threads(threads)
    },
    shared_instructions="Be helpful and accurate."
)

# Usage
result = agency.get_completion(
    message="Analyze this data: sample_data",
    response_format={"type": "json_schema", "json_schema": {...}},
    recipient_agent="AnalysisAgent"
)
print(result)

Backward Compatibility

Agency Swarm v1.x maintains backward compatibility where possible:
  • agency_chart: Still works but deprecated; migrate to positional arguments and communication_flows
  • get_completion(): Maintained as a synchronous wrapper; deprecated in favor of async get_response()
  • get_completion_stream(): Not supported - raises NotImplementedError; use async get_response_stream()
  • Agent Parameters: Individual model parameters still work but deprecated; use model_settings
  • BaseTool: Temporarily retained for gradual migration to @function_tool
Deprecated features will be removed in a future major version. We recommend migrating to the new patterns for the best experience.

Resources

Available Examples

The /examples directory contains comprehensive examples demonstrating v1.x features and migration patterns:
  • two_agent_conversation.py - Multi-agent communication with automatic thread isolation
  • streaming.py - Real-time response streaming with proper event handling
  • file_handling.py - File processing and vision analysis using OpenAI’s built-in capabilities
  • file_search.py - Vector store creation and FileSearch tool usage with automatic indexing
  • file_search_persistence.py - Hosted tool output preservation across conversation turns
  • multi_agent_workflow.py - Complex multi-agent collaboration with validation
  • response_validation.py - Input and output guardrails implementation with tripwire triggers
  • custom_persistence.py - Thread isolation and persistence across application restarts
  • chat_completion_provider.py - Custom OpenAI Chat Completions model provider usage
Each example includes detailed comments explaining v1.x concepts and can be run independently with proper environment setup.

Additional Resources