Skip to content

fix(openai): warn about reasoningContent once per request - #5016

Merged
liramon2 merged 1 commit into
strands-agents:mainfrom
AkshayShah03:agent-tasks/4990
Oct 9, 2026
Merged

liramon2 merged 1 commit into
strands-agents:mainfrom
AkshayShah03:agent-tasks/4990

Conversation

@AkshayShah03

@AkshayShah03 AkshayShah03 commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Human Overview

The "reasoningContent is not supported" warning was repeated for every earlier message on every request, logs filled up fast in long conversations; the check now runs once per request. LiteLLM also fixed. Once per request instead of once per model instance.

Description

OpenAIModel re-formats the whole history on every request and logged the reasoningContent warning once per reasoning message each time, so a reasoning-model run of N turns logged about N²/2 copies (552k in the reporter's benchmark). The check now runs once over the history, so each request logs at most one warning. LiteLLMModel shares this formatter and gets the same fix.

This warns once per request rather than once per model instance, as the issue suggested: the formatter is a classmethod with no instance to hold a "warned" flag, and the issue lists once per request as acceptable.

Resolves #4990

Related Issues

#4990, #1053 (how models handle reasoning content they didn't produce; this PR only changes how often the warning is logged)

Documentation PR

N/A — log-volume fix, no user-facing docs change.

Type of Change

Bug fix

Testing

Ran the issue's repro script: requests 1, 10 and 100 now each log 1 warning (100 in total over 100 requests, down from 5,050). Ran the OpenAI and LiteLLM model test suites and the full strands-py unit suite.

  • I ran hatch run prepare

Additional Details

Extended context (optional)

The cachePoint and location-source warnings in the same loop also repeat for every matching message on every request. They're left out of this PR to keep it focused.

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 complexity/low Touched functions have low cognitive complexity (<=10) size/xs labels Oct 9, 2026
@codecov

codecov Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@liramon2
liramon2 merged commit e46b0db into strands-agents:main Oct 9, 2026
49 of 57 checks passed
@AkshayShah03
AkshayShah03 deleted the agent-tasks/4990 branch October 22, 2026 03:01
gautamsirdeshmukh pushed a commit to gautamsirdeshmukh/harness-sdk that referenced this pull request Nov 2, 2026
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 bug Something isn't working complexity/low Touched functions have low cognitive complexity (<=10) python Pull requests that update python code size/xs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] OpenAIModel logs the reasoningContent warning once per earlier message on every request, so the count grows with the square of the turns

2 participants