generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 535
Feat/multiagent structured output #1310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
afarntrog
wants to merge
7
commits into
strands-agents:main
Choose a base branch
from
afarntrog:feat/multiagent-structured-output
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feat/multiagent structured output #1310
afarntrog
wants to merge
7
commits into
strands-agents:main
from
afarntrog:feat/multiagent-structured-output
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Allow for structured output in Graph workflows by allowing for structured output on the graph level and on the agent level as well. This allows for devs to not only get structured output results but also unlocks features such as enabling routing to the correct agent based structured output result of another agent - conditional routing
Prioritize individual agent's _default_structured_output_model when executing in a swarm, falling back to swarm-level model only if the agent doesn't have one. This allows agents with different structured output schemas to work correctly during handoffs.
…d Graph Both Swarm and Graph classes had __call__ implementations that were functionally identical to the base class. Removing them consolidates the synchronous invocation logic in MultiAgentBase, improving maintainability and ensuring consistent kwargs deprecation handling.
…d Graph Both Swarm and Graph classes had __call__ implementations that were functionally identical to the base class. Removing them consolidates the synchronous invocation logic in MultiAgentBase, improving maintainability and ensuring consistent kwargs deprecation handling.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
7 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This pull request introduces support for structured outputs in multi-agent orchestration by allowing a Pydantic model to be specified for structured output from nodes. This enhancement is implemented across the core multi-agent abstractions (
MultiAgentBase), as well as theGraphandSwarmorchestrators. The changes ensure that astructured_output_modelcan be passed through all relevant execution paths, and that agents or nodes can override or inherit this model as needed.Structured Output Model Support
Added an optional
structured_output_modelparameter (of typeType[BaseModel]) to theinvoke_async,stream_async, and__call__methods inMultiAgentBase,Graph, andSwarmclasses, allowing users to specify a Pydantic model for structured node outputs.Updated all internal orchestration and node execution methods to propagate the
structured_output_modelparameter, ensuring that it is available at every level of the orchestration stack.Agent and Node Behavior
These changes make it easier to enforce structured outputs from multi-agent workflows, improving type safety and downstream integration.
Related Issues
#538
#1309
Documentation PR
Will add documentation once we merge (if needed)
Type of Change
New feature
Testing
How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli
Tested locally and added integration tests proving these changes
hatch run prepareChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Example
Here's a complete example you can run to see how we can allow for a graph agent with conditional edge routing: