feat(agent-core-v2): round-trip reasoning_details in chat completions - #3492
feat(agent-core-v2): round-trip reasoning_details in chat completions#3492sailist wants to merge 1 commit into
Conversation
- parse array-shaped reasoning_details from stream and non-stream responses into ThinkParts keyed by detailsIndex, preferring them over the reasoning_content string dialect - keep summary segment boundaries in mergeInPlace so indexed segments never merge - rebuild reasoning_details and reasoning_content verbatim on outbound assistant history - drop interrupted thinking that never received its encrypted state; keep ciphertext-backed thinking replayable - regenerate the state manifest for the ThinkPart shape change
|
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 714ef33b53
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const reasoningDetails = extractReasoningDetails(message); | ||
| if (reasoningDetails !== undefined) { | ||
| yield* convertReasoningDetails(reasoningDetails); |
There was a problem hiding this comment.
Honor the explicitly configured reasoning key
When reasoningKey is explicitly configured and a response also contains an array-valued reasoning_details, this branch bypasses ReasoningKeyDialect.observe and accepts the array anyway. The resulting detailsIndex parts are subsequently serialized as reasoning_details plus reasoning_content, rather than under the configured key, so the explicit setting no longer pins the dialect as its existing contract and test describe; apply details detection only when no explicit key is set, in both response paths.
Useful? React with 👍 / 👎.
Related Issue
N/A — internal task: client-side phase 1 support for the OpenGW "thinking hiding + summary" rollout (no public issue).
Problem
OpenGW will hide raw model thinking from Chat Completions responses and instead send a readable summary plus an encrypted reasoning state that clients must replay verbatim on later turns. The wire shape is a new
reasoning_detailsarray (summary segments plus one trailing encrypted element, index-addressed when streaming) alongside the existingreasoning_contentplaintext. Today kimi-code silently drops array-shapedreasoning_details— the reasoning extractor only accepts strings — and outbound history only echoes concatenated think text under a single reasoning key while discardingThinkPart.encrypted. Once OpenGW makesreasoning_detailsmandatory on continuation (phase 2 rejects requests without it), multi-turn conversations would fail.What changed
reasoning_detailsis parsed intoThinkParts keyed by the element'sindex; the string reasoning dialect is only observed when no array is present. Elements whosetypeis notsummary/encryptedare skipped, so OpenRouter'sreasoning.*array dialect stays ignored as before.ThinkPartgainsdetailsIndex;mergeInPlacerefuses to merge think parts with different indices, so summary segment boundaries survive streaming and the array replays in original order (encrypted element last, delivered once).reasoning_details(summary segments in order plus the trailing encrypted element) together withreasoning_content(segment concatenation); messages without details keep the existing dialect behavior byte-for-byte.ThinkPartshape change.Verification: focused kosong contract/provider and agent loop tests pass; the full agent-core-v2 suite passes except pre-existing environment-dependent region-marker tests on this machine; repo-wide typecheck and lint pass.
Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.