Skip to content

fix: forward structured output request params for OpenAI Chat Completions#2944

Open
gautamsirdeshmukh wants to merge 1 commit into
strands-agents:mainfrom
gautamsirdeshmukh:fix/openai-chat-structured-params
Open

fix: forward structured output request params for OpenAI Chat Completions#2944
gautamsirdeshmukh wants to merge 1 commit into
strands-agents:mainfrom
gautamsirdeshmukh:fix/openai-chat-structured-params

Conversation

@gautamsirdeshmukh

@gautamsirdeshmukh gautamsirdeshmukh commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Description

Equivalent to #2551 (fix for normal OpenAI provider)

#2551

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 new warnings.

  • I ran hatch run prepare

Checklist

  • I have read the CONTRIBUTING document
  • I have reviewed and understand every line of code in this PR, including any generated by AI tools, and I can explain why it works
  • My change is focused and reasonably small; I have split unrelated work into separate PRs
  • 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.

@github-actions github-actions Bot added size/s python Pull requests that update python code area-structured-output Related to the structured output api area-model Related to models or model providers bug Something isn't working strands-running labels Jun 24, 2026
@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Comment thread strands-py/src/strands/models/openai.py
@github-actions

Copy link
Copy Markdown
Contributor

Assessment: Approve

Clean, focused bug fix that forwards configured request params (e.g. max_tokens, temperature) to the non-streaming parse() call in structured_output, while correctly dropping the streaming-only fields. The approach is consistent with the existing openai_responses.py sibling, and the new unit test asserts the full call shape in a single assert_called_once_with rather than per-field. Structured-output unit tests pass locally.

Review Categories
  • Correctness: format_request produces stream/stream_options (since stream defaults to True), both of which are explicitly popped before parse(). The inline comment explaining why is helpful.
  • Consistency: Mirrors the established pattern in openai_responses.py::structured_output, and is the Chat-Completions analogue of the already-merged fix(openai-responses): prevent tool list mutation across API calls #2551 fix.
  • Testing: Good coverage of the param-forwarding behavior with a full-shape assertion. One minor note left inline re: the incidental tools=[] now being forwarded — worth a quick end-to-end confirmation against the live API if not already done.

Nicely scoped change with a clear, well-commented intent.

@gautamsirdeshmukh gautamsirdeshmukh marked this pull request as ready for review June 24, 2026 19:46
@gautamsirdeshmukh gautamsirdeshmukh changed the title fix: forward structured output request params for OpenAI Chat Complet… fix: forward structured output request params for OpenAI Chat Completions Jun 24, 2026
Comment thread strands-py/src/strands/models/openai.py
@gautamsirdeshmukh gautamsirdeshmukh enabled auto-merge (squash) June 25, 2026 00:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-model Related to models or model providers area-structured-output Related to the structured output api bug Something isn't working python Pull requests that update python code size/s

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants