Skip to content

Conversation

@Arindam200
Copy link
Contributor

Description

Enhanced structured output handling for tool calls in LiteLLMModel.

  • Updated response parsing to correctly detect and process tool_calls within LiteLLM responses.
  • If no tool_calls are present, the model now parses the message.content directly.
  • Added tests to validate behavior for both tool-call and non-tool-call cases.

This ensures structured outputs are consistently parsed across all providers, preventing missing or malformed data in tool responses.

Related Issues

Fixes #1005

Documentation PR

N/A

Type of Change

Bug fix

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

  • I ran hatch run prepare
  • Added and verified unit tests for tool-call and non-tool-call scenarios.

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@Arindam200 Arindam200 deployed to manual-approval October 24, 2025 14:02 — with GitHub Actions Active
@codecov
Copy link

codecov bot commented Oct 28, 2025

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/strands/models/litellm.py 0.00% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@dbschmigelski
Copy link
Member

Hi, approving, but noting that we recently launched a new mechanism for structured_output in #943 which should be used instead (when it is released)

@Arindam200
Copy link
Contributor Author

Thanks,

Do I need to change anything here?

@dbschmigelski
Copy link
Member

Hi, approving, but noting that we recently launched a new mechanism for structured_output in #943 which should be used instead (when it is released)

Nope nothing to change, your change here is still useful and will make the, soon-to-be, deprecated approach more robust.

@Arindam200
Copy link
Contributor Author

Hi, approving, but noting that we recently launched a new mechanism for structured_output in #943 which should be used instead (when it is released)

Nope nothing to change, your change here is still useful and will make the, soon-to-be, deprecated approach more robust.

Okay, Thanks for the Opportunity!

@Unshure Unshure merged commit 104ecb5 into strands-agents:main Oct 28, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] : structured_output hard fails when LiteLLM returns JSON without tool_calls finish_reason

3 participants