Migration Guide: v0.x to v1.x
Guide for migrating from Agency Swarm v0.x to v1.x (OpenAI Agents SDK based)
Agency Swarm v1.x introduces significant changes to the API, including some breaking changes.
This page provides a guide highlighting the most important changes to help you migrate your code from Agency Swarm v0.x to v1.x.
Install Agency Swarm v1.x
Agency Swarm 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.
You can install Agency Swarm v1.x beta from PyPI:
v1.x is currently in beta. We recommend using v0.x for production applications until v1.0 reaches general availability.
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.
Continue using Agency Swarm v0.x features
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:
v0.x documentation is available at the current documentation site until v1.0 reaches general availability.
Critical Breaking Changes
These changes will cause your v0.x code to crash in v1.x and require immediate attention:
response_format
parameter: Now throwsNotImplementedError
- must migrate to Agent-leveloutput_type
response_validator
parameter: Completely removed from Agent class - must migrate tooutput_guardrails
- Thread callbacks data format: Now stores complete conversation histories instead of thread IDs
- Async-only methods:
get_response()
andget_response_stream()
are async and requiredawait
Quick Migration Checklist
Fix Immediate Crashes
Replace response_format
parameter:
Replace response_validator
parameter:
Update Method Names (Optional)
Update Agency Constructor
Update Thread Callbacks (if using persistence)
Why These Changes? (Architectural Context)
The migration from v0.x to v1.x represents a fundamental shift in how Agency Swarm operates. Here’s an overview of the key changes:
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
andConversationThread
managed viaRunHooks
and sharedMasterContext
Agent Definition
- v0.x: Custom
Agent
class with Assistants API integration - v1.x:
agency_swarm.Agent
extendsagents.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 → separateload_threads_callback
andsave_threads_callback
parameters - Data Format: Thread IDs only → Complete conversation histories
- Callback Signatures: Unchanged (both use no-parameter callbacks with closure)
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.
Parameter Reference Tables
Changes to Agency Class
The Agency
class constructor has been redesigned for clarity:
v0.x Method | v1.x Method (Recommended) |
---|---|
agency_chart parameter | Positional arguments for entry points + communication_flows parameter |
threads_callbacks | load_threads_callback + save_threads_callback |
get_completion() | get_response() (async) |
get_completion_stream() | get_response_stream() (async) |
Agency Structure Definition:
- v0.x Method: Used
agency_chart
parameter where standalone agents were entry points and lists defined communication paths - v1.x Method:
- Entry Points: Pass as positional arguments:
Agency(entry_point_agent1, entry_point_agent2, ...)
- Communication Flows: Use
communication_flows
parameter:communication_flows=[(sender, receiver)]
- Entry Points: Pass as positional arguments:
Backward Compatibility: The agency_chart
parameter still works but is deprecated and will trigger DeprecationWarning
.
Changes to Agent Class
v0.x Parameter | v1.x Parameter | Notes |
---|---|---|
Individual model params (temperature , top_p , etc.) | model_settings=ModelSettings(...) | Individual params deprecated but still work |
response_validator | output_guardrails , input_guardrails | Completely removed - shows deprecation warning then ignored |
examples | Prepended to instructions | Automatic migration with warning |
id , tool_resources | Removed | Use files_folder and upload_file instead |
Model Configuration:
- v0.x: Set individual parameters like
temperature=0.7
on Agent or Agency - v1.x: Use
model_settings=ModelSettings(temperature=0.7, model="gpt-4o")
Changes to Tools
Tool Definition:
- v0.x:
BaseTool
(Pydantic models) withrun()
method - v1.x:
@function_tool
decorator (recommended) or directFunctionTool
instantiation (advanced)
BaseTool
is temporarily retained for backward compatibility during migration.
Changes to Communication
v0.x Pattern | v1.x Pattern |
---|---|
Various SendMessage variants | Automatic send_message tool (request-response) |
Manual handoffs | SDK handoffs parameter on agents (experimental) |
Communication Patterns:
- Request-Response: Automatic via
send_message
tool for paths incommunication_flows
- Sequential Handoffs: Use SDK’s
handoffs=[target_agent]
on sending agent
SendMessage Variants: Several v0.x SendMessage variants (SendMessageQuick
, SendMessageAsyncThreading
, SendMessageSwarm
) are temporarily unavailable in v1.x until we reach feature parity. SendMessageSwarm
specifically refers to OpenAI’s handoffs feature (not Agency Swarm), which is experimental in the current SDK version and requires additional testing.
Structured Outputs
v0.x Method | v1.x Method |
---|---|
response_format={"type": "json_schema", ...} | output_type=PydanticModel on Agent |
get_completion(response_format=...) | Agent-level output_type configuration |
Breaking Change: The response_format
parameter in get_completion()
and get_response()
now throws NotImplementedError
instead of being deprecated. You must migrate to Agent-level output_type
configuration before upgrading to v1.x.
Code Examples
Complete Before/After Example
Step-by-Step Migration
Update Dependencies
Change your requirements.txt
or pyproject.toml
:
Update Agency Constructor (Persistence)
Update how you pass persistence callbacks to the Agency constructor:
What Changed:
- Parameter structure:
threads_callbacks
dict → separateload_threads_callback
andsave_threads_callback
parameters - Data format stored: Thread IDs → Complete conversation histories
- Your callback functions remain identical
Update Agency Initialization
New Pattern (Recommended):
Deprecated Pattern (Still Works):
Update Agent Definitions
Model Settings:
Structured Outputs (Breaking Change):
Convert Tools
v0.x Tool:
v1.x Tool (using @function_tool decorator):
Update Interaction Calls (Optional)
v0.x (still works in v1.x with deprecation warning):
v1.x Recommended (async):
Update response validation
v0.x:
v1.x (guardrails):
What Changed:
- Breaking Change:
response_validator
parameter is completely removed from Agent class (not just deprecated) - Validation is now passed as an agent’s input parameter using
output_guardrails
andinput_guardrails
- Retry validation logic is no longer incorporated within the library. Users have to implement their own retry logic by catching respective errors.
Backward Compatibility
Agency Swarm v1.x maintains backward compatibility where possible to ease migration:
agency_chart
: Theagency_chart
parameter in theAgency
constructor still works but is deprecated. It’s recommended to migrate to positional arguments for entry points and thecommunication_flows
keyword argument.get_completion()
: This method is maintained as a synchronous wrapper forget_response()
and works as it did in v0.x. It is deprecated and will be removed in a future version.get_completion_stream()
: This method is not supported in v1.x and will raise aNotImplementedError
. For real-time streaming, you must use the new asynchronousget_response_stream()
method.- Agent Parameters: Individual model parameters on
Agent
(liketemperature
) still work but are deprecated. It is recommended to use themodel_settings
parameter with aModelSettings
object instead. BaseTool
: TheBaseTool
class is temporarily retained to allow for a gradual migration of your custom tools to the new@function_tool
decorator format.
Deprecated features will be removed in a future major version. We recommend migrating to the new patterns for the best experience.
New Features & Capabilities
v1.x introduces several improvements:
- Better Control: More granular execution control via
agents.Runner
- Flexible Persistence: Custom conversation history management
- Clearer Communication: Explicit agent-to-agent messaging patterns
- SDK Integration: Leverages OpenAI Agents SDK features and improvements
- Structured Outputs: Native Pydantic model support for agent outputs
- Improved Performance: Optimized execution and state management
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, tool delegation between UI and Worker agents, and state management across conversation turnsstreaming.py
- Real-time response streaming with proper event handling, filtering text vs tool call data, and demonstration of async streaming capabilitiesfile_handling.py
- File processing and vision analysis using OpenAI’s built-in capabilities for PDF content extraction and image analysis with base64 encodingfile_search.py
- Vector store creation and FileSearch tool usage with automatic indexing, needle-in-haystack search capabilities, and citation-backed responsesfile_search_persistence.py
- Hosted tool output preservation across conversation turns, demonstrating FileSearch result persistence in multi-turn conversationsmulti_agent_workflow.py
- Complex multi-agent collaboration with validation, featuring financial analysis workflow with PortfolioManager, RiskAnalyst, and ReportGenerator agentsresponse_validation.py
- Input and output guardrails implementation with tripwire triggers, exception handling, and retry logic for response validationcustom_persistence.py
- Thread isolation and persistence across application restarts, demonstrating complete conversation history management and callback patternschat_completion_provider.py
- Custom OpenAI Chat Completions model provider usage with different models for different agents and multi-agent task management
Each example includes detailed comments explaining v1.x concepts and can be run independently with proper environment setup.
Additional Resources
- OpenAI Agents SDK Documentation
- Agency Swarm v0.x Documentation (current production docs)
- GitHub Issues - Report v1.x beta issues with the v1.x beta label