fix(translation): reject unsupported native Responses output - #788
Conversation
Signed-off-by: nachiketb <nachiketb@nvidia.com>
|
Validated SWITCH-1471 against unmodified main The HTTP reproduction used a real Switchyard server and a deterministic loopback Responses provider. It covered
Streaming HTTP headers can already be committed before the unsupported item arrives, so those responses remain HTTP 200 and signal failure through the terminal SSE error. The check asserts that no successful completion follows it. The single new test also covers preservation disabled, separate buffered decode/encode, both stream entry points, output arriving after partial text, incomplete snapshots, and exact same-format replay. It failed before the production fix and now passes. Existing controls confirm normal function/custom-tool output, response preservation, terminal snapshot recovery, and #729's built-in request history. All 13 targeted tests passed: cargo test -p switchyard-translation --locked --test response_translation responses_native_output_is_preserved_or_rejected -- --exact
cargo test -p switchyard-translation --locked --test request_translation responses_builtin_tool_history
cargo test -p switchyard-translation --locked --test stream_translation preserved_
cargo test -p switchyard-translation --locked --test stream_translation responses_terminal_snapshots_recover_missing_output_once -- --exact
cargo test -p switchyard-translation --locked --test stream_translation responses_function_call_stream_ends_with_tool_use_on_every_wire -- --exact
cargo test -p switchyard-translation --locked --test stream_translation responses_decode_emits_tool_arguments_once -- --exact
cargo test -p switchyard-translation --locked --test response_translation responses_custom_tool_call_output_round_trips_with_request_extensions -- --exact
cargo test -p switchyard-translation --locked --test response_translation responses_reasoning_and_message_preserve_the_final_answer -- --exact
cargo test -p switchyard-translation --locked --test lossless_roundtrip embedded_preservation_roundtrips_responses_for_every_source_target_pair_exactly -- --exact
cargo test -p switchyard-translation --locked --test lossless_roundtrip embedded_preservation_survives_every_distinct_three_format_response_cycle -- --exact
|
What
Reject translation of native Responses
apply_patch_call,shell_call,computer_call, andimage_generation_calloutput to Chat or Anthropic. Buffered requests return an unsupported-translation error; streams emit a terminal error instead of a normal successful stop.Keep the native buffered items in the existing opaque content representation so Responses re-encoding can retain their payload and identity. Check retained stream events before they are discarded, including output found only in completed or incomplete snapshots.
Why
Fixes SWITCH-1471. These provider outputs are currently skipped, leaving clients with an empty successful response and no action or image. The ticket explicitly accepts an unsupported-translation error. #729 addressed request history; this fixes provider output.
Notes for reviewers
88 added production lines and one regression test. The checks live in the translation crate and use existing content and error types. Responses passthrough and ordinary function/custom-tool translation are covered by controls.
Validation:
cargo fmt --all --check, andcargo clippy --workspace --all-targets --locked -- -D warningspassed.No full test suite or live provider calls were run. No returned tools were executed.
Summary by CodeRabbit
New Features
Bug Fixes