Skip to content

fix(translation): preserve Anthropic tool strictness - #585

Open
cpakkamisaac-sae wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
cpakkamisaac-sae:fix/anthropic-tool-strict
Open

fix(translation): preserve Anthropic tool strictness#585
cpakkamisaac-sae wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
cpakkamisaac-sae:fix/anthropic-tool-strict

Conversation

@cpakkamisaac-sae

@cpakkamisaac-sae cpakkamisaac-sae commented Sep 1, 2026

Copy link
Copy Markdown

What

Preserve top-level tools[].strict when decoding Anthropic Messages requests so explicit strictness reaches OpenAI Chat and Responses targets.

Add regression coverage for true, false, and omitted strictness across both translated formats.

Why

The Anthropic decoder previously replaced every tool's strictness with an absent value, silently disabling schema enforcement after translation.

Closes #577.

Notes for reviewers

Start with decode_anthropic_tools; the runtime change is one expression. The request-translation test exercises the complete decoder/encoder path for both destination formats.

Local validation:

  • cargo fmt --all --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --locked --offline -p switchyard-translation
  • cargo test --workspace
  • .venv/bin/ruff check .
  • .venv/bin/mypy switchyard
  • Hermetic Python suite: 113 passed, 2 deselected
  • Loopback proxy capture confirmed function.strict: true in the forwarded request

Summary by CodeRabbit

  • Bug Fixes

    • Anthropic tool definitions now correctly preserve the optional strict setting during translation.
    • Both enabled and disabled values are retained, while unspecified settings remain absent.
  • Tests

    • Added coverage confirming strict values translate correctly to OpenAI Chat and Responses formats.

Signed-off-by: Clement Pakkam Isaac <232634418+cpakkamisaac-sae@users.noreply.github.com>
@cpakkamisaac-sae
cpakkamisaac-sae marked this pull request as ready for review September 1, 2026 06:06
@cpakkamisaac-sae
cpakkamisaac-sae requested a review from a team as a code owner September 1, 2026 06:06
@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 54e80620-c6c8-4f1e-aa50-7761fbcfd586

📥 Commits

Reviewing files that changed from the base of the PR and between c597bfd and 32fe68a.

📒 Files selected for processing (2)
  • crates/switchyard-translation/src/codecs/anthropic/buffered.rs
  • crates/switchyard-translation/tests/request_translation.rs

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


Walkthrough

The change preserves Anthropic tool strict values during decoding. Tests verify that true, false, and unspecified values translate correctly to OpenAI Chat and OpenAI Responses formats.

Changes

Tool strictness translation

Layer / File(s) Summary
Decode and validate tool strictness
crates/switchyard-translation/src/codecs/anthropic/buffered.rs, crates/switchyard-translation/tests/request_translation.rs
Anthropic tool decoding now retains the optional strict value. Tests verify preservation for true and false, and omission when unspecified, across OpenAI Chat and Responses translations.

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

Merge Risk: ⚪ Minimal · up to 32fe6

This change preserves explicit tool schema strictness during request translation without altering endpoints, permissions, dependencies, or deployment behavior. No actionable merge-blocking risk remains after normal checks and review.

Poem

I’m a rabbit with tools in my hay,
Strict flags now travel the proper way.
True stays true, and false stays clear,
Missing flags remain missing here.
OpenAI paths now pass them along,
So translated tools can be strong.

🚥 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. 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 Anthropic tool strictness during translation.
Linked Issues check ✅ Passed The change satisfies issue #577. The Anthropic decoder now preserves tools[].strict, and regression tests verify true, false, and omitted values for OpenAI Chat and Responses translations.
Out of Scope Changes check ✅ Passed The changes are limited to the Anthropic tool decoder and focused translation tests. They directly support issue #577 and contain no unrelated scope.
  • Fix all pre-merge checks with AI

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

@ting-hong-shieh ting-hong-shieh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verified at 32fe68a. The change preserves true and false while leaving omitted strictness absent across OpenAI Chat and Responses. Format, workspace Clippy, and the full translation test suite pass. No blocking findings.

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.

switchyard drops anthropic tools[].strict when translating to openai chat

2 participants