Repository navigation
fix(agent-core-v2): preserve llm reasoning and usage compatibility - #4485
Conversation
- prefer the current model's detected reasoning dialect for unmarked history - restore top-level usage fallback for ordinary Responses events
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
commit: |
MoonshotAI#4410 MoonshotAI#4413 MoonshotAI#4431 MoonshotAI#4450 MoonshotAI#4451 MoonshotAI#4485 MoonshotAI#4524 were each implemented earlier — the compaction prefix suite, the media-recovery case, the OAuth callback socket drain, the split delivering-work section, the compaction wording, the reasoning-key order and the 10-step todo reminder are all in the tree and pinned by their own tests. Each row now carries that probe. Only MoonshotAI#4410 needed care: upstream patched paths that this fork renamed (`human/llm/builtin/protocol` versus `human/llm/requester/bases`), so the matching was done on the behaviour — stripDynamicToolContext is gone and extractEventUsage already reads usage only on terminal response events. Ledger: closed 22 -> 28, remaining 71.
… terminal event Same bug class on the Responses wire: a Responses-compatible server can put usage on the `response.completed` event itself instead of inside its `response` object. The Codex assembler read only the nested copy, so the turn's usage was None. Fall back to the event-level copy; the nested one still wins when both exist. kimi-code#4485 restored the same fallback in its Responses decoder.
Requirement or Bug
Follow up on #4352 with two LLM compatibility fixes identified during review:
Bug Reproduction Steps
reasoning, switch to a model that detectsreasoning_content, then switch back with history containing one explicitly marked and one unmarked thinking part. The unmarked part is emitted withreasoning_contentinstead of the current model'sreasoningkey.usage. The emitted token usage isundefined.Root Cause
response.usagewhenever response metadata was present, even for ordinary events that carry usage at the top level.Both fixes address the selection logic directly rather than adding a compatibility workaround.
Code Changes
response.completedandresponse.incomplete; for other Responses events, fall back from nested usage to top-level usage.Behavior Changes and Affected Users
response.completedandresponse.incompletehandling is unchangedCoverage:
thinking.test.tsexercises real HTTP model switches and mixed marked/unmarked history;trait.test.tsexercises a real requester stream with top-level usage. Prior focused verification passed: thinking 15/15, trait plus response-format 69/69, and agent-core-v2 typecheck.Checklist
gen-changesets; no changeset was added per the author's decision.