Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
0ff494e
feat(gateway): add multi-attachment --pinned-session mode
danielkov Nov 28, 2026
e1c9df1
fix(gateway): harden pinned-session replay, caps, reaping, and relay …
danielkov Nov 28, 2026
05c07ab
fix(gateway): budget relay startup trim, reparent retries, and harden…
danielkov Nov 28, 2026
047289b
fix(gateway): reserve start-replay relay headroom, skip cancelled orp…
danielkov Nov 28, 2026
be65c9f
feat(gateway): universalize client-request relay, replay cursors, and…
danielkov Nov 28, 2026
ee0e487
fix(gateway): harden pinned workspace binding, keyed cancel, and rela…
danielkov Nov 29, 2026
efe420e
fix(gateway): scope relay ids, target elicitation by capability, and …
danielkov Nov 29, 2026
c5dc937
fix(gateway): resolve ineligible pending relays on default-mode attach
danielkov Nov 29, 2026
38492c6
fix(gateway): harden relay framing, exit drain, pinned ownership, and…
danielkov Nov 29, 2026
378d7e0
fix(gateway): cancel orphaned relays on control drop and isolate lega…
danielkov Nov 29, 2026
1dabce8
fix(gateway): contain oversized live updates, share relay payloads, a…
danielkov Nov 29, 2026
947a8c5
fix(gateway): preserve frame_too_large reason and document pinned fan…
danielkov Nov 29, 2026
d2c4f25
fix(gateway): check per-frame limit before queue capacity and retain …
danielkov Nov 29, 2026
5c46e82
fix(gateway): bound serialized request ids at admission
danielkov Nov 29, 2026
84afa90
fix(gateway): return correlated error for fitting over-budget request…
danielkov Nov 29, 2026
4c43f50
fix(gateway): mark request_id_too_large rejection non-terminal for bu…
danielkov Nov 29, 2026
269e583
fix(gateway): validate request id budget before bridge startup state …
danielkov Nov 29, 2026
b6bddbf
fix(gateway): apply request id bounds during bridge reconnect backoff
danielkov Nov 29, 2026
5967019
fix(gateway): bound batch request ids in bridge admission and backoff
danielkov Nov 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 40 additions & 6 deletions docs/reference/gateway-protocol.md

Large diffs are not rendered by default.

22 changes: 20 additions & 2 deletions docs/user/gateway.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ To start another session, exit and omit `--remote-session` on the next invocatio

## Close a session

