fix(translation): reject lossy buffered responses - #274
Draft
bbednarski9 wants to merge 1 commit into
Draft
Conversation
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
This was referenced Aug 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Makes
LossyConversionPolicyeffective when encoding buffered LLM responses:of silently selecting one.
Reject, or emita diagnostic and retain their existing best-effort result under
AllowWithDiagnostics.target format cannot represent all of them.
long enough for target encoders to diagnose the loss.
Exact same-format replay remains the first path and returns the preserved
provider body unchanged.
Why
Before this change, strict loss detection applied to requests but several
buffered response paths silently discarded extra outputs or unsupported content.
For a routing integration such as #270, that could return a weakened
cross-protocol response instead of surfacing a translation failure while the
trusted fallback was still available.
Related: #192, #270
How tested
uv run ruff check .clean (N/A: Rust-only change)uv run mypy switchyardclean (N/A: Rust-only change)uv run pytest tests/green (N/A: Rust-only change)cargo test -p switchyard-translation --all-targetscargo test --workspace --all-targetscargo clippy --workspace --all-targets -- -D warningscargo fmt --all -- --checkgit diff --checkChecklist
snake_caseof the primary class. (N/A: no Python classes added.)switchyard/__init__.py.__all__if intended for downstream use. (N/A: no Python symbols added.)--helpupdated if customer-facing surface changed. (N/A: behavior is governed by the existing translation policy.)Signed-off-by: Your Name <email>) per the DCO.Notes for reviewers
separate preserved-event contract for same-protocol streaming.
AllowWithDiagnosticsremains theexplicit opt-in for best-effort conversion.
in-memory preservation. If preservation is disabled, strict encoding rejects
them because the current neutral
Unknownblock cannot prove whether raw JSONoriginated at the output-item level or inside message content.
while feat(relay): add Switchyard-owned HTTP dynamic plugin #270 converts the resulting finalization error into its existing
exactly-once trusted-fallback flow.