Skip to content

Conversation

dbschmigelski
Copy link
Member

Description

In LiteLLMModel we currently attempt to perform structured_output using the model's native capabilities. This is checked using the supports_response_schema method.

This has two edge cases which are causing customer failures.

  1. The first obvious one is that if a model does not support structured output we are failing hard. This means that if a customer changes the model id, code that previously worked will now fail with ValueError("Model does not support response_format").

  2. The second is what appears to be a bug in LiteLLM. supports_response_schema does not appear to work with proxies. Looking at their code, they are not passing along proxy information, meaning there is no ability to perform a runtime check for proxies.

To fix this, when supports_response_schema returns false, we now fallback to the similar tool approach used in other model providers. A fix in LiteLLM will be explored but in the immediate term we need to unblock customers.

Related Issues

#862
#909

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

  • I ran hatch run prepare

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.

@dbschmigelski dbschmigelski changed the title feat(models): use tool for structured_output when supports_response_schema=false feat(models): use tool for litellm structured_output when supports_response_schema=false Oct 8, 2025
Copy link

codecov bot commented Oct 9, 2025

Codecov Report

❌ Patch coverage is 62.85714% with 13 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/strands/models/litellm.py 62.85% 10 Missing and 3 partials ⚠️

📢 Thoughts on this report? Let us know!

@dbschmigelski dbschmigelski merged commit 2f04758 into strands-agents:main Oct 9, 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.

5 participants