feat: Move libsy::algorithm::run to libsy-llm-client (#324)
`libsy` previously had two entrypoints: - `run_stream`, the main one - `run`, which wrapped `run_stream` and used `libsy-llm-client` to make actual calls. `run` is a convenience many callers will want. It relies entirely on `libsy-llm-client`. This PR moves `run` into `libsy-llm-client`. That's it. There's now no `default_client` in `libsy`. It never makes any calls. The crate dependency runs `libsy-llm-client` -> `libsy`. The key change in `switchyard-server` is this: - Before: `algorithm.run_observed(..)`. `algorithm` is an instance of `Algorithm` trait. - Now: `switchyard_llm_client::run(..)`. Notice the `::`. The bulk of the PR is moving code so it's large but a small delta. It's mostly mechanical. Internally `libsy` now has a `drive` function that does most of what `run` did (iterating the stream), without the HTTP client calls. `libsy_llm_client::run` calls `drive` with a set of real HTTP clients (`TranslatingLlmClient`). It dispatches the `CallLlm` to the correct client. The leaves the machinery in `libsy::drive`, but the user-facing piece with a fully feature LLM client is in `libsy-llm-client`. Some `libsy` integration tests relied on `libsy-llm-client`, so they now live in `libsy-llm-client`. Observation / metrics that relied on knowing host / port and so on also moved to `libsy-llm-client` (`libsy` doesn't know about these things). To review start with `crates/switchyard-server/src/lib.rs` to see the point of the change. Key parts are: 1. `switchyard-server/src/lib.rs` `handle_llm_request` line 768. Uses the moved code, so it shows what PR is doing. Good to orient with that. 2. `libsy-llm-client/src/run.rs` `run` line 37. This is where `run_observed` moved to. That handles the RoutedLlmClient stuff, and calls libsy to iterate the stream. It plugs together quite nicely (`drive(serve(..))`). 3. `crates/libsy/src/core/algorithm.rs` `drive` line 329. That iterates `run_stream`, and we're back! Part of https://github.com/NVIDIA-NeMo/Switchyard/issues/310 Assisted-by: Claude:Opus 5 medium Signed-off-by: Graham King <grahamk@nvidia.com>
G
Graham King committed
74b8990543935670763331c64df293c85be93be7
Parent: 9d7cea4
Committed by GitHub <noreply@github.com>
on 8/7/2026, 4:53:37 PM