Skip to content

fix: openai repsonses api error handling#1931

Merged
Unshure merged 1 commit intostrands-agents:mainfrom
Unshure:main
Mar 18, 2026
Merged

fix: openai repsonses api error handling#1931
Unshure merged 1 commit intostrands-agents:mainfrom
Unshure:main

Conversation

@Unshure
Copy link
Member

@Unshure Unshure commented Mar 18, 2026

Description

Fix failing openai responses api integ test:

FAILED tests_integ/models/test_model_openai.py::test_context_window_overflow_integration[OpenAIResponsesModel-gpt-4o-mini-2024-07-18] - Failed: DID NOT RAISE <class 'strands.types.exceptions.ContextWindowOverflowException'>

Related Issues

N/A

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

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.

@github-actions github-actions bot added size/s and removed size/s labels Mar 18, 2026
@Unshure Unshure marked this pull request as ready for review March 18, 2026 18:40
@github-actions github-actions bot added size/s and removed size/s labels Mar 18, 2026
@github-actions github-actions bot added size/s and removed size/s labels Mar 18, 2026
@strands-agents strands-agents deleted a comment from github-actions bot Mar 18, 2026
@strands-agents strands-agents deleted a comment from github-actions bot Mar 18, 2026
@strands-agents strands-agents deleted a comment from github-actions bot Mar 18, 2026
@strands-agents strands-agents deleted a comment from github-actions bot Mar 18, 2026
@github-actions
Copy link

Assessment: Request Changes

The fix for stream() is correct and will resolve the failing integration test. However, the structured_output() method (line 366) has the same bug and wasn't fixed.

Review Details
  • Critical: Apply the same fix to structured_output() at line 366 - it currently only catches BadRequestError, not APIError
  • Testing: Consider adding a test for APIError in structured_output() to verify the fix

Once structured_output() is updated with the same error handling pattern, this will be good to merge.

@codecov
Copy link

codecov bot commented Mar 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

zastrowm
zastrowm previously approved these changes Mar 18, 2026
@Unshure Unshure merged commit 1643a62 into strands-agents:main Mar 18, 2026
20 of 21 checks passed
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.

2 participants