Skip to content

fix(translation): preserve responses tool-use stop reasons - #1317

Merged
grahamking merged 1 commit into
NVIDIA-NeMo:mainfrom
dagardner-nv:fix/preserve-buffered-tool-stop-reason
Nov 13, 2026
Merged

grahamking merged 1 commit into
NVIDIA-NeMo:mainfrom
dagardner-nv:fix/preserve-buffered-tool-stop-reason

Conversation

@dagardner-nv

@dagardner-nv dagardner-nv commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

What

Preserve ToolUse when decoding buffered Responses output that contains a tool call followed by assistant text. Extend the existing mixed text/tool test to check the decoded stop reason in both item orders.

Why

Trailing text overwrote the tool-use stop reason with EndTurn. Chat and Anthropic translations then reported ordinary completion while still containing a tool call.

Notes for reviewers

The decoder change keeps the existing response-level token-limit override.

Validation passed:

  • cargo test --offline -p switchyard-translation
  • cargo clippy --offline --workspace --all-targets --locked -- -D warnings
  • cargo fmt --all --check
  • Local Python reproduction after rebuilding the extension: tool_use, one retained tool call, exit code 0.

Summary by CodeRabbit

  • Bug Fixes
    • Mixed assistant responses containing both text and tool calls now retain the correct tool-use stop reason, regardless of whether the text or tool-call item appears first. This keeps translated response behavior consistent when output items are processed in different orders.

Signed-off-by: David Gardner <dagardner@nvidia.com>
@dagardner-nv

Copy link
Copy Markdown
Contributor Author

@coderabbitai fullreview

@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

@dagardner-nv I’ll start a full review of the PR.

Action performed

Full review finished.

@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The response decoder now preserves ToolUse when a later output item supplies another stop reason. The translation test checks the behavior with text and tool-call items in both orders.

Changes

Response Translation

Layer / File(s) Summary
Decode and verify stop reason
crates/switchyard-translation/src/codecs/responses/buffered.rs, crates/switchyard-translation/tests/response_translation.rs
The decoder preserves ToolUse when a later output item provides another stop reason. The test checks the decoded stop reason with text and tool-call items in both orders.

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

Merge Risk: Minimal · up to e25be

Buffered Responses output that contains a tool call followed by assistant text now reports a tool-use stop reason instead of ordinary completion. The change is small and tested in both item orders, so merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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.
Title check Passed The title names the change: the fix preserves the tool-use stop reason when decoding Responses output. The raw summary says decode_response keeps StopReason::ToolUse when a later output item supplies …
Full details: Title check

Explanation

The title names the change: the fix preserves the tool-use stop reason when decoding Responses output. The raw summary says decode_response keeps StopReason::ToolUse when a later output item supplies another stop reason, and the test checks ToolUse in both item orders. The title is specific and matches the main change, so it passes.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit checks the stops in line,
“ToolUse stays,” the tests confirm.
Text may hop before the call,
Or take its turn after all.
Both orders keep the reason fine.

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 287365f and e25be1c.

Files selected for processing: 2

  • crates/switchyard-translation/src/codecs/responses/buffered.rs
  • crates/switchyard-translation/tests/response_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.

@dagardner-nv dagardner-nv changed the title fix(translation): preserve buffered tool-use stop reasons fix(translation): preserve responses tool-use stop reasons Nov 13, 2026
@dagardner-nv
dagardner-nv marked this pull request as ready for review November 13, 2026 21:12
@dagardner-nv
dagardner-nv requested a review from a team as a code owner November 13, 2026 21:12
@grahamking
grahamking merged commit fcd2a4f into NVIDIA-NeMo:main Nov 13, 2026
24 checks passed
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