Skip to content

fix(sse): default summary + strip malformed id on kept Responses input items (#11108) - #11110

Merged
diegosouzapw merged 1 commit into
diegosouzapw:release/v3.8.50from
maxmad64bis:fix/11108-reasoning-summary-field
Aug 22, 2026
Merged

diegosouzapw merged 1 commit into
diegosouzapw:release/v3.8.50from
maxmad64bis:fix/11108-reasoning-summary-field

Conversation

@maxmad64bis

@maxmad64bis maxmad64bis commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ base-red inherited: #9985

Summary

applyReasoningInputPolicy() / sanitizeResponsesInput() (open-sse/services/reasoningInputPolicy.ts) never guaranteed two fields stayed valid on input[] items it kept for replay:

  1. summary on a kept type: "reasoning" item — never defaulted when the source omitted it entirely.
  2. id on any kept item (reasoning and non-reasoning alike) — only ever stripped when it was already a valid string; a malformed id (observed as null, same upstream omission pattern) survived replay untouched.

If the upstream that produced the item never included summary (observed with opencode/muse-spark-1.2-contributor-free via the opencode/zen provider — its Responses API output omits summary entirely on opaque-only reasoning items, and separately sends id: null instead of a rs_... string on some items, including non-reasoning function_call items), that missing/malformed field survives the replay round trip. Some Responses-API-compatible upstreams treat both as required-if-present and reject the next turn:

[400] invalid_request_error: `input[N]` missing required field `summary`
Expected 'id' to be a string.

Same code path recently touched by #10949/#10959/#10961 (mixed plaintext/opaque reasoning replay) for the summary gap; the id gap is the sibling finding caught while validating that fix end-to-end against live muse-spark traffic — and the same class of gap was independently present in responsesInputSanitizer.ts::sanitizeInputItemId(), which returned a malformed id unchanged instead of stripping it.

Change

  • sanitizeResponsesInput(), reasoning branch: default next.summary = [] on a kept type: "reasoning" item carrying opaque state when the source omitted it. Plaintext-only items intentionally have no summary key and stay untouched.
  • sanitizeResponsesInput(), reasoning branch: keep id only when the item is opaque and id is a valid string; strip it otherwise (collapsed two overlapping conditions into one, via the new shared helper).
  • sanitizeResponsesInput(), generic branch (function_call, message, ...): strip id whenever present, valid or not.
  • New open-sse/services/responsesItemId.ts::isValidResponsesItemId(), shared by both places above and by responsesInputSanitizer.ts::sanitizeInputItemId(), which now actually strips a malformed id instead of passing it through unchanged.
  • Flipped one legacy assertion in strip-reasoning-blobs-agentic-context-1599.test.ts that locked in the old byte-verbatim passthrough (no summary) to the corrected contract.

Test Plan

Regressions in tests/unit/reasoning-input-policy-summary-11108.test.ts and tests/unit/responses-input-sanitizer-name.test.ts:

  • Compatible-transport passthrough defaults summary: [] on an opaque item missing it; an existing summary is left untouched.
  • Incompatible-transport drop-and-repair path also defaults summary on the surviving opaque item.
  • A non-string id (null) on a kept opaque reasoning item is stripped; a valid string id is preserved.
  • A non-string id on a non-reasoning item (function_call) is stripped; call_id is untouched.
  • responsesInputSanitizer.ts::sanitizeInputItemId() now strips a non-string reasoning-item id instead of passing it through (previously untested gap).
node --import tsx/esm --test tests/unit/reasoning-input-policy-summary-11108.test.ts tests/unit/responses-input-sanitizer-name.test.ts tests/unit/codex-system-message-image-8089.test.ts
# 26 pass, 0 fail

npx cross-env DISABLE_SQLITE_AUTO_BACKUP=true node --import tsx/esm --import ./open-sse/utils/setupPolyfill.ts --import ./tests/_setup/isolateDataDir.ts --test --test-force-exit --test-concurrency=1 \
  tests/unit/reasoning-cache.test.ts \
  tests/unit/strip-reasoning-blobs-agentic-context-1599.test.ts \
  tests/unit/translator-resp-openai-responses.test.ts \
  tests/unit/translator-openai-responses-req.test.ts \
  tests/unit/encrypted-reasoning-summary-7243.test.ts \
  tests/unit/reasoning-input-policy-summary-11108.test.ts \
  tests/unit/responses-input-sanitizer-name.test.ts \
  tests/unit/codex-system-message-image-8089.test.ts
# 152/152 pass, 0 fail (no regressions from the shared-helper refactor)

npx eslint open-sse/services/reasoningInputPolicy.ts open-sse/services/responsesInputSanitizer.ts open-sse/services/responsesItemId.ts tests/unit/reasoning-input-policy-summary-11108.test.ts tests/unit/responses-input-sanitizer-name.test.ts — clean.

npx tsc --noEmit -p tsconfig.json — no errors on the touched files.

Closes #11108

@maxmad64bis
maxmad64bis marked this pull request as draft August 22, 2026 11:25
@maxmad64bis maxmad64bis changed the title fix(sse): default summary on kept opaque reasoning items (#11108) fix(sse): default summary + strip malformed id on kept Responses input items (#11108) Aug 22, 2026
@maxmad64bis
maxmad64bis marked this pull request as ready for review August 22, 2026 11:31
@maxmad64bis
maxmad64bis marked this pull request as draft August 22, 2026 11:37
…t items

applyReasoningInputPolicy()/sanitizeResponsesInput()
(open-sse/services/reasoningInputPolicy.ts) never guaranteed two fields
stayed valid on `input[]` items it kept for replay:

1. `summary` on a kept `type: "reasoning"` item — never defaulted when the
   source omitted it entirely.
2. `id` on any kept item (reasoning and non-reasoning alike) — only ever
   stripped when it was already a valid string; a malformed `id` (observed
   as `null`, same upstream omission pattern) survived replay untouched.

If the upstream that produced the item never included `summary` (observed
with `opencode/muse-spark-1.2-contributor-free` via the `opencode`/zen
provider — its Responses API output omits `summary` entirely on
opaque-only reasoning items, and separately sends `id: null` instead of a
`rs_...` string on some items, including non-reasoning `function_call`
items), that missing/malformed field survives the replay round trip. Some
Responses-API-compatible upstreams treat both as required-if-present and
reject the next turn:

```
[400] invalid_request_error: `input[N]` missing required field `summary`
```
```
Expected 'id' to be a string.
```

Same code path recently touched by diegosouzapw#10949/diegosouzapw#10959/diegosouzapw#10961 (mixed
plaintext/opaque reasoning replay) for the `summary` gap; the `id` gap is
the sibling finding caught while validating that fix end-to-end against
live muse-spark traffic — and the same class of gap was independently
present in responsesInputSanitizer.ts::sanitizeInputItemId(), which
returned a malformed id unchanged instead of stripping it.

Changes:
- sanitizeResponsesInput(), reasoning branch: default `next.summary = []`
  on a kept opaque `type: "reasoning"` item when the source omitted it.
  Plaintext-only items intentionally have no `summary` key and stay
  untouched.
- sanitizeResponsesInput(), reasoning branch: keep `id` only when the item
  is opaque and `id` is a valid string; strip it otherwise (collapsed from
  two overlapping conditions into one, using the new shared helper).
- sanitizeResponsesInput(), generic branch (function_call, message, ...):
  strip `id` whenever present, valid or not.
- New open-sse/services/responsesItemId.ts::isValidResponsesItemId(),
  shared by both files above and by
  responsesInputSanitizer.ts::sanitizeInputItemId(), which now actually
  strips a malformed id instead of passing it through.
- Flipped one legacy assertion in
  strip-reasoning-blobs-agentic-context-1599.test.ts that locked in the
  old byte-verbatim passthrough (no `summary`) to the corrected contract.

Closes diegosouzapw#11108
@maxmad64bis
maxmad64bis force-pushed the fix/11108-reasoning-summary-field branch from 4376366 to d40168d Compare August 22, 2026 11:42
@maxmad64bis
maxmad64bis marked this pull request as ready for review August 22, 2026 11:44
@maxmad64bis
maxmad64bis marked this pull request as draft August 22, 2026 11:59
@maxmad64bis
maxmad64bis marked this pull request as ready for review August 22, 2026 12:05
@maxmad64bis
maxmad64bis marked this pull request as draft August 22, 2026 12:15
@maxmad64bis
maxmad64bis marked this pull request as ready for review August 22, 2026 14:51
@diegosouzapw
diegosouzapw merged commit d021423 into diegosouzapw:release/v3.8.50 Aug 22, 2026
25 of 46 checks passed
diegosouzapw pushed a commit to jackjinke/OmniRoute that referenced this pull request Aug 23, 2026
…ary defaults in chatcore-translation-paths
diegosouzapw pushed a commit that referenced this pull request Aug 23, 2026
…10949, #10959) (#10961)

Validated on the combined batch board + this branch: 231/231 across chatcore-translation-paths, reasoning-cache, strip-reasoning-blobs, and both Responses translator suites. Pre-merge: propagated the #11110/#11129 summary:[] defaults into five assertions here (each commented with its PR) — without it this branch red against the tip, and as a bonus the merge drains the 4 reasoning reds that were live on the tip from those merges. Plaintext now wins over a coexisting opaque companion; opaque-only drops cleanly for plaintext targets; combos keep explicit Skip. Fixes #10949 and #10959. Thank you @jackjinke!
@maxmad64bis
maxmad64bis deleted the fix/11108-reasoning-summary-field branch September 24, 2026 21:12
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…t items (diegosouzapw#11110)

Validated on the combined batch board over release/v3.8.50 tip 0f43f0f: static gates clean, typecheck:core clean, focused tests green.

Defaults summary and strips malformed ids on kept Responses input items — both 400s observed against live muse-spark traffic; the flipped legacy assertion is documented contract propagation. Thank you @maxmad64bis!
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…iegosouzapw#10949, diegosouzapw#10959) (diegosouzapw#10961)

Validated on the combined batch board + this branch: 231/231 across chatcore-translation-paths, reasoning-cache, strip-reasoning-blobs, and both Responses translator suites. Pre-merge: propagated the diegosouzapw#11110/diegosouzapw#11129 summary:[] defaults into five assertions here (each commented with its PR) — without it this branch red against the tip, and as a bonus the merge drains the 4 reasoning reds that were live on the tip from those merges. Plaintext now wins over a coexisting opaque companion; opaque-only drops cleanly for plaintext targets; combos keep explicit Skip. Fixes diegosouzapw#10949 and diegosouzapw#10959. Thank you @jackjinke!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(providers): Responses API reasoning replay drops summary field, upstream 400s on input[N]

2 participants