Repository navigation
feat: support code interpreter as gateway execution tool - #368
Conversation
Signed-off-by: haoshan98 <[email protected]>
Signed-off-by: haoshan98 <[email protected]>
Signed-off-by: haoshan98 <[email protected]>
Signed-off-by: haoshan98 <[email protected]>
maralbahari
left a comment
There was a problem hiding this comment.
Thanks for supporting this feature, it's really helpful and it follows the repo architecture nicely, cassettes included. Left some inline comments.
One general thing: the pluggable sandbox. In #308 (comment) we agreed this should be pluggable, but right now Eryx isn't a provider behind an interface, it is the implementation. A second sandbox (E2B, Firecracker, a container runner) means writing a whole new GatewayExecutor and redoing the OpenAI projection.
web_search already has the shape for this: the provider shapes the request and normalizes the response, the handler owns concurrency and the model-facing output. Same split here:
pub(crate) trait CodeInterpreterProvider: Debug + Send + Sync {
fn execute<'a>(
&'a self,
code: &'a str,
limits: &'a ExecutionLimits,
) -> Pin<Box<dyn Future<Output = Result<ExecutionOutput, ToolError>> + Send + 'a>>;
fn max_concurrent_executions(&self) -> Option<NonZeroUsize> { None }
fn check_ready(&self) -> Result<(), ToolError>;
}ExecutionOutput { status, stdout, stderr } already exists in the PR, so it's mostly moving code: plan_gateway_events / public_output / output_item onto the handler, Eryx into eryx.rs behind the feature.
This also cleans up the #[cfg]. Most of the 25 sites only exist because the field is typed on the concrete Eryx type. Use a dyn alias like WebSearchExecutor and 21 of them go away, leaving only mod embedded, its re-export, and the one construction site.
if you'd rather land the feature first. Your call.
Signed-off-by: haoshan98 <[email protected]>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Unresolved timeout, fail-closed, sandbox ownership, native event preservation, and history rehydration issues remain.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (3)
What changed in this PR
Adds an opt-in, Eryx-backed gateway code_interpreter with sandboxed execution, lifecycle events, streaming support, configuration, documentation, and tests.
Changes:
- Adds strict gateway tool normalization and execution controls.
- Integrates HTTP/SSE, WebSocket, scheduling, and native event handling.
- Adds runtime setup, OpenAPI coverage, CI, and characterization fixtures.
| File | Summary |
|---|---|
scripts/tests/setup-eryx-runtime-test.sh |
Tests runtime setup behavior. |
scripts/setup-eryx-runtime.sh |
Provisions the Eryx runtime. |
rust-toolchain.toml |
Pins the Rust toolchain. |
README.md |
Documents opt-in setup. |
mkdocs.yaml |
Registers design documentation. |
docs/design/tool-framework.md |
Updates tool architecture. |
docs/design/embedded-code-interpreter.md |
Documents implementation and limitations. |
docs/design/codex-integration.md |
Documents tool integration. |
crates/agentic-server/tests/responses_websocket_test.rs |
Tests WebSocket fail-closed behavior. |
crates/agentic-server/tests/responses_test.rs |
Tests HTTP validation. |
crates/agentic-server/src/openapi.rs |
Adds OpenAPI models. |
crates/agentic-server/src/main.rs |
Parses interpreter configuration. |
crates/agentic-server/src/config_file.rs |
Adds file-based configuration. |
crates/agentic-server/Cargo.toml |
Adds feature forwarding. |
crates/agentic-server-core/tests/support/mod.rs |
Supports new output items. |
crates/agentic-server-core/tests/code_interpreter_characterization_test.rs |
Validates recorded contracts. |
crates/agentic-server-core/tests/cassettes/record_code_interpreter_cassettes.sh |
Records characterization cassettes. |
crates/agentic-server-core/tests/cassettes/README.md |
Documents cassette workflows. |
crates/agentic-server-core/tests/cassettes/code_interpreter/prompts.txt |
Defines test prompts. |
crates/agentic-server-core/tests/cassettes/code_interpreter/openai_tools.json |
Defines OpenAI fixtures. |
crates/agentic-server-core/tests/cassettes/code_interpreter/gateway_tools.json |
Defines gateway fixtures. |
crates/agentic-server-core/tests/cassettes/code_interpreter/code-interpreter-openai-reference-gpt-5.6-streaming.yaml |
Stores streaming reference behavior. |
crates/agentic-server-core/tests/cassettes/code_interpreter/code-interpreter-openai-reference-gpt-5.6-nonstreaming.yaml |
Stores non-streaming reference behavior. |
crates/agentic-server-core/tests/cassettes/code_interpreter/code-interpreter-gateway-Qwen-Qwen3.6-35B-A3B-nonstreaming.yaml |
Stores gateway behavior. |
crates/agentic-server-core/src/types/tools/params.rs |
Defines strict request parameters. |
crates/agentic-server-core/src/types/tools/mod.rs |
Exports tool types. |
crates/agentic-server-core/src/types/tools/code_interpreter.rs |
Validates tool arguments. |
crates/agentic-server-core/src/types/request_response.rs |
Updates request fixtures. |
crates/agentic-server-core/src/types/mod.rs |
Re-exports new types. |
crates/agentic-server-core/src/types/io/output.rs |
Adds output-item integration. |
crates/agentic-server-core/src/types/io/mod.rs |
Exports IO models. |
crates/agentic-server-core/src/types/io/code_interpreter.rs |
Defines output and event models. |
crates/agentic-server-core/src/tool/registry.rs |
Registers gateway bindings. |
crates/agentic-server-core/src/tool/ownership.rs |
Updates ownership documentation. |
crates/agentic-server-core/src/tool/normalize.rs |
Normalizes gateway declarations. |
crates/agentic-server-core/src/tool/mod.rs |
Exposes tool modules. |
crates/agentic-server-core/src/tool/handler.rs |
Updates handler contracts. |
crates/agentic-server-core/src/tool/executors.rs |
Adds readiness-gated executors. |
crates/agentic-server-core/src/tool/code_interpreter.rs |
Implements Eryx execution and admission control. |
crates/agentic-server-core/src/lib.rs |
Re-exports public APIs. |
crates/agentic-server-core/src/executor/response_budget.rs |
Accounts for retained output. |
crates/agentic-server-core/src/executor/request.rs |
Updates configuration errors. |
crates/agentic-server-core/src/executor/rehydrate.rs |
Validates inherited declarations. |
crates/agentic-server-core/src/executor/pipeline/tests.rs |
Tests native lifecycle handling. |
crates/agentic-server-core/src/executor/gateway.rs |
Emits gateway lifecycle events. |
crates/agentic-server-core/src/executor/gateway_accumulator.rs |
Allocates event sequences. |
crates/agentic-server-core/src/executor/accumulator/tests.rs |
Tests output accumulation. |
crates/agentic-server-core/src/executor/accumulator/slot.rs |
Supports code-call slots. |
crates/agentic-server-core/src/executor/accumulator/completion.rs |
Merges completed calls. |
crates/agentic-server-core/src/executor/accumulator/active.rs |
Tracks active calls. |
crates/agentic-server-core/src/events/validate.rs |
Validates lifecycle events. |
crates/agentic-server-core/src/events/types.rs |
Adds event and item variants. |
crates/agentic-server-core/src/events/normalize.rs |
Normalizes event payloads. |
crates/agentic-server-core/src/config.rs |
Adds runtime limits. |
crates/agentic-server-core/Cargo.toml |
Adds optional Eryx dependencies. |
Cargo.toml |
Adds workspace dependencies. |
ARCHITECTURE.md |
Updates architecture guidance. |
.rust-file-sizes.json |
Records file-size allowances. |
.github/workflows/rust.yml |
Adds feature-enabled CI. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| let mode = std::fs::metadata(temp_dir) | ||
| .map_err(|_| ToolError::Config("code interpreter TMPDIR cannot be inspected".to_owned()))? | ||
| .permissions() | ||
| .mode() | ||
| & 0o777; | ||
| if mode != 0o700 { |
| Self::McpListTools(list_tools) => Some(InputItem::McpListTools(list_tools.clone())), | ||
| Self::Compaction(item) => Some(InputItem::Compaction(item.clone())), | ||
| Self::WebSearchCall(_) | Self::McpCall(_) | Self::Unknown => None, | ||
| Self::CodeInterpreterCall(_) | Self::WebSearchCall(_) | Self::McpCall(_) | Self::Unknown => None, |
| "crates/agentic-server-core/src/tool/code_interpreter.rs": { | ||
| "limit": 529, | ||
| "reason": "The dedicated Eryx executor keeps sandbox admission, cancellation, bounded output capture, and gateway execution lifecycle together." |
Signed-off-by: haoshan98 <[email protected]>
Signed-off-by: haoshan98 <[email protected]>
franciscojavierarceo
left a comment
There was a problem hiding this comment.
the latest patch fixes the done-only ID and public ID-format issues, but the remaining blockers are still unresolved: Eryx can bypass the configured output limits through raw WASI stdout/stderr; native code_interpreter_call items are dropped from continuation history; native image outputs are not represented and can disappear during ingestion; and TMPDIR validation does not reject symlinks or verify ownership. we need to close those paths before this is ready to merge.
Signed-off-by: haoshan98 <[email protected]>
Signed-off-by: haoshan98 <[email protected]>
Signed-off-by: haoshan98 <[email protected]>
Signed-off-by: haoshan98 <[email protected]>
Signed-off-by: haoshan98 <[email protected]>
Signed-off-by: haoshan98 <[email protected]>
|
@haoshan98 thanks my concerns have been addressed. looks good to me @franciscojavierarceo can you check the PR again? |
Signed-off-by: haoshan98 <[email protected]>
Signed-off-by: haoshan98 <[email protected]>
Signed-off-by: haoshan98 <[email protected]>
ARCHITECTURE.md described an application-provided ShellExecutor slot, GatewayExecutorRegistration::Shell, an opt-in gateway shell history projection, and a ShellHandler::model_input entry point that do not exist in the implementation. Shell remains client-executed: ShellHandler deliberately does not implement GatewayExecutor (PR vllm-project#264 removed the optional executor), and RFC vllm-project#352 tracks a possible gateway-executed shell backend as future work. Also refresh the GatewayExecutors slot list to include the opt-in Eryx-backed code interpreter executor added in PR vllm-project#368. Fixes vllm-project#353 Signed-off-by: LeaderOnePro <[email protected]>
ARCHITECTURE.md described an application-provided ShellExecutor slot, GatewayExecutorRegistration::Shell, an opt-in gateway shell history projection, and a ShellHandler::model_input entry point that do not exist in the implementation. Shell remains client-executed: ShellHandler deliberately does not implement GatewayExecutor (PR vllm-project#264 removed the optional executor), and RFC vllm-project#352 tracks a possible gateway-executed shell backend as future work. Also refresh the GatewayExecutors slot list to include the opt-in Eryx-backed code interpreter executor added in PR vllm-project#368. Fixes vllm-project#353 Signed-off-by: LeaderOnePro <[email protected]>
ARCHITECTURE.md described an application-provided ShellExecutor slot, GatewayExecutorRegistration::Shell, an opt-in gateway shell history projection, and a ShellHandler::model_input entry point that do not exist in the implementation. Shell remains client-executed: ShellHandler deliberately does not implement GatewayExecutor (PR vllm-project#264 removed the optional executor), and RFC vllm-project#352 tracks a possible gateway-executed shell backend as future work. Also refresh the GatewayExecutors slot list to include the opt-in Eryx-backed code interpreter executor added in PR vllm-project#368. Fixes vllm-project#353 Signed-off-by: LeaderOnePro <[email protected]>
## Summary Several user-facing docs had fallen behind `main` or contradicted each other and the code. This PR brings them in line with what has shipped. It changes documentation only. **Corrected claims** - README listed the Messages API as "🚧 Planned" while another README section documents `/v1/messages`. It is now listed as shipped; only stateful Messages stays planned. - README and `docs/index.md` advertised "Background execution" and gateway-executed file search. Neither exists yet: background mode is #357, and `file_search` declarations parse but are dropped before inference (`tool/normalize.rs`). Both claims are removed. - `docs/api/index.md` quoted fixed WebSocket and executor limits (256 KiB SSE lines, 1 MiB events and response budget). These now come from the configurable `[responses]` settings, which default to 16 MiB and 8 MiB. - `docs/api/index.md` listed only some of the conditions that route a Responses request through the executor. The list now also includes non-function tools, `multi_agent.enabled`, and tool-search state, matching `handler/http/responses.rs`. - CHANGELOG listed Tavily under 0.8.0, but it merged on Sep 28, after the Sep 19 release. The two Tavily entries move to `[Unreleased]`. **Newly documented features** - README: a multi-agent Responses section with an example and the gateway's limits (`store: true`, HTTP/SSE only, default of 3 concurrent subagents, no `max_tool_calls` or reasoning summaries). Also new rows in the API table for `/v1/responses/compact`, the full Conversations routes, `/v1/messages` with `/v1/messages/count_tokens`, and Swagger/OpenAPI (`ENABLE_OPENAPI_DOCS`). The features list, diagram, and tool ownership table now include MCP, the code interpreter, Claude Code, compaction, and OpenTelemetry. - `docs/api/index.md`: new sections for `GET /v1/responses/{response_id}`, multi-agent, Conversations, and Messages. - CHANGELOG `[Unreleased]` was empty. It now has entries for #345, #347, #349, #351/#370, #354, #368, #369, #372/#373, #380, and #387. **Roadmap** - ROADMAP.md marks multi-agent HTTP execution as shipped, with WebSocket injection (#300) and stateless requests (#393) still open. It adds a status note for Messages, a code interpreter entry, and a file search item linking #34 and #356. - README "Roadmap at a Glance" checks off Messages and Conversations and adds unchecked items for multi-agent, file search, and stateful Messages. **Smaller fixes** - The repository layout in README and AGENTS.md now lists `agentic-llm-d`, `agentic-cli-docs`, and `python/agentic_api/`. - ARCHITECTURE.md's list of multi-agent rejections now includes `max_tool_calls`, matching `executor/rehydrate.rs`. - `mkdocs.yaml` adds the existing but unlinked `design/shell-tool.md` to the nav. **Not changed:** the README's "Rust 1.85+" badge is wrong (1.85 cannot build the lockfile, see #377), but #379 already updates it to 1.88 along with `rust-version` and a CI check, so this PR leaves it alone to avoid a conflict. Signed-off-by: haoshan98 <[email protected]>
…401) ## Summary Aligns ARCHITECTURE.md with the implemented, client-executed shell tool (#353). - ARCHITECTURE.md described shell-executor interfaces that do not exist: an application-provided `ShellExecutor` slot, a `GatewayExecutorRegistration::Shell` execution grant, an opt-in gateway-executed shell history projection, and a `ShellHandler::model_input` entry point. Shell is client-executed only: `ShellHandler` deliberately does not implement `GatewayExecutor` (PR #264 removed the optional executor to keep execution on the client), and RFC #352 tracks the proposed gateway-executed shell backend as future work. - Rewrites the two shell passages (the `translate/` section and the `tool/` registry section) to describe the implemented flow: declarations normalize to canonical function tools, calls restore to `shell_call` and command SSE events, the client executes each call and submits `shell_call_output` with the same `call_id`, and shell history stays public in storage, lowering into function history through the standard output-to-input conversion plus typed input conversions. - Refreshes the `GatewayExecutors` slot list: MCP servers are the only lazily connected slot (configured clients and discovered handlers are cached by `server_label` across requests; request-declared servers connect afresh per request, their discovered handlers reused only within that request), alongside the shared `WebSearchHandler` and the opt-in Eryx-backed `CodeInterpreterExecutor` added in #368 (disabled by default). Adds `shell` to the client-owned tool list. Fixes #353 ## Test Plan - Documentation-only change; no code paths affected. - Verified every claim against the implementation: `GatewayExecutorRegistration` variants (`tool/executors.rs`), `ShellHandler` not implementing `GatewayExecutor` (`tool/shell.rs`), MCP client caching by `server_label` with fresh request-declared connections (`tool/executors.rs`), and shell history lowering (`types/io/input.rs`, `docs/design/shell-tool.md`). - `rg 'ShellExecutor|GatewayExecutorRegistration::Shell|ShellHandler::model_input|opt-in gateway executor' ARCHITECTURE.md` returns no matches. - `git diff --check` is clean and the diff touches only `ARCHITECTURE.md`. - Locally, `pre-commit run --files ARCHITECTURE.md` passes all hooks. Signed-off-by: LeaderOnePro <[email protected]>
### Summary Fixes #377, taking option 1 from the issue: raise the declared MSRV to what the locked dependencies need. The documented MSRV was 1.85, but nothing declared or checked it, and the committed `Cargo.lock` needs more: - The default build needs 1.88: `idna_adapter` 1.2.2 needs 1.86, `process-wrap` 9 (for `rmcp`'s stdio MCP transport) needs 1.87, and `home` 0.5.12 and `icu_*` 2.3 need 1.88. - The `embedded-code-interpreter` feature (#368) needs 1.98.1: `eryx` 0.8.0 declares it, and wasmtime and cranelift 48 need 1.95. `rust-toolchain.toml` is already pinned to 1.98.1 for that feature. Cargo expects `rust-version` to cover every feature, so the MSRV is 1.98.1: - `rust-version = "1.98.1"` in `[workspace.package]`, inherited by every crate, so older toolchains fail with a clear message. `clippy.toml`'s `msrv` matches it. - A new `msrv` CI job reads `rust-version` and fails if `clippy.toml` differs. It prepares the Eryx runtime, because the `eryx` build script needs it, then runs `cargo check --workspace --all-targets --all-features --locked` on that toolchain. - Every workflow toolchain pin is now 1.98.1. Jobs pinned to 1.98.0 had been running 1.98.1 only because `rust-toolchain.toml` overrode them. - The container now builds on cargo-chef 0.1.78 with Rust 1.98.1. It had been building with 1.96.0, because the image doesn't copy `rust-toolchain.toml`, so the new MSRV would have rejected it. cargo-chef publishes Rust 1.98 images only from 0.1.78. - The clippy suggestions enabled by the new MSRV are applied in a separate commit: `if let` chains, `is_none_or`, `as_chunks`, `Duration::from_mins` and `is_multiple_of`. No behavior changes. - The MSRV is updated in `AGENTS.md`, the README badge, the getting-started and container docs, and the embedded code interpreter design doc. That doc now says the toolchain pin and the MSRV are both 1.98.1. The provider-aware reasoning design doc no longer says an MSRV repair is pending. - The observability docs, `OtlpProtocol` and the unsupported-protocol startup error no longer blame the MSRV for the missing gRPC exporter. The error used to say "gRPC is unavailable below Rust 1.88"; it now says the exporter is not compiled in, matching the zstd compression error. - The website's copy of the observability page is a release snapshot that `refresh-site-docs.mjs` regenerates, so it is left for the next refresh. ### Test Plan ```bash # With the Eryx runtime prepared (./scripts/setup-eryx-runtime.sh): cargo +1.98.1 check --workspace --all-targets --all-features --locked # passes cargo +1.98.0 check --workspace --locked # refused: "agentic-* requires rustc 1.98.1" cargo clippy --workspace --all-targets --all-features --locked -- -D warnings # clean with msrv = "1.98.1" cargo clippy --workspace --all-targets --locked -- -D warnings # clean (default features) cargo fmt -- --check cargo test --workspace --locked # 2281 passed, 1 failed, 18 ignored (see below) uvx pre-commit run --from-ref upstream/main --to-ref HEAD # includes the file-size ratchet uvx --with-requirements docs/requirements.txt mkdocs build --strict ``` - Without the Eryx runtime, the all-features check stops in `eryx`'s build script ("Pre-compiled runtime (runtime.cwasm) not found"). The `msrv` job prepares the runtime the same way the `embedded-code-interpreter` job does, and shares its cache key. - The one test failure is `web_fetch::http::tests::the_deadline_bounds_a_slow_origin`. It fails the same way on unmodified `main` under the full suite and passes on its own; this PR doesn't touch `web_fetch`. - I dry-ran the job's version-reading step locally: both files read `1.98.1`. - Container: on the old base (cargo-chef 0.1.77, Rust 1.96.0), `cargo chef cook` is refused with "rustc 1.96.0 is not supported … requires rustc 1.98.1". On the new base, the Rust build stage completes, and both binaries run (`agentic-server 0.9.0`). My local Docker has no BuildKit, so CI's image build covers the later `COPY --chmod` step. - Default features alone would still build on 1.88. On `main` at 2026-09-30, `cargo +1.88.0 check --workspace --all-targets --locked` passed, and on today's `main` every locked dependency outside `eryx`'s tree still declares at most 1.88. The MSRV follows Cargo's expectation that `rust-version` covers every feature. - Rebased onto `main` `8b27941`. The clippy autofix commit was redone against current `main`. #427 removed the `provider-upstream` job, so that job's toolchain pin is gone too. ### Merging alongside #375 #375 (#340) also edits `.github/workflows/rust.yml`; whichever lands second keeps both changes. Under `msrv = "1.98.1"`, #375 must also pass clippy, which may need the same mechanical autofixes. --------- Signed-off-by: Zheng Lu <[email protected]>



Summary
code_interpretertool backed by Eryx 0.8.0. Accept the OpenAI SDK declaration{"type":"code_interpreter","container":{"type":"auto"}}and normalize it to a model-facing function with onecodeargument. Execution occurs in the gateway.code_interpreter_calllifecycle.code_interpreter_callitems, including image outputs and continuation history. Stored gateway calls retain private origin metadata so their public projection is not replayed alongside the model-facing function call and result.TMPDIR, delegated cgroup support, and a successful worker readiness probe. Add the source-based runtime setup script, configuration and design documentation, OpenAPI models, and recorder-generated reference and gateway cassettes.Containment limit: Eryx 0.8.0 still accumulates output internally, so retained-output limits do not cap its intermediate allocations. The worker cgroup contains post-attachment memory charges; raw WASI stdout and stderr go to
/dev/null. Small allocations before worker attachment remain charged to the gateway. Feature-enabled prebuilt releases still need runtime-artifact provenance and verification.Test Plan
cargo fmt -- --check,cargo check --locked --workspace --all-targets, workspace Clippy, feature-enabled Clippy, and all pre-commit hooks passed.6eee0e8.