fix(translation): return HTTP 502 for buffered Chat abort and error finish reasons - #884
colinmcnamara wants to merge 1 commit into
Conversation
…inish reasons Signed-off-by: Colin McNamara <colin@2cups.com>
|
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 configurationConfiguration used: Repository: NVIDIA-NeMo/Switchyard/.coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review. WalkthroughThe OpenAI Chat decoder now treats ChangesOpenAI Chat Finish-Reason Handling
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The change implements the intended failure and fallback behavior for buffered Chat responses. Discarding partial abort text is intentional; no actionable merge-blocking risk remains in the supplied evidence. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
A rabbit checks the finish sign, Comment |
What
A non-streaming OpenAI Chat response now fails when
choices[0].finish_reasonis"abort"or"error". Decode returnsUpstreamFailure, the same path #703 uses for a Responses body withstatus: "failed". The server answers HTTP 502 with the finish reason in the message, and a route with another target tries it.Fixes #876
Why
These reasons map to
StopReason::Unknowntoday, which Anthropic clients receive asend_turnand Responses clients ascompleted. A cut-off or failed answer looks complete, and fallback never runs. Details and captured bodies are in the issue.Notes for reviewers
Start at
OpenAiChatCodec::decode_responseinopenai_chat/buffered.rs: one guard after the body is parsed. Tests: one translation test, and one server test next to #703'sfailed_responses_return_errors_and_try_fallback_across_endpoints.finish_reasonabort/errorend_turnabort/errorcompletedabort/errorabort/error, route with another targetabortbody for Chat clients; the issue asks whether that trade is wanted.choices[0]. When a request asks for more than one choice, anabortorerroron a later choice still looks successful.errorobject, with a guard at the same spot. Whichever lands second needs a small rebase, and the combined guard should check fix(translation): return HTTP 502 for Chat and Anthropic error bodies #855'serrorobject first, so the provider's message wins.repetitionstill maps toUnknown.Checks run on this commit, with CI's commands:
cargo fmt --all --check;cargo clippy --workspace --all-targets --locked -- -D warnings(pinned 1.96.1);cargo clippy -p switchyard-server --all-targets --features prefill-router --locked -- -D warnings;cargo test --workspace --locked(893 passed, 0 failed);cargo test -p switchyard-runner --features prefill-router --locked(66 passed). The two new tests fail onabf90180.Test run
AI tools helped me trace the code, run the tests and review this change.
Summary by CodeRabbit