Skip to content

fix(translation): preserve native Anthropic thinking settings - #878

Merged
grahamking merged 1 commit into
mainfrom
gk-1490
Sep 30, 2026
Merged

grahamking merged 1 commit into
mainfrom
gk-1490

Conversation

@grahamking

@grahamking grahamking commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

AnthropicMessagesCodec::encode_request (crates/switchyard-translation/src/codecs/anthropic/buffered.rs:294-308) now re-emits the caller's native thinking object on the reconstructed path, and only falls back to {"type": "adaptive"} when effort is set and no native thinking exists.

Previously, any reasoning.effort clobbered thinking with adaptive, so reconstruction disagreed with verbatim replay (a caller sending thinking: disabled + output_config.effort replayed as disabled but reconstructed as adaptive).

GLM 5.3's review:

Real bug, correctly fixed. README claims match the code, including omit-before-merge ordering and reasoning_effort only applying to OpenAI backends.

Fixes: https://linear.app/nvidia/issue/SWITCH-1490/

Assisted-by: Pi:GPT 6 Astra medium
Reviewed-by: Pi:GLM 5.3 high
Signed-off-by: Graham King grahamk@nvidia.com

Summary by CodeRabbit

  • Bug Fixes
    • Anthropic requests now preserve native thinking settings, including disabled, enabled, and adaptive modes, when translated for a new model or target prompt.
    • Reasoning effort is kept separate from native thinking settings and selects adaptive thinking only when no native setting is provided.
    • OpenAI targets can apply their configured reasoning effort when preparing requests.

`AnthropicMessagesCodec::encode_request` (crates/switchyard-translation/src/codecs/anthropic/buffered.rs:294-308) now re-emits the caller's native thinking object on the reconstructed path, and only falls back to `{"type": "adaptive"}` when effort is set and no native thinking exists.

Previously, any `reasoning.effort` clobbered thinking with adaptive, so reconstruction disagreed with verbatim replay (a caller sending thinking: disabled + output_config.effort replayed as disabled but reconstructed as adaptive).

GLM 5.3's review:
> Real bug, correctly fixed. README claims match the code, including omit-before-merge ordering and reasoning_effort only applying to OpenAI backends.

Fixes: https://linear.app/nvidia/issue/SWITCH-1490/

Assisted-by: Pi:GPT 6 Astra medium
Reviewed-by: Pi:GLM 5.3 high
Signed-off-by: Graham King <grahamk@nvidia.com>
@grahamking
grahamking requested a review from a team as a code owner September 30, 2026 16:41
@coderabbitai

coderabbitai Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: NVIDIA-NeMo/Switchyard/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 3217fa9e-62b0-4630-8cf7-22d33cf99f3a

📥 Commits

Reviewing files that changed from the base of the PR and between fbabf51 and c1aba3d.

📒 Files selected for processing (3)
  • crates/libsy-llm-client/README.md
  • crates/switchyard-translation/src/codecs/anthropic/buffered.rs
  • crates/switchyard-translation/tests/request_translation.rs

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.


Walkthrough

Anthropic request encoding now preserves native thinking settings separately from output_config.effort. A reconstruction test covers disabled, enabled, and adaptive thinking. The README documents field replacement behavior and target-specific effort overrides.

Changes

Anthropic thinking reconstruction

Layer / File(s) Summary
Preserve thinking during reconstruction
crates/switchyard-translation/src/codecs/anthropic/buffered.rs, crates/switchyard-translation/tests/request_translation.rs, crates/libsy-llm-client/README.md
Anthropic encoding copies raw reasoning to thinking when present. It adds adaptive thinking only when thinking is absent and keeps effort in output_config.effort. The test covers reconstruction across disabled, enabled, and adaptive settings. The README describes field replacement and target effort overrides.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to c1aba

The change preserves native Anthropic thinking settings while keeping output effort separate. No merge-blocking issue was identified; merge after normal checks pass.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: preserving native Anthropic thinking settings during translation.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


A rabbit checks the thinking field,
Native settings stay revealed.
Effort keeps its separate place,
Three test cases trace the case.
Hop, the request returns in form!

Comment @coderabbitai help to get the list of available commands.

@grahamking
grahamking enabled auto-merge (squash) September 30, 2026 17:04
@grahamking
grahamking merged commit 649e91d into main Sep 30, 2026
16 checks passed
@grahamking
grahamking deleted the gk-1490 branch September 30, 2026 19:03
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.

2 participants