Skip to content

Structured Outputs

Compare
Choose a tag to compare
@VRSEN VRSEN released this 20 Aug 17:07
· 48 commits to main since this release

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 the BaseTool class and in your schema using ToolFactory. See Structured Outputs for more details.
  • response_format: json_schema: The response format can now be set to json_schema in both the Agent class and completion methods.
  • get_completion_parse: This new method allows you to pass a Pydantic model directly to the response_format method, which will then return a parsed model. If the request is refused, a RefusalError from agency_swarm.util.errors will be raised.
  • Verbose mode for get_completion: By setting the verbose parameter to true, 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 in BaseTool is now located under ToolConfig.

  • shared_state and caller_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