Use standard ACP [`session/close`](../reference/gateway-protocol.md#close-a-resident-session) from the current controller to end a resident session and its outstanding work, including detached jobs and subagents. Closing a terminal or HTTP connection only detaches; it is not a substitute for closing the session. Interrupting a turn with `session/cancel` also leaves ordinary top-level detached jobs running.
Use standard ACP [`session/close`](../reference/gateway-protocol.md#close-a-resident-session) from the current controller to end a resident session and its outstanding work, including detached jobs and subagents. In `--pinned-session` mode, `session/close` detaches only the calling attachment and does not end the shared session (see [Share one session across multiple clients](#share-one-session-across-multiple-clients)). Closing a terminal or HTTP connection only detaches; it is not a substitute for closing the session. Interrupting a turn with `session/cancel` also leaves ordinary top-level detached jobs running.

A successful close response follows session cleanup and child exit. Cleanup failure returns an error rather than reopening a partially closed child. A successful close also confirms that the session transcript has reached disk after cleanup. If writes remain buffered, persistence was disabled, or a transcript record was rejected, close returns an error instead of claiming durability. A storage failure can recover before the close check, but a record already lost cannot be repaired by a later successful disk write. After a successful close, the transcript remains available for explicit resume, which restores history rather than restarting the closed work. If the response is lost, do not assume either success or that the old child is still usable; list sessions and explicitly resume when ready to continue.

Expand All @@ -107,6 +107,24 @@ Create or resume the session before querying gateway status. Treat a failed stat

The gateway does not expose `session/fork`. When using native Kit transcript forks, stop concurrent submissions and wait for outstanding work to finish. If the fork reports `session must be settled before snapshot`, wait for background and delegated work to finish, or cancel it explicitly and wait for completion. If it reports `session changed during snapshot admission; retry`, wait for activity to settle before retrying the fork. A saved transcript is history, not a checkpoint that restarts interrupted tools.

## Share one session across multiple clients

To host one long-lived session that multiple ACP HTTP clients (for example, a dashboard, an automated trigger, and an operator) attach to simultaneously, pin the gateway to a single session ID:

```sh
kit gateway --credential-file "$HOME/.kit-gateway-token" \
--project /absolute/server/project \
--pinned-session my-thread-id \
--client-request-timeout 5m
```

- **Shared session boundary:** All attachments share the pinned session: every connected client receives all live updates, can submit prompts or cancel work, can answer relayed interactive questions or permission requests, and can call `session/set_config_option` and `_kit/session/update_mcp` (which can register stdio MCP servers that run commands in the host or sandbox). Place an authenticating proxy in front of `kit gateway --pinned-session` when serving multiple users or services and filter methods for less-trusted clients; the gateway itself verifies only its single bearer token.
- **Independent attachments:** Connecting a second client does not displace existing clients or withdraw their held prompts. Sending `session/close` detaches only the calling client without ending the session. If a slow client's output queue overflows, only that client is disconnected; other attachments and the active turn continue.
Comment thread
danielkov marked this conversation as resolved.
Resolved
- **Late joiners and default replay:** Unlike default mode (where `session/new` defaults to full replay), pinned mode omits historical replay by default on both `session/new` and `session/resume` unless `replayFrom` is provided. Both modes support `{"type":"start"}`, `{"type":"_kit_current_turn"}`, and `{"type":"_kit_message","sessionId":"...","messageId":"..."}`.
- **Multi-client interactive prompts:** Both modes relay agent-to-client requests (such as `ask_user` forms and permission requests) using `--client-request-timeout` (default `5m`). `elicitation/create` requests are offered only to attached clients (and late joiners) whose connection declared `capabilities.elicitation.form` (so headless deliverers with `capabilities: {}` are never targeted), while permission requests are offered to all live attachments. The first valid answer wins and the other targets receive a cancellation.

For exact wire behavior, cursors, and limits, see [Pinned-session mode](../reference/gateway-protocol.md#pinned-session-mode).

## Standard ACP HTTP clients

Use an ACP v2 HTTP/SSE client with the exact endpoint `http://HOST:7766/acp/v2`, a bearer credential on every request, and matching Kit versions. There is no separate Kit session REST API. See the [gateway protocol reference](../reference/gateway-protocol.md) for connection setup, supported operations, close requests, and transport limits.
Expand All @@ -132,6 +150,6 @@ See [Implement an ACP HTTP client](../reference/gateway-protocol.md#implement-an
- There is no fixed resident-session count ceiling. Provision memory and process capacity for your workload. Detaching does not stop a session, even when it is idle; use `session/close` to end resident work. Listing or creating sessions reclaims completed entries without deleting durable transcripts.
- Transport saturation can disconnect a client without canceling accepted work. HTTP frames are limited to 1 MiB; child output frames to 8 MiB. Oversized or malformed child output stops that child. There is no idle connection expiration or body-read deadline: abandoned transports can retain connection slots, and exhaustion may require restarting the gateway. See [Transport limits](../reference/gateway-protocol.md#transport-limits) before sizing an integration. These bounds are not a hard process-memory ceiling or denial-of-service protection.
- Use `Ctrl+C` on the gateway host for graceful shutdown. Kit waits for child cleanup and exit, then forcibly stops a child if it exceeds the 10-second timeout. That fallback can leave a stale transcript lock requiring operator intervention. Hard process termination has operating-system-dependent cleanup behavior; arbitrary tool descendants are not a managed process group.
- Client-side ACP services, arbitrary extra directories, session-scoped HTTP/SSE MCP servers, browser callbacks, and arbitrary ACP methods are not supported. Files, tool execution, and provider authentication belong to the gateway host.
- Interactive agent-to-client requests (such as `ask_user` forms and permission requests) are relayed to attached clients when the client advertises support (always advertised in pinned mode), with a configurable `--client-request-timeout` (default `5m`). Client-side filesystem and terminal services, arbitrary extra directories, legacy SSE MCP servers, browser callbacks, host-side terminal authentication, and arbitrary ACP methods are not supported. Files, tool execution, and provider authentication belong to the gateway host.

The internal `gateway bridge` stdio command is a transport adapter for the bundled TUI, not a stable public protocol or general-purpose ACP proxy. The public transport is ACP HTTP at `/acp/v2`, implemented by the ACP SDK rather than a Kit-specific RPC protocol.
Loading
Loading