Skip to content

rust: add Responses web-service sample#785

Open
MaanavD wants to merge 6 commits into
mainfrom
agents/rust-responses-web-service-sample
Open

rust: add Responses web-service sample#785
MaanavD wants to merge 6 commits into
mainfrom
agents/rust-responses-web-service-sample

Conversation

@MaanavD

@MaanavD MaanavD commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds a Rust Responses web-service sample, a matching SDK example, and integration tests. The sample, example, and tests talk to a running local Foundry Local instance over raw HTTP against the OpenAI-compatible /v1/responses endpoint — mirroring the merged Python samples/python/web-server-responses sample. No SDK-native Responses client is added.

What's included

  • samples/rust/web-server-responses/ — new standalone sample (Cargo.toml, README.md, src/main.rs) demonstrating the Responses API (including streaming and tool calling) against the local web service.
  • samples/README.md, samples/rust/README.md, samples/rust/Cargo.toml — register the new workspace member and update the sample catalog.
  • sdk/rust/examples/responses_web_service.rs — new SDK example that locates the local web service and calls /v1/responses via raw HTTP (reqwest).
  • sdk/rust/Cargo.toml — wire up the new example and enable the reqwest stream feature for streaming responses.
  • sdk/rust/tests/integration/{main.rs,responses_test.rs} — integration coverage for the Responses web service (skips in CI and when the model isn't cached).

Why a new PR

Supersedes #682. That PR's head branch lived on a fork, which blocks CI/Vercel. This branch lives on the microsoft remote (agents/rust-responses-web-service-sample) so CI and Vercel checks can run. The branch is updated to current main via git merge (no rebase, no force-push).

Validation (local, Windows)

  • cargo build — ✓
  • cargo clippy --all-targets -- -D warnings — ✓ (clean)
  • cargo test --lib — ✓ (19 passed)
  • cargo check -p web-server-responses — ✓
  • cargo clippy -p web-server-responses — ✓
  • Integration tests require a running Foundry Local plus a cached model, so they skip locally and in CI.

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

MaanavD and others added 6 commits May 1, 2026 16:23
Implements the HTTP Responses API client, wire types, SSE streaming parser, manager factory, tests, and example for the Rust SDK.

Also aligns the Rust implementation with resolved Responses API review feedback: opt-in storage, request timeouts, image source validation, optional media type, list pagination fields, get_responses_client naming, and server-matching streaming event shapes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Make responses_client/responses_types modules private; expose only the re-exported public surface (matching audio_client/chat_client/etc).

- Introduce ResponseCreateOptions for per-call overrides so callers no longer need to materialize a full ResponseCreateRequest; ResponseCreateRequest stays as the wire-serialized request body.

- Move SSE parser tests inline into responses_client.rs so they exercise parse_sse_stream directly instead of duplicating the framing logic in tests/unit.

- Skip vision_image_base64 only when FOUNDRY_VISION_MODEL_ID is unset; when set, surface real failures so regressions are caught.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Pivot the Rust Responses work away from SDK-native client/types and demonstrate the intended pattern instead: use FoundryLocalManager for setup/model/web-service lifecycle, then call /v1/responses via raw HTTP.

Adds a focused responses_web_service example and integration tests for non-streaming, streaming SSE, and function-calling flows against the local OpenAI-compatible web service.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Mirror the JavaScript Responses web-service PR by adding a Rust samples/rust/web-server-responses package, registering it in the Rust samples workspace, and documenting it in the sample indexes.

Tighten the Rust Responses integration tests to use cached variants, skip CI/local-missing prerequisites, assert response object/status and streaming event types, and use the same simple get_weather tool flow as the reference.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Document the Rust web-server Responses sample with prerequisites, restored Cargo dependencies, runtime downloads, and commands for running from either the samples workspace or sample directory.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Resolve samples/README.md language table conflict: keep main's WinML EP verification updates and new C++ row, and fold in this PR's Rust Responses API sample (Rust count 11 -> 12, add 'Responses API' to description).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 8, 2026 19:54
@vercel

vercel Bot commented Jun 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
foundry-local Ready Ready Preview, Comment Jun 8, 2026 7:54pm

Request Review

Copilot AI 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.

Pull request overview

Adds a Rust “Responses” web-service sample and companion SDK example/tests that call the local OpenAI-compatible /v1/responses endpoint via raw HTTP (mirroring the existing Python pattern), without introducing an SDK-native Responses client.

Changes:

  • Add a new Rust sample workspace member (samples/rust/web-server-responses) demonstrating non-streaming, SSE streaming, and tool-calling /v1/responses flows.
  • Add a new Rust SDK example (sdk/rust/examples/responses_web_service.rs) that starts the local web service and exercises /v1/responses via reqwest.
  • Add Rust SDK integration tests for /v1/responses and wire the new test module/example into the existing Rust crates/workspaces and sample catalog.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
sdk/rust/tests/integration/responses_test.rs Adds Responses web-service integration tests (non-streaming, SSE streaming, tool calling).
sdk/rust/tests/integration/main.rs Registers the new responses_test module in the integration test harness.
sdk/rust/examples/responses_web_service.rs New SDK example that starts the local web service and calls /v1/responses over raw HTTP.
sdk/rust/Cargo.toml Enables reqwest streaming support and registers the new example target.
samples/rust/web-server-responses/src/main.rs New standalone Rust sample implementing /v1/responses flows (non-streaming, SSE, tool calling).
samples/rust/web-server-responses/README.md Documents how to run the new Rust Responses web-service sample and what it demonstrates.
samples/rust/web-server-responses/Cargo.toml Declares the new sample crate and its dependencies/features.
samples/rust/README.md Adds the new sample to the Rust samples catalog table.
samples/rust/Cargo.toml Adds web-server-responses to the Rust samples workspace members.
samples/README.md Updates the top-level samples index to reflect the added Rust sample.


type TestResult<T> = Result<T, Box<dyn std::error::Error + Send + Sync>>;

static RESPONSES_TEST_LOCK: tokio::sync::Mutex<()> = tokio::sync::Mutex::const_new(());
Comment on lines +67 to +68
manager.stop_web_service().await.ok();
model.unload().await.ok();
Comment on lines +90 to +91
manager.stop_web_service().await.ok();
model.unload().await.ok();
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.

2 participants