Repository navigation
refactor: restructure into 3-crate workspace per ADR-03 - #29
Conversation
Restructure the flat crate into a Cargo workspace with three crates: - agentic-core: framework-agnostic library (proxy logic, config, error, readiness). No axum/clap/tower dependencies. - agentic-server: axum binary with CLI, thin handler adapter, server lifecycle, and vLLM subprocess management. - agentic-praxis: stub for future Praxis gateway adapter. Rename vllm_* identifiers to llm_* throughout for gateway-agnostic naming. All existing tests and benchmarks migrate to agentic-server with updated imports. Signed-off-by: Sébastien Han <[email protected]>
- Add tracing::warn for LLM timeout, connection, and body-read errors - Use append instead of insert for multi-value header forwarding - Set content-type on error responses - Add 900s timeout on stream client to prevent infinite hangs - Use PAYLOAD_TOO_LARGE (413) instead of BAD_REQUEST for body size - Deduplicate CLI args into shared CommonArgs struct - Move bytes/futures/reqwest to dev-dependencies in agentic-server Signed-off-by: Sébastien Han <[email protected]>
Update the placeholder comment to reflect ADR-03's direction: multiple HttpFilter implementations (one per core function) composed into a Praxis filter chain with branch support for tool-call looping. Signed-off-by: Sébastien Han <[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]>
|
@ashwing thanks for the review, i'd be happy to discuss some of your followup items in issues, thanks! |
| repository.workspace = true | ||
|
|
||
| [dependencies] | ||
| agentic-core = { path = "../agentic-core" } |
There was a problem hiding this comment.
I think we could use agentic-core.workspace = True
similar to https://github.com/vllm-project/vllm/blob/e1814f822d51225e0c6240386d65b2182758c2a4/rust/src/server/Cargo.toml#L35-L39
|
@leseb thank you for the PR. |
| @@ -0,0 +1,75 @@ | |||
| use agentic_core::config::Config; | |||
| use agentic_core::error::Error; | |||
| use agentic_core::proxy::ProxyState; | |||
There was a problem hiding this comment.
I think the proxy should be in agentic-server? basically the agentic-server should handle setting up gateway to vllm-server/LLM-server right and agentic loop is handled in agentic-server?
so basically users would only need to run agentic-server and it will be our means of communication and http requests between LLM server and parsing events to either call agentic-core or agentic-praxies?
| #[error("vLLM subprocess exited before becoming ready: {status}")] | ||
| VllmProcessExited { status: String }, | ||
| #[error("LLM subprocess exited before becoming ready: {status}")] | ||
| LlmProcessExited { status: String }, |
There was a problem hiding this comment.
let's separate out the error that is related to agentic-server to there. since agentic-server would be setting up the gateway so some of the errors would belong to server only. IO error can stay here. what do you think?
| #[arg(long, default_value_t = 2.0)] | ||
| pub vllm_ready_interval_s: f64, | ||
| pub llm_ready_timeout_s: f64, | ||
| pub llm_ready_interval_s: f64, |
There was a problem hiding this comment.
Similar to errors.rs let's only keep in config that agentic-core would need.
I think as off now agentic-core wouldnt need any config till we setup database and the rest of the features in core.
There was a problem hiding this comment.
I think a timeout is a rational config and having a config for the runtime feels okay but that's just my opinion
| /// # Errors | ||
| /// | ||
| /// Returns an error if the LLM does not become ready within the configured timeout. | ||
| pub async fn wait_llm_ready(config: &Config) -> Result<(), Error> { |
There was a problem hiding this comment.
so if agentic-server handles the gateway and proxy setup to either use pure proxy and agentic-core or setup the agentic-praxies we wouldn't need this file?
we can keep agentic-core independence from gateway setup. it solely focuses on core features.
the entrypoint and agentic loop start can be part of agentic-server where it decides to dispatch use praxies or core.
let me know your thoughts. I am not sure what I'm suggesting is the best choice.
i think we discussed it in another pr but this is not how the broad rust ecosystem is doing things, crates/ is the Rust community standard for workspace members (ripgrep, bevy, nushell, deno all use it). vllm uses rust/src/ because Rust is a secondary language in that repo. the crates live inside a Python project. In our repo, Rust is the primary language, so crates/ is idiomatic. Also, src/ would be confusing since each crate already has its own src/ directory. |
cool .. I might have missed that. thanks for clarifying . |
franciscojavierarceo
left a comment
There was a problem hiding this comment.
i'm going to follow up on @maralbahari's feedback so she can incorporate this into #33
## Summary Add liveness (`GET /health`) and readiness (`GET /ready`) endpoints to the gateway, enabling proper orchestration under Kubernetes, ECS, and docker-compose. - `/health` returns `200 OK` unconditionally when the process is listening (liveness probe) - `/ready` probes the LLM backend's `/health` with a 2-second timeout and returns `200` if healthy, `503 Service Unavailable` otherwise (readiness probe) This separates "is the gateway process alive?" from "is the system ready to serve traffic?" — standard for any load-balanced deployment. Closes #31 ## Related - Follow-up from [PR #29 review comment](#29 (review)) — @leseb acknowledged as a sensible follow-up - Pattern aligned with [vllm#36960](vllm-project/vllm#36960) (vLLM health endpoint conventions) ## Changes | File | Change | |------|--------| | `crates/agentic-server/src/handler.rs` | `health()` and `ready()` handler functions | | `crates/agentic-server/src/app.rs` | Route registration for `/health` and `/ready` | | `crates/agentic-server/Cargo.toml` | Add `reqwest` runtime dependency (for backend probe) | | `crates/agentic-server/tests/health_test.rs` | 4 integration tests | ## Test Plan **Automated (4 integration tests):** - `test_health_returns_200` — gateway up, LLM up → 200 - `test_health_returns_200_even_when_llm_down` — gateway up, LLM unreachable → 200 (liveness unaffected) - `test_ready_returns_200_when_llm_healthy` — LLM responds on `/health` → 200 - `test_ready_returns_503_when_llm_unreachable` — LLM unreachable → 503 All pass via `cargo test --workspace`. **Manual (live vLLM backend):** Built the gateway on an EC2 g6e.48xlarge instance and pointed it at a running vLLM server (port 8000): ``` $ curl -w '%{http_code}' http://localhost:9090/health 200 $ curl -w '%{http_code}' http://localhost:9090/ready 200 ``` **Lint/format:** - `cargo clippy --workspace --all-targets -- -D warnings` — clean - `cargo fmt -- --check` — clean --------- Signed-off-by: Ashwin Giridharan <[email protected]>
## Summary - Moves `proxy.rs`, `readiness.rs`, `config.rs`, and `error.rs` from `agentic-core` to `agentic-server` — these are gateway-specific concerns, not framework-agnostic core abstractions - Renames `Config` → `GatewayConfig` to clarify the struct's scope - Migrates all crate `Cargo.toml` files to use `[workspace.dependencies]` declarations - Addresses feedback from @maralbahari on #29 ## Test Plan - [x] `cargo build` — clean - [x] `cargo test` — 25/25 pass - [x] `cargo clippy --all-targets -- -D warnings` — clean - [x] `cargo fmt -- --check` — clean 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Francisco Javier Arceo <[email protected]> Co-authored-by: Claude Opus 4.6 <[email protected]>
## Summary This will be part of `agentic-core` after #29 merged will open for review Integrated complete SQLx-based storage layer for persistent conversation and response management. Implements trait-based CRUD operations with connection pooling supporting SQLite, PostgreSQL, and MySQL. Two main stores (`ConversationStore` and `ResponseStore`) handle persisting input/output items with metadata and rehydrating full conversation/response history from database. **Features:** - Database connection pooling with optional URL configuration (defaults to SQLite) - `ConversationStore`: persist turns with items and responses, rehydrate full conversation history - `ResponseStore`: persist responses with items and metadata, rehydrate by response ID - Schema migrations and initialization via `SchemaManager` - Type-safe database models with sqlx `FromRow` derive ## Test Plan **Unit tests (39 passing):** - Model CRUD operations, schema initialization, type conversions, error handling - IO conversion from data types resulted from database models to Rust data types. **Integration tests (18 passing):** - Store-level CRUD, error handling for disabled/missing resources - Multi-turn conversations with response chaining - Concurrent operations, foreign key constraints, edge cases **Benchmarks:** - `conversation_persist`: measure insertion of items and response records - `response_persist`: measure response creation with item tracking - `conversation_rehydrate`: measure full conversation retrieval from database - `response_rehydrate`: measure response history lookup by ID All tests pass. No clippy warnings. ## Running Benchmarks To run the storage CRUD benchmarks: ```bash cargo bench -p agentic-core --bench storage_crud ``` Or run with specific sample count and target time: ```bash cargo bench -p agentic-core --bench storage_crud -- --sample-size 100 --warm-up-time 3.000 s ``` ## Benchmark Results ``` Benchmarking conversation_persist conversation_persist time: [1.4119 ms 1.4390 ms 1.4663 ms] Benchmarking response_persist response_persist time: [893.67 µs 908.53 µs 923.55 µs] Benchmarking conversation_rehydrate conversation_rehydrate time: [1.4377 ms 1.4701 ms 1.5037 ms] Benchmarking response_rehydrate response_rehydrate time: [1.0061 ms 1.0270 ms 1.0488 ms] ``` ### Performance Notes **Response persist is ~1.5x faster than conversation persist** because: - `ResponseStore.persist()` stores `history_item_ids` directly in the responses table (single lookup) - `ConversationStore.persist()` must query the items table to determine the next sequence number for conversation items (additional query) --------- Signed-off-by: maral <[email protected]> Co-authored-by: Claude Haiku 4.5 <[email protected]>
Summary
Restructures the flat single-crate layout into a Cargo workspace with three crates per ADR-03:
proxy_request()as a composable building block.clap), server lifecycle, vLLM subprocess management.Built on top of PR #24's proxy gateway code (cherry-picked with full commit history). Renames
vllm_*identifiers tollm_*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— cleancargo fmt -- --check— cleancargo bench -p agentic-server --no-run— benchmarks compile