Skip to content

rust: add Responses web-service sample#682

Open
MaanavD wants to merge 5 commits intomicrosoft:mainfrom
MaanavD:agents/bitter-partridge
Open

rust: add Responses web-service sample#682
MaanavD wants to merge 5 commits intomicrosoft:mainfrom
MaanavD:agents/bitter-partridge

Conversation

@MaanavD
Copy link
Copy Markdown
Collaborator

@MaanavD MaanavD commented Apr 28, 2026

Summary

  • Pivot the Rust Responses work to the web-service pattern: FoundryLocalManager handles SDK initialization, model lifecycle, and local OpenAI-compatible web service startup/shutdown.
  • Use raw HTTP against /v1/responses for the actual Responses calls; no SDK-native Responses client/types or FFI/native Responses surface are added.
  • Add samples/rust/web-server-responses plus SDK example coverage for non-streaming, streaming SSE, and tool-calling Responses flows.
  • Add sample README documentation that shows restored Cargo dependencies, runtime downloads, and commands for running the sample from either samples/rust or the sample directory.
  • Add integration tests that verify non-streaming output, response.output_text.delta/response.completed streaming events, and a get_weather function-calling round trip with previous_response_id.

Validation

  • cargo build
  • cargo test --test integration responses_test -- --nocapture
  • cargo test --lib
  • cargo clippy --all-targets
  • cargo check -p web-server-responses from samples/rust
  • cargo clippy -p web-server-responses from samples/rust

Notes

  • Responses integration tests skip in CI and when the local qwen2.5-0.5b model is not cached.
  • responses-api-sdk-spec.md remains local/untracked and is not included in this PR.

Copilot AI review requested due to automatic review settings April 28, 2026 06:27
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 28, 2026

@MaanavD is attempting to deploy a commit to the MSFT-AIP Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 HTTP-based OpenAI Responses API client to the Foundry Local SDK, including request/response types, SSE streaming support, manager factory wiring, public re-exports, and new unit/integration tests plus an example.

Changes:

  • Introduce ResponsesClient (+ settings) with non-streaming and SSE streaming APIs.
  • Add responses_types models for request/response payloads and streaming event shapes; re-export via openai and crate root.
  • Add unit/integration coverage and a responses example demonstrating non-streaming, streaming, multi-turn, and tool calling.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
sdk/rust/src/openai/responses_client.rs New HTTP client implementation (create/get/delete/cancel/list) + SSE parser.
sdk/rust/src/openai/responses_types.rs New serde models for Responses API payloads + streaming events.
sdk/rust/src/openai/mod.rs Wires new modules and re-exports Responses API surface.
sdk/rust/src/lib.rs Public re-exports of Responses API types/client from crate root.
sdk/rust/src/foundry_local_manager.rs Adds get_responses_client factory based on started web service URL.
sdk/rust/examples/responses.rs End-to-end example for Responses API (streaming + tools + multi-turn).
sdk/rust/tests/unit/main.rs Adds unit test harness for Responses API tests.
sdk/rust/tests/unit/responses_test.rs Adds serverless unit tests for types/serialization and some SSE-related behavior.
sdk/rust/tests/integration/main.rs Registers the new integration test module.
sdk/rust/tests/integration/responses_test.rs Adds end-to-end integration tests for Responses API flows.
sdk/rust/Cargo.toml Adds deps needed for SSE streaming (reqwest stream, bytes, async-stream) and example entry.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sdk/rust/src/openai/responses_client.rs Outdated
Comment thread sdk/rust/tests/unit/responses_test.rs Outdated
Comment thread sdk/rust/tests/integration/responses_test.rs Outdated
Comment thread sdk/rust/src/openai/mod.rs Outdated
MaanavD and others added 4 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>
@MaanavD MaanavD force-pushed the agents/bitter-partridge branch from a37cda9 to 9f89490 Compare May 1, 2026 22:19
@MaanavD MaanavD changed the title rust: add Responses API client rust: add Responses web-service sample May 1, 2026
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>
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