Repository navigation
feat: implement Rust proxy gateway for vLLM Responses API - #24
maralbahari merged 9 commits into
Conversation
Replaces the Python gateway stub with a full Rust implementation using axum, reqwest, and tokio. Supports both streaming (SSE) and non-streaming proxy modes, hop-by-hop header filtering, API key injection, and comprehensive error mapping (502/504). Includes 11 tests covering passthrough, auth, streaming, error propagation, mid-stream failure, connection errors, and timeouts. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: Sébastien Han <[email protected]>
Derive clap::Args on RuntimeConfig directly and use #[arg(skip)] for llm_api_base, eliminating the duplicate GatewayOpts struct and the manual build_config mapping function. Addresses review feedback from @maralbahari. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: Sébastien Han <[email protected]>
|
@leseb I was wondering if we should validate that the library choices are optimal and verify stateless proxy throughput/latency against the Python baseline. When I was working on translating Python to Rust, I noticed some performance regression compared to the Python baseline, so I thought it would be best to try and avoid such regressions from the start. |
Introduces a proper Error enum via thiserror, replacing Box<dyn std::error::Error> across the library. ProxyState::new now returns Result instead of panicking on HTTP client build failure. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: Sébastien Han <[email protected]>
Can you share more? I'll add a criterion benchmarks |
Measures proxy latency overhead by comparing direct upstream requests against proxied requests for both non-streaming and streaming (SSE) paths. Establishes a baseline for regression detection. Results on Apple M-series: non_stream/direct: ~65 µs non_stream/proxied: ~133 µs (68 µs overhead) stream/direct: ~91 µs stream/proxied: ~462 µs (371 µs overhead) Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: Sébastien Han <[email protected]>
Replaces generic "upstream" terminology with "vllm" to make it clear what the gateway is proxying to. Affects config fields, error variants, function names, variables, and test helpers. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: Sébastien Han <[email protected]>
Signed-off-by: Sébastien Han <[email protected]>
Signed-off-by: Sébastien Han <[email protected]>
|
@maralbahari any thoughts here? |
Captures the three-layer crate design (core library, axum server, thin gateway adapters) and key architectural decisions: - Agentic loop as explicit state machine, not proxy filters - No Python (OGX) in core request paths - Praxis routes to agentic-api as a backend service - Standalone mode is first-class - Gateway adapters are thin (one filter per gateway) Shapes PR vllm-project#24 as the foundation for agentic-core/agentic-server. Supersedes PR vllm-project#27's filter-based decomposition approach. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: Sébastien Han <[email protected]>
1cff48f to
a1ebe54
Compare
- Add note about superseding ADR-01 language decision (D3) - Remove axum from Layer 3 diagram (it belongs in Layer 2) - Soften PR vllm-project#27 language to "if accepted" - Clarify PR vllm-project#24 relationship as forward-looking Signed-off-by: Sébastien Han <[email protected]>
| use agentic_api::config::RuntimeConfig; | ||
| use agentic_api::proxy::ProxyState; | ||
|
|
||
| pub fn test_config(vllm_url: &str) -> RuntimeConfig { |
There was a problem hiding this comment.
after reading the official rust documentation examples. The isolated unit tests that are verifying a single module in this case the RuntimeConfig struct in config we should implement the test into the same file as source code in src/config.rs so the test_config_no_key() and test_config cases should move there. you can look at the example here from documentation.
while the tests/ folder is used for integration tests where you would need to test multiple modules relying on each other for an integration case. and test/common/mod.rs use to keep the common setup in this file
like make_runtime_config() make_response_handler(). but I think for this proxy feature we don't need a integration tests as proxy is the single module.
There was a problem hiding this comment.
fair point, i'll remove the integration tests since it's too much of mocking anyways and not using a real vllm server, i'll add more unit tests
Replaces the integration test harness (fake axum servers, TCP listeners, full HTTP round-trips) with direct unit tests on the proxy functions: header filtering, auth injection, SSE detection. Tests the same logic without the overhead of spawning servers and making real HTTP calls against mocks. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: Sébastien Han <[email protected]>
|
Test plan: Run vLLM: Check it's healthy: Check status code: Build the project: Run it: Test a request: |
## Summary Restructures the flat single-crate layout into a Cargo workspace with three crates per ADR-03: - **agentic-core**: framework-agnostic library — proxy logic, config, error types, LLM readiness. No axum/clap/tower dependencies. Exposes `proxy_request()` as a composable building block. - **agentic-server**: standalone axum binary — thin handler adapter, CLI (`clap`), server lifecycle, vLLM subprocess management. - **agentic-praxis**: stub for future Praxis gateway adapter. Built on top of PR #24's proxy gateway code (cherry-picked with full commit history). Renames `vllm_*` identifiers to `llm_*` for gateway-agnostic naming. Includes improvements to error logging, multi-value header forwarding, and CLI arg deduplication. ## Test Plan - `cargo test --workspace` — 16 tests pass (7 unit in agentic-core + 9 integration in agentic-server) - `cargo clippy --workspace --all-targets -- -D warnings` — clean - `cargo fmt -- --check` — clean - `cargo bench -p agentic-server --no-run` — benchmarks compile --------- Signed-off-by: Sébastien Han <[email protected]>
Summary
--llm-api-base) and integrated (serve <model>spawning vLLM as a subprocess)config,proxy,app,servermodules with a clean separation of concernsTest Plan
cargo test(11/11 green)cargo clippy --all-targets -- -D warningscargo fmt -- --check🤖 Generated with Claude Code