Skip to content

feat(translator,executor): preserve Kimi reasoning as canonical reasoning_content - #2

Closed
warelik wants to merge 0 commit into
warelik/mission-integrationfrom
ao/airouters-16-kimi-reasoning
Closed

feat(translator,executor): preserve Kimi reasoning as canonical reasoning_content#2
warelik wants to merge 0 commit into
warelik/mission-integrationfrom
ao/airouters-16-kimi-reasoning

Conversation

@warelik

@warelik warelik commented Aug 21, 2026

Copy link
Copy Markdown
Owner

Summary

  • internal/translator/openai/claude/openai_claude_request.go shouldMapClaudeThinkingToReasoning: when the target model is a Kimi model, degrade Claude thinking blocks to unsigned reasoning_content instead of dropping foreign or unsigned signed blocks. GPT and unknown targets keep the existing strict behavior.
  • internal/runtime/executor/helps/codex_multi_agent_v2.go TranslateRequestWithAPIKeyModelCompatibility: skip CarryOverThinkingToSystem for Kimi targets so prior reasoning_content stays in assistant messages rather than being moved into a system message.
  • internal/runtime/executor/helps/carry_over.go: fix plugin-payload doc comment.
  • internal/runtime/executor/kimi_executor.go fallbackAssistantReasoning: do not copy visible assistant content into reasoning_content for tool-call messages; fabricates hidden reasoning and risks self-reflection loops.

Upstream counterpart

kaitranntt#222

Test plan

  • go build -o /tmp/cli-proxy-api ./cmd/server green
  • go test ./... green (8624 passed)
  • New tests pin Kimi reasoning preservation, carry-over skip, and content fallback removal.

Stock issues

Decision

  • reports/kimi-fallback-reasoning-decision.md

@warelik warelik left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AO review: approved (posted as COMMENT; GitHub rejects APPROVE on ones own PR).

Verified at head ff4aeeb:

  • shouldMapClaudeThinkingToReasoning Kimi branch matches the signature-package semantics exactly: DecideSignatureCompatibilityForModel returns Preserve for Kimi-native signatures and DropSignature for everything else (unsigned, Claude, Gemini, GPT, malformed) with the documented rationale that Kimi never validates replayed thinking signatures. The mapping accumulates only the thinking text, which is correct because Kimi reasoning continuity travels in OpenAI-style reasoning_content. GPT and unknown targets keep the strict GPT-signature path unchanged, and the compat wrapper (preserveThinkingBlocks=true) still maps everything as before — verified both wrappers.
  • The carry-over gate skip via isKimiReasoningTarget is consistent with the translator change: on Kimi targets prior reasoning_content stays in the assistant message (canonical container) instead of being relocated into a system instruction. Model-name matching (kimi/moonshot/k2/k3) resolves the test model kimi-k3 correctly.
  • The variadic preserveThinkingBlocks ...bool hack is now an explicit bool; the rename has no stragglers (single call site, build green).
  • The carry_over.go doc-comment fix is accurate against sdk/translator/registry.go (normalizers run after native translation).
  • Assistant-only gating (injection guard) and redacted_thinking exclusion are intact. CI green.

This lands the Plus half of stock issues #5159/#5160 and directly serves stable cross-provider failover into Kimi without dropping recoverable thinking — mission-aligned, with no degradation to GPT/unknown targets.

One optional coverage note (non-blocking): the Kimi degradation table could add a GPT-format-signature case and a Kimi-native Preserve case, though the decision function treats all mismatched signatures uniformly so the current cases pin the behavior adequately.

@warelik warelik left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AO review: changes requested (posted as COMMENT; GitHub rejects REQUEST_CHANGES on ones own PR).

The implementation itself was already reviewed and approved, but this PR is no longer mergeable or needed in its current form:

  • GitHub reports mergeable: false, mergeable_state: dirty. The head is 165 commits behind the PR-recorded base (a229fd79) and 168 behind the current warelik/mission-integration tip (d34e87df), while only 4 commits ahead.
  • Those four changes have already landed in the base through their canonical commits/merges: carry-over (c75a7d6b / merge de336cca), Kimi reasoning preservation (ff4aeeb2 / merge 7c08f6b4), and the no-fabricated-reasoning fix (70f7a097). Every file in this PR overlaps changes already present in the base.
  • The current head is therefore replaying duplicate patches over a base that already contains the work, which explains the dirty merge. The only workflow attached to this head is the agents-md guard; no build/test run was created for this recomposed head.

Please close this PR as already integrated, or rebase it onto the current base and drop all commits already present (which should leave no diff). There is no code correction to make to the reviewed Kimi/carry-over logic itself; this is a branch-state blocker.

@warelik warelik closed this Aug 22, 2026
@warelik
warelik force-pushed the ao/airouters-16-kimi-reasoning branch from 6a27105 to d34e87d Compare August 22, 2026 06:16
@warelik

warelik commented Aug 22, 2026

Copy link
Copy Markdown
Owner Author

Closed as already integrated: the PR branch was rebased onto the current base and all four commits were found to be present through canonical commits/merges. The branch now points to the base commit with no unique diff.

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.

1 participant