feat(plugin): add NeMo Relay run-stream dynamic plugin - #220
Draft
bbednarski9 wants to merge 19 commits into
Draft
feat(plugin): add NeMo Relay run-stream dynamic plugin#220bbednarski9 wants to merge 19 commits into
bbednarski9 wants to merge 19 commits into
Conversation
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
…replay Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
…al event Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
Keep preservation on TranslationEngine, the API consumed by NVIDIA/NeMo-Relay#586, and remove the unused built-in convenience decoder. Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
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
Adds
switchyard-nemo-relay-plugin, an external NeMo Relay native dynamic plugin that drives Switchyard algorithms throughlibsy::Algorithm::run_stream.The plugin:
nemo-relay-plugin, while the C ABI remains the binary boundary;switchyard-translation;CallLlmsemantic target and invokes Relay withLlmContinuationV2::call()orLlmStreamContinuationV2::open_stream();ReturnToAgent;Passthrough(request)outcome for unmanaged streams, so provider events remain inside Relay's bounded host path; andThe migration removes the plugin's 479-line generic FFI layer: no raw host table, opaque pointer, manual host-string allocation, callback-to-future bridge, stream pump, completion settlement, or release function remains in Switchyard.
Switchyard owns routing, translation, target binding, credentials, retry, and fallback policy. Relay core owns targeted HTTP(S)/JSON/SSE transport, downstream middleware execution, scopes, bounded stream forwarding, cancellation, and observability export.
The crate is a source/build unit (
cdylib+rlib,publish = false). The operator-facing artifact remains a release bundle containing the shared library, manifest, schema, license notices, and digest.Why
A selection-only decision API cannot express classifiers or future policies that transform requests, make one or more LLM calls, inspect results, and select the final response.
run_streamprovides that lifecycle while leaving provider dispatch under Relay's control.Relay's raw C ABI can represent the lifecycle, but requiring each Rust policy plugin to reproduce unsafe callbacks and ownership logic is error-prone and obscures the actual Switchyard integration. NVIDIA/NeMo-Relay#594 now provides safe Rust continuations over that ABI and a host-owned streaming pass-through path. This PR consumes that general SDK surface rather than maintaining Switchyard-specific FFI glue.
This PR is stacked on and depends on #192, which preserves raw same-protocol provider events through the required
Relay -> libsy -> Relayround trip. It also depends on NVIDIA/NeMo-Relay#594 and pins its SDK commit to54452966e9c12065cf77ac3426ee81198a6658b0until a compatible Relay SDK is published.Related: NVIDIA/NeMo-Relay#594
How tested
cargo test -p switchyard-nemo-relay-plugin— 9 passed.cargo clippy -p switchyard-nemo-relay-plugin --all-targets -- -D warnings.cargo fmt --all -- --check.uv run ruff check crates/switchyard-nemo-relay-plugin/tests/e2e.The repository-wide Rust workspace run still reaches the existing macOS
switchyard-pyunresolved-Python-symbol link failure. Focused touched-crate validation and the cross-repository process path pass.Checklist
snake_caseof the primary class (not applicable to the Rust crate; Python helpers followsnake_case).switchyard/__init__.py.__all__if intended for downstream use (no Python public symbols added).--helpupdated if customer-facing surface changed.Signed-off-by: Your Name <email>) per the DCO.Notes for reviewers
flowchart LR A["Caller request"] --> B["Relay LLM pipeline"] B --> C["Safe Switchyard v2 callback"] C --> D["switchyard-translation decode"] D --> E["libsy run_stream"] E --> F["CallLlm"] F --> G["Safe continuation call / open_stream"] G --> H["Raw C ABI boundary"] H --> I["Remaining Relay LLM middleware"] I --> J["Relay core HTTP JSON / SSE transport"] J --> K["Selected provider"] K --> L["Response, provider stream, or typed failure"] L --> G G --> M["CallLlmRequest.respond"] M --> E E --> N["ReturnToAgent"] N --> O["switchyard-translation encode"] O --> A C -->|"unmanaged stream"| P["Passthrough(request)"] P --> IPlease focus review on:
src/lib.rs: safe registration and complete removal of raw callback state;src/runtime.rs: typed continuations, boxed output stream, pre-commit retry/fallback, and post-commit failure behavior;Intentional constraints: