Skip to content

refactor: implement _loop_response_model to manage response_model dur…#5613

Open
lorenzejay wants to merge 3 commits intomainfrom
lorenze/fix/structured-outputs
Open

refactor: implement _loop_response_model to manage response_model dur…#5613
lorenzejay wants to merge 3 commits intomainfrom
lorenze/fix/structured-outputs

Conversation

@lorenzejay
Copy link
Copy Markdown
Collaborator

@lorenzejay lorenzejay commented Apr 24, 2026

…ing tool loops

This change introduces the _loop_response_model method in BaseAgentExecutor to conditionally return the response_model based on the presence of tools. The CrewAgentExecutor and AgentExecutor classes have been updated to utilize this new method, ensuring that the response_model is not sent to the LLM during tool loops, which prevents issues with structured-output schemas. Additionally, tests have been added to verify the correct behavior of this implementation.


Note

Medium Risk
Changes the parameters sent to LLM providers during tool-execution loops, which can affect structured-output behavior across multiple providers and execution paths. Test cassette updates reduce risk but regressions could still alter agent outputs or tool-calling flows.

Overview
Prevents response_model from being forwarded to the LLM when an executor has tools, via a new BaseAgentExecutor._loop_response_model() helper, to avoid providers returning schema-constrained placeholder JSON instead of making tool calls.

Updates all in-loop LLM call sites in CrewAgentExecutor (sync/async, ReAct and native tools) and experimental.AgentExecutor to route response_model through this helper, and adds regression tests enforcing the behavior.

Extends VCR header filtering (e.g., x-amz-security-token, x-crewai-organization-id) and refreshes Anthropic/Bedrock structured-output-with-tools cassettes and test models to match the new request/response flow.

Reviewed by Cursor Bugbot for commit e77d1c0. Bugbot is set up for automated code reviews on this repo. Configure here.

…ing tool loops

This change introduces the _loop_response_model method in BaseAgentExecutor to conditionally return the response_model based on the presence of tools. The CrewAgentExecutor and AgentExecutor classes have been updated to utilize this new method, ensuring that the response_model is not sent to the LLM during tool loops, which prevents issues with structured-output schemas. Additionally, tests have been added to verify the correct behavior of this implementation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant