fix: keep OpenAI reasoning responses stateful#4557
Merged
Conversation
Contributor
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4557 +/- ##
==========================================
- Coverage 74.35% 70.13% -4.22%
==========================================
Files 52 79 +27
Lines 6897 9427 +2530
Branches 2190 2958 +768
==========================================
+ Hits 5128 6612 +1484
- Misses 1753 2798 +1045
- Partials 16 17 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
903470f to
34bd59d
Compare
1fa914b to
b0bf1af
Compare
balegas
approved these changes
Jun 11, 2026
KyleAMathews
added a commit
that referenced
this pull request
Jun 11, 2026
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Executive Summary
Built-in OpenAI/OpenAI Codex reasoning model payloads now force
store: trueso OpenAI Responses continuations can replay reasoning/tool-call state reliably. This prevents follow-up agent steps from failing with missingrs_*reasoning item errors.Root Cause
OpenAI Responses reasoning/tool-call continuations can include prior
rs_*reasoning items in subsequent requests. The upstream Responses payload defaults tostore: false, which means OpenAI does not persist those items server-side. When a later request references one of those non-persisted item ids, OpenAI can return:Approach
When applying built-in provider payload defaults for OpenAI reasoning models, keep the existing reasoning-effort normalization and also force the Responses payload to be stateful:
The test coverage verifies that:
store: true.store: falseis intentionally overridden.Key Invariants
store: true.Non-goals
@mariozechner/pi-ai; it applies the built-in agent payload default at our integration layer.Trade-offs
The alternative is to keep
store: falseand preserve/replay fullreasoning.encrypted_contentfor stateless operation. That is more complex and unnecessary for the built-in agent default path. Usingstore: truematches OpenAI's stateful Responses flow and directly fixes the observed continuation failure.Verification
GITHUB_BASE_REF=main node scripts/check-changeset.mjs pnpm --filter @electric-ax/agents exec vitest run test/model-catalog.test.ts pnpm --filter @electric-ax/agents typecheckAlso attempted the prep command's suggested Vitest thread flag:
pnpm --filter @electric-ax/agents exec vitest run test/model-catalog.test.ts --pool-options.threads.maxThreads=2That failed because this Vitest version rejects the flag as an unknown option (
--poolOptions). The same targeted test passes without that unsupported flag.Files Changed
.changeset/openai-reasoning-store-true.md— patch changeset for@electric-ax/agents.packages/agents/src/model-catalog.ts— forcesstore: truefor built-in OpenAI reasoning payload defaults.packages/agents/test/model-catalog.test.ts— updates expectations and adds regression coverage for OpenAI-onlystore: truebehavior.