Structured Outputs
New Features
- Removed Instructor: Agency Swarm no longer relies on the instructor. If a Pydantic model is passed, the
response_format
parameter will now use OpenAI's implementation. The tool creation process remains unchanged. strict
mode: You can now enable "strict" mode when creating tools in both theBaseTool
class and in your schema usingToolFactory
. See Structured Outputs for more details.response_format: json_schema
: The response format can now be set tojson_schema
in both theAgent
class and completion methods.get_completion_parse
: This new method allows you to pass a Pydantic model directly to theresponse_format
method, which will then return a parsed model. If the request is refused, aRefusalError
fromagency_swarm.util.errors
will be raised.- Verbose mode for
get_completion
: By setting theverbose
parameter 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_time
parameter inBaseTool
is now located underToolConfig
. -
shared_state
andcaller_agent
are 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