Skip to content

ui-server: inference admission waits for every pending egress record commit, twice per model request #4293

Open

Description

@schlessera

Blocked by #4279

Context

Part of #4278.

Since #3726, a governed turn's inference admission first waits for every egress record the turn has submitted so far to commit, then for the session binding (settleOperation, packages/ui-server/src/brain/turn-egress.ts:286-300; settled, :248). The relay admits twice per request (operation.admit(), packages/ui-sdk/src/server/inference-relay.ts:125-129 and :191-194), so the join runs twice. The records commit on the single write worker with full durability, measured at 35 to 85 ms per commit on a hosted install.

Today this is harmless: after a tool result the worker is stopped for 0.3 to 2 s before it can send the next request (see #4292), which gives the write queue time to drain. The relay's span did not rise at the release that introduced the join.

It stops being harmless the moment the hold moves. With the next request arriving about 10 ms after a tool result, the previous response's record and the tool's own bookkeeping are still queued, and the request waits for them inside the relay's span. Part of whatever the deferred freeze saves would reappear there.

Scope

  • Measure the join with the marks from ui-sdk: the inference relay records one duration per request, so host time cannot be told from the provider's time to first byte #4279: admitMs and the interval from credentialMs to dispatchMs, on turns with back-to-back tool calls, with the hold in place and with it removed in a fixture.
  • If the join costs more than a few milliseconds without the hold: make inference admission wait only for what it depends on. The comment at turn-egress.ts:288-291 names the purpose (a concurrent session binding must not change a healthy scope under its first admission). Records that cannot change the admission's outcome need not be joined.
  • If it does not, record the numbers and close this as a documented no.

Out of scope

Acceptance criteria

  • The PR reports admitMs for requests that follow a tool result by 10 ms, 50 ms and 500 ms on the native fixture, with the write queue loaded as a tool call loads it.
  • If the join is narrowed: a test shows inference admission still refuses when the session binding is unavailable and still sees a taint or a recording failure submitted before it; a mutation that drops the binding wait fails that test.
  • If it is not narrowed: the measured cost and the reason are recorded on this issue.
  • A test covering any change fails on the tree before the change and passes after.

Verification

bun run test packages/ui-server/tests packages/ui-sdk/tests
bun scripts/prove-native-host.ts --backend=claude --observation-timing

Contract impact

None.

2026-11-20 triage at main 63bb400b3. The two admission fences and the session binding are independent checks. Keep both fences and attribute the two joins separately in the fixture. The interval before dispatch also includes header charging and commit. The timing prerequisite is #4279. A throwaway fixture can vary the post-tool hold while #4292 is open.

Activity

  1. added
    type: fixSomething is broken and must behave the way it is documented.
    area: ui-serverHono app factory: turn coordinator, auth, session catalog, routes, cron.
    blockedWaiting on another issue or an upstream dependency. Say which in the body.
    on Nov 20, 2026
  2. added
    agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.
    priority: p2Wanted, not scheduled. Pulled in when a milestone has room.
    on Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.area: ui-serverHono app factory: turn coordinator, auth, session catalog, routes, cron.blockedWaiting on another issue or an upstream dependency. Say which in the body.priority: p2Wanted, not scheduled. Pulled in when a milestone has room.type: fixSomething is broken and must behave the way it is documented.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions