Structured Outputs
New Features
- Removed Instructor: Agency Swarm no longer relies on the instructor. If a Pydantic model is passed, the
response_formatparameter will now use OpenAI's implementation. The tool creation process remains unchanged. strictmode: You can now enable "strict" mode when creating tools in both theBaseToolclass and in your schema usingToolFactory. See Structured Outputs for more details.response_format: json_schema: The response format can now be set tojson_schemain both theAgentclass and completion methods.get_completion_parse: This new method allows you to pass a Pydantic model directly to theresponse_formatmethod, which will then return a parsed model. If the request is refused, aRefusalErrorfromagency_swarm.util.errorswill be raised.- Verbose mode for
get_completion: By setting theverboseparameter totrue, you can view intermediary messages, similar to Crew AI. - Improved error handling for existing threads: The system will now automatically cancel any active runs within a thread and continue the conversation.
Bug Fixes
- Fixed shared state initialization when testing tools separately. #165
- Improved common error handling like connection errors and rate limits in Thread.
⚠️ Breaking Changes in BaseTool Class
-
The
one_call_at_a_timeparameter inBaseToolis now located underToolConfig. -
shared_stateandcaller_agentare now private attributes.from agency_swarm.tools import BaseTool class Action1(BaseTool): input: str = Field(...) # one_call_at_a_time = True # before class ToolConfig: one_call_at_a_time = True # now strict = True # new def run(self): # self.shared_state.get('param') # before self._shared_state.get('param') # now
Full Changelog: GitHub Compare v0.2.6...v0.2.7