Skip to content

refactor: restructure into 3-crate workspace per ADR-03 - #29

Merged
franciscojavierarceo merged 6 commits into
vllm-project:mainfrom
leseb:leseb/adr-3-v1
May 28, 2026
Merged

franciscojavierarceo merged 6 commits into
vllm-project:mainfrom
leseb:leseb/adr-3-v1

Conversation

@leseb

@leseb leseb commented May 19, 2026

Copy link
Copy Markdown
Collaborator

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

@leseb

leseb commented May 19, 2026 •

Copy link
Copy Markdown
Collaborator Author

draft because this is on top of #24 and implements proposed ADR in #28

@ashwing ashwing left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been following this refactor and ADR-03 closely — with #24 and #28 now merged, this looks ready to land. Left a few observations while the code is fresh; nothing blocking, mostly forward-looking questions and one small gap I'd be happy to contribute as a follow-up.

Comment thread crates/agentic-server/src/app.rs Resolved
Comment thread crates/agentic-core/src/proxy.rs Resolved
leseb added 5 commits May 27, 2026 09:26
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]>
@leseb
leseb force-pushed the leseb/adr-3-v1 branch from c5cf4ab to bec31f3 Compare May 27, 2026 07:27
@leseb
leseb marked this pull request as ready for review May 27, 2026 07:28
@leseb

leseb commented May 27, 2026

Copy link
Copy Markdown
Collaborator Author

@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" }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do - thanks

@maralbahari

Copy link
Copy Markdown
Collaborator

@leseb thank you for the PR.
I think we can rename crates folder to src so the agentic-api/src is not left empty
I think we should follow the rust frontend based on vllm https://github.com/vllm-project/vllm/tree/main/rust/src
while each module is maintaining its own crate package like vllm-tokenizer, vllm-chat, etc but there's still under same source.

@@ -0,0 +1,75 @@
use agentic_core::config::Config;
use agentic_core::error::Error;
use agentic_core::proxy::ProxyState;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 },

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree with this @leseb can we revise?

#[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,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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> {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@leseb

leseb commented May 28, 2026

Copy link
Copy Markdown
Collaborator Author

@leseb thank you for the PR. I think we can rename crates folder to src so the agentic-api/src is not left empty I think we should follow the rust frontend based on vllm https://github.com/vllm-project/vllm/tree/main/rust/src while each module is maintaining its own crate package like vllm-tokenizer, vllm-chat, etc but there's still under same source.

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.

@maralbahari

Copy link
Copy Markdown
Collaborator

@leseb thank you for the PR. I think we can rename crates folder to src so the agentic-api/src is not left empty I think we should follow the rust frontend based on vllm https://github.com/vllm-project/vllm/tree/main/rust/src while each module is maintaining its own crate package like vllm-tokenizer, vllm-chat, etc but there's still under same source.

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 franciscojavierarceo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm going to follow up on @maralbahari's feedback so she can incorporate this into #33

@franciscojavierarceo
franciscojavierarceo merged commit f82ec73 into vllm-project:main May 28, 2026
3 checks passed
franciscojavierarceo pushed a commit that referenced this pull request May 29, 2026
## 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]>
maralbahari pushed a commit that referenced this pull request May 29, 2026
## 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]>
@leseb
leseb deleted the leseb/adr-3-v1 branch May 29, 2026 07:51
franciscojavierarceo pushed a commit that referenced this pull request Jun 2, 2026
## 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants