The speech model now lives in a worker thread (whisperWorker.mjs), so loading and transcribing no longer block the bridge's HTTP server or its Hermes polling. Measured longest event-loop pause during transcription: 387 ms before, 3 ms after. A dead worker is replaced on the next request; closing the bridge terminates it. Polling: bridge to Hermes every 150 ms (was 500). The app polls the bridge every 200 ms for the first 8 s of a turn, 400 ms until 30 s, then 1 s (was a fixed 700 ms). Tests: 131 unit/integration, 7 real-speech, 9 real-Hermes, 6 simulator, all passing. Effect on a phone or a droplet is not measured. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
52 lines
2.9 KiB
Markdown
52 lines
2.9 KiB
Markdown
# 0002: Use the Hermes Runs API, not `/v1/responses`
|
|
|
|
Status: accepted for the first slice; revisit if the target Hermes differs. Date: 2026-11-18.
|
|
|
|
## Context
|
|
|
|
The specification says to use the supported authenticated Hermes API, "normally
|
|
`/v1/responses`", and to verify cancellation, idempotency and continuity before relying on it.
|
|
Both were checked against hermes-agent v0.23.1 (docs and source), then against a running gateway.
|
|
|
|
| Need | `/v1/responses` | `/v1/runs` |
|
|
|---|---|---|
|
|
| Start a turn without holding a connection for its whole duration | No. Non-streaming blocks until the turn ends; streaming holds an SSE connection. | Yes. Returns 202 and a `run_id` at once. |
|
|
| Read status later, including after a bridge restart | Only the finished response by id. | `GET /v1/runs/{id}`. |
|
|
| Cancel | No endpoint. Only dropping a streaming connection interrupts the agent. | `POST /v1/runs/{id}/stop`; status settles as `cancelled`. |
|
|
| Idempotent create | Yes, with replay rules that depend on the response store. | Yes: durable reservation, 24-hour retention, identical retry returns the same `run_id`. |
|
|
| Approval-required visible | Not as a pollable state. | `waiting_for_approval`. |
|
|
| "Outcome unknown" visible | 409 `unknown_execution` on retry. | `unknown` status. |
|
|
| Continuity | `previous_response_id` or `conversation`. | `session_id` (loads that session's transcript). |
|
|
|
|
## Decision
|
|
|
|
One adapter (`services/bridge/src/hermes/runsAdapter.ts`) using `POST /v1/runs`,
|
|
`GET /v1/runs/{id}` and `POST /v1/runs/{id}/stop`.
|
|
|
|
- Continuity: each Hermeven conversation owns one bridge-generated Hermes `session_id`
|
|
(`hermeven-<uuid>`). It is never accepted from, or shown to, a client.
|
|
- Idempotency: `Idempotency-Key: hermeven-turn-<request id>`. The exact request body is persisted
|
|
before the first attempt so a retry is byte-identical, and erased once the run id is stored.
|
|
- The bridge never calls the approval endpoint.
|
|
|
|
## Verified
|
|
|
|
Against a real gateway with a stub model: admission, identical replay
|
|
(`Idempotency-Replayed: true`), 409 on a changed body, session continuity (the model received
|
|
both user turns), stop settling as `cancelled`, and re-attachment after a bridge restart.
|
|
|
|
## Not verified
|
|
|
|
`waiting_for_approval`, `unknown`, `interrupted` and the stopped-short (`completed: false`) shape
|
|
are implemented from the source and exercised only against the test fake, because the stub model
|
|
calls no tools. They need a run against a real model with a tool that requires approval.
|
|
|
|
## Consequences
|
|
|
|
- Polling adds up to one poll interval (150 ms by default) of latency to every answer.
|
|
- No token streaming to the HUD. Acceptable: the HUD shows whole pages, and streaming through the
|
|
Even WebView is undocumented.
|
|
- If the target Hermes runs without the durable run ledger, the idempotency guarantee weakens.
|
|
The bridge should check `/v1/capabilities` `runs_idempotency.durable` at startup; that check is
|
|
not implemented yet.
|