strands-agents/sdk-python

[BUG] Structured output failing for LiteLLM model run with azure provider

Closed this issue · 2 comments

Checks

  • I have updated to the lastest minor and patch version of Strands
  • I have checked the documentation and this is not expected behavior
  • I have searched ./issues and there are no duplicates of my issue

Strands Version

1.13.0

Python Version

3.11.0

Operating System

macOS 15.6

Installation Method

pip

Steps to Reproduce

from strands import Agent
from strands.models.litellm import LiteLLMModel
from pydantic import BaseModel


model = LiteLLMModel(
    model_id="azure/<your-deployment>",
    client_args={
        "api_key": "<your-token>",
        "api_base": "<azure-endpoint>",
    }
)


agent = Agent(model=model)


class UserInfo(BaseModel):
    Username: str
    Location: int


result = agent.structured_output(UserInfo, "Extract user information from the following text: 'My username is john_doe and I live in Madrid.'")
print(result)

install strands-agents with litellm

run the above code

Expected Behavior

The code should run successful, and return response with provided structure.

Actual Behavior

The code fail with this error
litellm.exceptions.BadRequestError: litellm.BadRequestError: AzureException BadRequestError - The 'stream_options' parameter is only allowed when 'stream' is enabled.

Additional Context

No response

Possible Solution

No response

Related Issues

No response

Hi, this approach to structured_output is going to be deprecated when #943 is released. Will ping here when that is done

Hi, in 1.14.0 we introduced a new mechanism for structured_output which we expect to be much more robust. This deprecates the existing

agent.structured_output

pattern in favor of

result = agent(structured_output_model=SomeModel)
some_model: SomeModel = result.structured_output

You can read more about this here https://strandsagents.com/latest/documentation/docs/user-guide/concepts/agents/structured-output/#basic-usage. The new approach should handle this azure edge case already.