Repository navigation
fix(relaykit): emit summary on reasoning items announced without one - #7833
Conversation
The Responses schema requires summary on every reasoning item, but the chat-to-Responses stream announces a reasoning item with an empty summary that omitempty drops. Strict clients reject the item and then see every summary event that follows as having no active item. Items that already carry summary text keep their existing encoding.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughReasoning output items now serialize with ChangesReasoning Summary Serialization
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to
|
Sync 54 upstream commit(s) via merge (fork history preserved). Behavior changes from upstream: - 4013729 fix: disable sensitive word filtering by default and clear the default word list (QuantumNous#7814) Upstream commits: - 5e95951 feat(channels): add drag mode for channel priority ordering - 5a59d69 fix(pricing): hide task prices left at zero when another price is set - 3e2ce2c fix: align model card summary with status bar hours (QuantumNous#7847) - b0a98ac fix(web): apply theme class before first paint so Dark Reader detects dark mode (QuantumNous#7571) - f92c576 fix(web): cover Cloudflare clef and NVIDIA model families in provider rules (QuantumNous#7840) - ff36846 fix(relayconvert): 保留 Chat/Claude → Responses 转换中 input_image 的 detail 字段 (QuantumNous#7855) - 09109ec fix(middleware): 过载哨兵改用容器口径并加入连续性与新鲜度判定 (QuantumNous#7317) - d032204 feat(aws): add Mantle Messages API support - ca2cae6 fix(relaykit): emit summary on reasoning items announced without one (QuantumNous#7833) - 45fbb14 fix(rate-limit): count each group with its own limit separately - 6549a17 fix(dashboard): draw flow chart labels in the theme text color (QuantumNous#7821) - c9179d3 fix(playground): support the reasoning field in chat responses (QuantumNous#7831) - 908f94d fix(web): hide pages the user cannot open from console search - 19d435e fix(relay): mask only the custom upstream address in error messages (QuantumNous#7822) - 718a4e7 fix(vertex): use the multi-region hostnames for us and eu - f196934 feat(plugins): bind Hailuo, Vidu and Veo plugins to New API channels - bfdad29 fix(vidu): bill the model, duration and resolution Vidu generates - 150ab3c chore(licenses): refresh the third-party dependency inventory - 76cd511 build: upgrade moejs to v0.1.0-alpha.7 - 1b63c28 fix(claude): preserve explicit zero usage and cache-only billing (QuantumNous#7816) - c9f7b62 fix(web): sort pricing models by input, output and per-request price (QuantumNous#7813) - a0bf6a8 fix(vertex): pass project_id in API Key mode to avoid 404 on official endpoints (QuantumNous#6330) - 4013729 fix: disable sensitive word filtering by default and clear the default word list (QuantumNous#7814) - 7de10f2 feat(token): let an API key read its owner's quota - ef60ef2 fix(relay): keep the cause of a failed body read for every later reader - d10eafb fix(relay): report the real cause when a request body cannot be read - 63cecab feat(channel): support Sub2API balance queries (QuantumNous#7749) - b4be2a7 feat(ui): show newly added pricing groups at the top (QuantumNous#7782) - 633b4c5 feat(logs): export usage logs from the common log page (QuantumNous#7774) - dd59854 chore(deps-dev): bump undici from 6.28.0 to 6.29.0 in /electron (QuantumNous#7624) - 93cf4ba chore(deps-dev): bump js-yaml from 4.3.1 to 4.3.2 in /electron (QuantumNous#7327) - 3c9fb2a chore(deps-dev): bump brace-expansion from 1.1.16 to 1.1.21 in /electron (QuantumNous#7623) - 9f04810 chore(deps): bump ai from 7.0.31 to 7.0.136 in /web (QuantumNous#7767) - 3fe394c chore(deps): bump github.com/gorilla/websocket from 1.5.0 to 1.5.3 (QuantumNous#7001) - 1c58f3d chore(deps-dev): bump fast-uri from 3.1.5 to 3.1.7 in /electron (QuantumNous#7169) - 7f51a97 chore(deps-dev): bump js-yaml from 4.3.1 to 4.3.2 in /electron (QuantumNous#7327) - 7e25797 chore(deps-dev): bump electron from 39.8.10 to 41.10.6 in /electron (QuantumNous#7625) - bf4e1eb build(deps-dev): bump oxfmt from 0.57.0 to 0.72.0 in /web (QuantumNous#7766) - 82306b3 build(deps-dev): bump @tanstack/router-plugin in /web (QuantumNous#7768) - c730add build(deps): bump stream-markdown-parser from 1.1.3 to 1.2.18 in /web (QuantumNous#7769) - b8c2dc1 build(deps): bump yace from 1.1.0 to 1.1.1 in /web (QuantumNous#7770) - ba29f06 chore(deps-dev): bump @xmldom/xmldom from 0.8.13 to 0.8.15 in /electron (QuantumNous#7187) - 767a82b fix(claude): forward thinking.block_binding and every anthropic-beta value (QuantumNous#7732) - 2b85a8f fix(auth): show legal consent warning on password login (QuantumNous#7771) - 2ed0587 fix(ci): stabilize checks and configure Bun dependency updates (QuantumNous#7765) - 9948b1e fix(pricing): accept declared endpoint arrays in pricing conversion (QuantumNous#7724) - 4bfcf28 chore(web): bump @lobehub/icons to 5.22.0 (QuantumNous#7764) - fc08b76 fix(web): preserve recorded billing tiers in usage log previews (QuantumNous#7763) - ba0e478 fix(relaykit): preserve assistant text with tool calls (QuantumNous#6871) - 34b1942 fix(pricing): allow root access when the model square is disabled (QuantumNous#7761) - b22a43b fix: mark task settlement logs with is_task for tiered billing display (QuantumNous#7446) - bbf60b4 fix(logs): vertically align billing source icons on mobile (QuantumNous#7760) - 3f926c3 fix(metrics): count completed streams after context cancellation (QuantumNous#7638) - 3827fd8 fix(web): show cache read price on expression model cards (QuantumNous#7757) Local tests not run (CI-only).
…uantumNous#7833) The Responses schema requires summary on every reasoning item, but the chat-to-Responses stream announces a reasoning item with an empty summary that omitempty drops. Strict clients reject the item and then see every summary event that follows as having no active item. Items that already carry summary text keep their existing encoding.
…uantumNous#7833) The Responses schema requires summary on every reasoning item, but the chat-to-Responses stream announces a reasoning item with an empty summary that omitempty drops. Strict clients reject the item and then see every summary event that follows as having no active item. Items that already carry summary text keep their existing encoding. (cherry picked from commit ca2cae6)
…uantumNous#7833) The Responses schema requires summary on every reasoning item, but the chat-to-Responses stream announces a reasoning item with an empty summary that omitempty drops. Strict clients reject the item and then see every summary event that follows as having no active item. Items that already carry summary text keep their existing encoding. (cherry picked from commit ca2cae6)
…uantumNous#7833) The Responses schema requires summary on every reasoning item, but the chat-to-Responses stream announces a reasoning item with an empty summary that omitempty drops. Strict clients reject the item and then see every summary event that follows as having no active item. Items that already carry summary text keep their existing encoding.
…uantumNous#7833) The Responses schema requires summary on every reasoning item, but the chat-to-Responses stream announces a reasoning item with an empty summary that omitempty drops. Strict clients reject the item and then see every summary event that follows as having no active item. Items that already carry summary text keep their existing encoding.
Agent
Roger Chien <[email protected]>is not among the historical core developers ingit log(no commits byRogerorrjchien728before45fbb149), so this is stated here per AGENTS.md.Links
User request
rjchien728.summary.Out of scope — refuse
summaryis required comes from the official OpenAI SDKs, not Codex-specific behavior; not a usage / configuration question.Open gate — do not open unless all are satisfied
go buildor tests passed: yesKind
Issue facts
response.output_item.addedemitted by the chat→Responses stream conversion has nosummaryin its item (the empty slice is dropped byomitempty).output_item.doneand the output inresponse.completedcarry the summary text and are not affected.ResponseReasoningItem.summaryis required in the official OpenAI SDKs. Codex CLI 0.162.1 fails to parse the item withoutsummary, and then logs awithout active itemerror for every followingreasoning_summary_part.added/reasoning_summary_text.delta; the task still completes.reasoning_content.Summary, whichomitemptycancels; with the same Codex 0.162.1 and only the two SSE streams swapped (with / without"summary":[]), the log lines go from 2 to 0.POST /v1/responses(stream), chat upstream,RelayFormatOpenAI→RelayFormatOpenAIResponses, pass-through off; not tested against a server, reproduced at the relaykit level. Billing / Frontend / Deployment: not applicable.Change
Adds
case "reasoning"toResponsesOutput.MarshalJSONinrelaykit/dto/openai_response.go:Summaryhas content: encodes through the existing alias, byte-for-byte the same output as before.Summaryis empty: additionally emits"summary":[](an anonymous struct embedding the alias, with an outerSummaryfield taggedjson:"summary"withoutomitempty; the shallower outer field overrides the embedded one of the same name).Only items with
Type == "reasoning"are affected; message / function_call and other items keep their existing branches and output. Test: a 6-line assertion added to the existingTestChatCompletionsStreamToResponsesEmitsReasoningSummaryPartLifecycle(the serialized reasoning added event contains"summary":[]); no new test file.Research
Duplicate / prior art
gh search issues/gh search prs(--repo QuantumNous/new-api):reasoning summary,output_item.added,without active item,summary omitempty,reasoning_summary_part,ReasoningSummaryPartAdded; Discussions via GraphQLsearch(type: DISCUSSION)for the first three, 0 results;gh pr list --state open --search 'relaykit/dto/openai_response.go'and--search reasoningfor open PRs.summary omitemptyreturns 0 results in both issues and PRs.relay/channel/openai/relay_responses.go. This PR is about events new-api generates itself during conversion, on therelay/channel/openai/responses_via_chat.gopath, which does not go throughrelay_responses.go; fix: normalize missing Responses output item collections #7088 does not change this path's output.summary: []. fix(relayconvert): Claude tool_result 图片提升到 user 消息;Chat→Responses 流补齐 reasoning part 事件并按段切分 item #7512 (merged) later addedreasoning_summary_part.added/donebut did not changerelaykit/dto, so the added event still lackssummary.omitemptyor "reasoning item missingsummary".Docs and code
/en/docs/api,/zh/docs/api/ai-model/chat/openai/createresponse. The Responses page only lists request parameters and response fields; it has no reasoning itemsummaryor SSE event fields, and no configuration option. Not a usage / configuration question.README.mdandREADME.zh_CN.mdonly listPOST /v1/responsesin the feature table; searchingdocs/foroutput_item|reasoning_summary|relayconvertfinds nothing.relaykit/dto/openai_response.go:371—Summaryhasomitempty; thedefaultbranch ofMarshalJSONencodes through an alias, so an empty slice is omitted.relaykit/relayconvert/internal/oai_chat/to_oai_responses_stream_resp.go:488-497— the reasoning added event explicitly setsSummary: []dto.ResponsesReasoningSummaryPart{}, i.e. it means to emitsummary:[].relay/channel/openai/responses_via_chat.go:73,:86-87,:159— streaming for a chat upstream and a/v1/responsesclient, converting per chunk and serializing withcommon.Marshal(event.Payload); confirmed to go through this defect.relay/channel/claude/relay_responses.go:22,relay/channel/gemini/relay_responses.go:86— intext_converter_registry.goboth response conversions end withConverterOpenAIChatToOpenAIResponses, and Claudethinking_delta/ Gemini thought parts becomereasoning_content; by reading the code they should be affected the same way; not tested.relay/channel/openai/relay_responses.go:26-44,:83-97— native Responses forwarding: the decoded struct is only used to read usage, and the client receives the original bytes, notResponsesOutputserialization, so this change does not affect it.src/openai/types/responses/response_reasoning_item.pyhassummary: List[Summary](no default); openai-nodesrc/resources/responses/responses.tshasResponseReasoningItem.summary: Array<...>(not optional); Codexrust-v0.162.1hassummary: Vec<...>atcodex-rs/protocol/src/models.rs:1054.Alternatives considered
omitemptyfromSummary. Every item that goes through thedefaultbranch (e.g. message) would then also emitsummary(nullwhen nil), changing the output of other item types and requiring golden file updates. Not tried.to_oai_responses_stream_resp.goemits the reasoning added event. That code already sets an empty slice; it is the serialization step that drops it, so fixing it there means working around the DTO's encoding, and any other place that builds a reasoning item with an emptySummarywould still lose the field.summaryonly for thereasoningtype inMarshalJSON. The schema requiressummaryon every reasoning item, and doing it at DTO serialization covers every path; the output is unchanged whenSummaryhas content and for every other item type, and the diff is 16 lines (10 of production code).Files
relaykit/dto/openai_response.gocase "reasoning"toResponsesOutput.MarshalJSON, emitting"summary":[]whenSummaryis emptyrelaykit/relayconvert/internal/oai_chat/to_oai_responses_resp_test.goTestChatCompletionsStreamToResponsesEmitsReasoningSummaryPartLifecycleBehavior
response.output_item.addeditem is{"type":"reasoning","id":"r1_reasoning_0","status":"in_progress","role":"","content":null,"quality":"","size":""}, with nosummary."summary":[]. Reasoning items with a non-emptySummaryand all other item types are unchanged.finish_reason, after the next item'soutput_item.added(interleaved events). There is no evidence of a client failing on this, so it is not part of this PR.Verification
cd relaykit && GOWORK=off go test ./relayconvert/internal/oai_chat/ -run TestChatCompletionsStreamToResponsesEmitsReasoningSummaryPartLifecycle -count=1: FAIL on upstream main45fbb149(unfixed) with"{\"type\":\"response.output_item.added\",\"item\":{\"type\":\"reasoning\",\"id\":\"resp_1_reasoning_0\",\"status\":\"in_progress\",\"role\":\"\",\"content\":null,\"quality\":\"\",\"size\":\"\"},\"output_index\":0}" does not contain "\"summary\":[]"; PASS on this branch.cd relaykit && GOWORK=off go build ./...succeeds;GOWORK=off go test ./dto/ ./relayconvert/... -count=1all ok, including the golden testTestGoldenResponseConversionMatrix(golden files unchanged).go test ./relay/channel/openai/ ./relay/channel/claude/ ./relay/channel/gemini/ ./service/ -count=1all ok.gofmt -l relaykit/dto/openai_response.go relaykit/relayconvert/internal/oai_chat/to_oai_responses_resp_test.goprints nothing.NewResponseStreamState+ConvertStreamResponseChunkfed onereasoning_content:"think"chunk): the reasoning added item from45fbb149has nosummary; this branch outputs the same plus"summary":[], and all other events are identical.replace github.com/QuantumNous/new-api/relaykit => <fork>/relaykit) usesNewResponseStreamState(RelayFormatOpenAI → RelayFormatOpenAIResponses, EmitSequenceNumber: true), feeds 4 chat chunks (reasoning_content:"think"→ tool_callshellannounced → arguments{"command":["echo","hi"]}→finish_reason:"tool_calls"), thenFinalizeStreamResponse, and prints the SSE. Reasoning added from upstream main:{"type":"reasoning","id":"r1_reasoning_0","status":"in_progress","role":"","content":null,"quality":"","size":""}; this branch: the same plus"summary":[]. Both SSE streams were served by a local mock Responses server tocodex exec --skip-git-repo-check "run echo hi" < /dev/null(Codex CLI 0.162.1): upstream main exit 0 with 2without active itemlines on stderr (ReasoningSummaryPartAdded 1, ReasoningSummaryDelta 1); this branch exit 0 with 0 lines. Codex ran the tool and sent the follow-up request both times.Risks
ResponsesOutputwithType == "reasoning"and an emptySummarynow emits an extra"summary":[]. This matches the required field in the official OpenAI SDKs; per the code, native Responses forwarding (relay_responses.go) writes the original bytes and is not affected. The output is unchanged whenSummaryis non-empty.Scope check