The owner had no llm.oneshot handler, so the WebSocket fell back to the
legacy sidecar's. That handler lends the model of a session it finds in
its own table (_main_runtime_from_agent), and that table never holds an
owner session: every session-bound one-shot (Desktop commit messages,
review summaries, plugins) ran on the task backend's `auto` route, the
profile default, instead of the chat's model.
The owner now serves llm.oneshot. A session-bound call authorizes
session:read on that session and lends the resident agent's route
(snapshotted on the loop when the request arrives), else the session's
own frozen launch route, resolved in the worker with fallback=False: only
the primary route, so an AuthError fails the one-shot (5030) instead of
walking the route's fallback chain, a walk that would also set the
runner-wide fallback notice the next turn reports. A session-less call
keeps the task backend.
A named custom provider's route is lent as provider `custom` with its
resolved endpoint and key, and the aux client's anonymous custom arm
dropped the entry's extra_headers, so a provider that requires them
failed the one-shot while chat worked. That arm now adds the extra_headers
of the configured entry whose base URL matches the endpoint, the same
match the main agent's own client makes; the endpoint and key stay
pinned, and the headers only ever go to that entry's own endpoint.
The model call is answered by a detached task, as the sidecar ran it on
its long-handler pool: the connection's serial dispatch moves on, so a
slow commit message never holds up the next request on that socket. The
call runs on the owner's own one-shot pool (4 threads, 16 admitted calls;
the 17th is refused as oneshot_busy), never the loop's default executor,
which session resume, socket setup and disconnect cleanup share across
connections and profiles. The pool is its own FIFO rather than a
ThreadPoolExecutor, which keeps a cancelled queued call (params and
copied context) until a worker dequeues it: with every worker parked on
the model, a reconnect loop would retain payloads past the bound. The
thread runs in a copy of the handler's context, so the profile scope
holds. dispatch still checks the accepted params before deferring and
the result before the reply is written.
Lifecycle: a closed socket's queued calls leave the queue at once and
its replies are discarded; owner shutdown (whole runtime or one profile's
unserve) refuses new calls with runtime_draining and cancels the queue.
A call already running in its thread cannot be interrupted: it finishes,
keeps its slot until then, and its reply goes nowhere. Failures keep the
sidecar's 5030 "one-shot generation failed" answer.
Refs #134889 (RT-7)
Refs #140208