Skip to content

feat: mature gateway webui api surfaces#1439

Open
chumyin wants to merge 1 commit into
devfrom
feat/gateway-webui-api-maturity
Open

feat: mature gateway webui api surfaces#1439
chumyin wants to merge 1 commit into
devfrom
feat/gateway-webui-api-maturity

Conversation

@chumyin
Copy link
Copy Markdown
Collaborator

@chumyin chumyin commented May 2, 2026

Summary

  • Problem:
    Loong's gateway already exposed useful HTTP surfaces, but third-party WebUI integration was still incomplete. Operators could talk to /v1/chat/completions, /v1/models, and /v1/turn, yet the gateway still lacked a persisted Responses-style continuity surface and had rough streaming-compatibility edges.
  • Why it matters:
    Operators want to connect Loong to their own browser frontends or OpenAI-compatible chat UIs without building a custom bridge around the runtime first.
  • What changed:
    Added a persisted gateway Responses surface, completed fetch/delete response endpoints, taught chat-completions streaming to degrade gracefully on non-streaming providers, wired request-level tool-view overrides into turn execution, and documented the trusted WebUI contract.
  • What did not change (scope boundary):
    Caller-supplied tools remain limited to Loong's structured gateway tool layer. Direct runtime tools are still governed by Loong's own runtime surface rather than arbitrary client-declared tool contracts.

Linked Issues

Change Type

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Security hardening
  • CI / workflow / release

Touched Areas

  • Kernel / policy / approvals
  • Contracts / protocol / spec
  • Daemon / CLI / install
  • Providers / routing
  • Tools
  • Browser automation
  • Channels / integrations
  • ACP / conversation / session runtime
  • Memory / context assembly
  • Config / migration / onboarding
  • Docs / contributor workflow
  • CI / release / workflows

Risk Track

  • Track A (routine / low-risk)
  • Track B (higher-risk / policy-impacting)

If Track B, fill these in:

  • Risk notes:
    This changes the public gateway contract for WebUI clients and threads request-level tool settings into the turn-runtime seam.
  • Rollout / guardrails:
    The new contract is covered by focused gateway tests and keeps direct runtime tools behind Loong-controlled governance instead of opening arbitrary external tool contracts.
  • Rollback path:
    Revert this branch or disable use of /v1/responses and request-level tool fields on the client side; existing /v1/turn remains available as the native control surface.

Validation

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo test --workspace --locked
  • cargo test --workspace --all-features --locked
  • Relevant architecture / dep-graph / docs checks for touched areas
  • Additional scenario, benchmark, or manual checks when behavior changed
  • If this changes config/env fallback, limits, or defaults: include before/after behavior and regression coverage for explicit path, fallback path, and boundary values
  • If tests mutate process-global env: document how state is restored or serialized

Commands and evidence:

./scripts/cargo-local-toolchain.sh fmt --all -- --check
./scripts/cargo-local-toolchain.sh test -p loong gateway_ --lib
./scripts/cargo-local-toolchain.sh clippy -p loong --all-targets --all-features -- -D warnings

Result:
- fmt check passed
- gateway_ test surface passed (42 tests)
- package-scoped clippy passed with -D warnings

User-visible / Operator-visible Changes

  • Trusted WebUI clients can now use /v1/responses with persisted response continuity.
  • Clients can fetch and delete stored responses through the gateway.
  • chat/completions streaming now degrades gracefully when the configured provider can complete turns but does not expose native token streaming.
  • tool_choice="none" is accepted on the gateway-compatible request surface.
  • Public docs now include a dedicated WebUI gateway integration page.

Failure Recovery

  • Fast rollback or disable path:
    Revert the commit series or stop advertising /v1/responses to clients and continue using /v1/chat/completions or /v1/turn.
  • Observable failure symptoms reviewers should watch for:
    Missing response persistence, continued responses losing history, gateway tool filters dropping the expected structured gateway tools, or streaming responses falling back to empty SSE bodies.

Reviewer Focus

  • Review the request-level tool-view override seam in crates/app/src/agent_runtime.rs, crates/app/src/chat.rs, and crates/app/src/conversation/runtime.rs.
  • Review the gateway contract additions in crates/daemon/src/gateway/openai_compat.rs, openai_responses.rs, openai_tooling.rs, and response_store.rs.
  • Review the public contract wording in site/use-loong/gateway-webui.mdx to confirm the stated boundary around structured gateway tools vs direct runtime tools is the one we want to support.

@chumyin chumyin requested a review from a team as a code owner May 2, 2026 07:44
@chumyin chumyin self-assigned this May 2, 2026
@github-actions github-actions Bot added daemon Daemon binary, CLI entrypoints, and install flow. tools Tool runtime, policy adapters, and tool catalog behavior. conversation Conversation runtime, session flow, and prompt assembly. size: XL Very large pull request: more than 1000 changed lines. labels May 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conversation Conversation runtime, session flow, and prompt assembly. daemon Daemon binary, CLI entrypoints, and install flow. size: XL Very large pull request: more than 1000 changed lines. tools Tool runtime, policy adapters, and tool catalog behavior.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mature gateway WebUI API surfaces for third-party frontends

1 participant