Skip to content

perf(workspace): the roster stops waiting for the slowest agent — briefing hydration moves off the critical path - #2518

Merged
vybe merged 8 commits into
devfrom
vybe/issue-2163
Sep 4, 2026
Merged

vybe merged 8 commits into
devfrom
vybe/issue-2163

Conversation

@trinity-ability

Copy link
Copy Markdown
Contributor

The Workspace roster's first paint was bounded by the slowest agent in the fleet. GET /my-agents fanned _agent_briefing across every card and await asyncio.gather(...) — which waits for all — so one wedged agent made every user's sign-in hang, on every sign-in. "Best-effort and parallel" bounded the blast radius (a failing agent left defaults); it never bounded the latency.

Fixes #2163

Shape of the fix

  • get_roster awaits no agent HTTP at all. It is now two SQL reads and one Docker list; its latency is its own. Each card ships briefing_state: "pending".
  • A new roster-scoped batch GET /briefings hydrates them off the critical path. Two shapes, one route: no filter briefs the whole roster (the background batch that fills the picker and the composer / typeahead); ?agents=a,b briefs a subset, used for the active agent so its hints arrive at its speed rather than the batch's slowest member. A per-agent route would have re-created the N+1 that bug: Agent Detail and Workspace over-fetch on load (21 redundant requests, N+1 roster) #2198 removed; an unfiltered-only batch would have moved the floor from the roster onto the hint zone.
  • Every briefing is bounded — 2.0s httpx per-phase / 3.0s wall clock — through one entry point, _bounded_briefing, shared by the batch and the agent page so the two doors cannot disagree about the same agent.
  • briefing_state is server-owned (pending / ready / unavailable), so a headless client doesn't have to reinvent the third value from empty fields.

Measured result (AC3)

An offline service-level harness driving the real code paths in both trees over a 12-agent roster with one wedged agent; 5 runs, min/med/max:

Call Before After
GET /my-agents (wedged / tarpit / refused / healthy) 10.003 / 10.004 / 10.086 s 0.000 s in every shape
Active agent's hints — (blocked behind the fleet) 0.053 s, regardless of the fleet
GET /agents/X/page, X wedged 10.002 s 2.002 s
GET /agents/X/page, X tarpit never returned 3.002 s
GET /agents/X/page, X healthy 0.103 s 0.051 s

Limits of the method, plainly: no real network and no real agent-server, and it models the two GETs as fully concurrent whereas a real agent server is a single uvicorn worker that will serialise them — so the healthy "after" (0.051 s) is the optimistic end of the range.

Three things the measurement corrected

  1. The old 5.0 was never a ceiling. It was httpx's per-phase timeout across two sequential GETs, so a wedged agent cost 10 s, not 5. Every "5s" in the issue description understates it by half.
  2. The wall-clock bound is not redundant with the httpx one. It never fires in the wedged shape — and it is the only thing that returns at all against a tarpit, where a per-read timeout resets forever (the a2a_client lesson).
  3. Making the two GETs concurrent halves the healthy agent page (0.103 → 0.051 s) — an unadvertised second win, and the reason a cancel landing mid-second-GET no longer discards the description the first GET already returned.

The defect the measurement found, and the fix

briefing_state depended on which exception the failure raised, not on whether the agent was reachable. _agent_briefing keeps a try/except per GET leg and an outer one, so a ReadTimeout (wedged) or a ConnectError (container gone) returned an ordinary empty briefing well inside the budget — and the card said ready. Only the tarpit shape, which trips the wall clock, reported unavailable.

So the two commonest unreachable shapes rendered as a genuinely hint-less agent, and since the client retries only on unavailable, it never asked again for the rest of the session. That violates AC2's "never silently empty" — the "looks complete" class.

Fixed by making the verdict follow reachability: one answered flag where the excepts already are, plus a module-level _UNREACHED sentinel compared by identity — an empty briefing an agent really produced compares equal to it and must stay ready. Deliberately not a fifth NamedTuple field (the positional shape is a published contract) and not a raise (the "degrades to empty, never crashes" contract has its own tests). Both doors inherit it; get_agent_card needed no change.

Shape Verdict
wedged / connection-refused / connect-timeout / tarpit unavailable
completed-empty / answered-500 / one-answering-leg / healthy ready

Contract change for API-only clients (ent#83 headless surface)

/my-agents cards now ship empty briefing fields plus briefing_state: "pending"; a client that wants hints makes the second call to /briefings. Mitigated by the field defaulting to "ready", so a payload from a build that predates it still validates and reads as "resolved inline, nothing to hydrate" — the non-privileged direction, since the field grants nothing and gates no affordance.

Verification performed

Suite Result
Crux test_2163_roster_latency_floor.py 44 passed (was 33)
Backend neighbourhood 70 passed
All 46 client_portal-touching unit files 866 passed / 1 skipped
Frontend 74 files / 1619 passed
/verify-local --skip-agent pass — unit 13747 (+35, the only lane whose count moves); integration 70 passed / 13 skipped / 2 deselected

The 2 deselected are the registry's test_webhook_rate_limit pair, which hardcode localhost:8000.

Re-run at ship time in this worktree: crux 44 passed; touched backend neighbourhood (test_2160, test_ent79, test_163) 101 passed; touched frontend specs + the loading-gate ratchet 3 files / 74 passed. The full pytest and full npm run test:unit suites were deliberately not re-run here — three lanes are shipping concurrently on this host and overlapping full-suite runs have already produced two phantom reds in test_1081_physical_meter (temp-SQLite state sharing; passes in isolation and in every verify run).

Human pre-merge steps (NOT done)

  • AC3 step 5b — the healthy-busy tail is still owed. On an instance with a real non-system agent Y mid-turn, time GET /briefings?agents=Y ×10 and raise the two constants (staying under 5 s) if p95 exceeds 2.0 s. Its risk calculus has improved: a healthy-but-slow agent that trips the bound now reports unavailable with honest copy and one retry, instead of rendering hint-less forever.
  • One uncontended full-unit-suite run on CI.

The live measurement was impossible here: this host's dev stack carries exactly one agent container, agent-trinity-system, and there was no throwaway agent to make unresponsive.

Follow-ups (listed, not filed)

  • The two limiter buckets key on request shape, not cost, so a fully-populated ?agents= (cap 200) pays the loose bucket. Not a regression — on dev, /my-agents fans out to the whole roster with no limiter at all, so this strictly reduces the ceiling — but it needs a measured threshold.
  • ScanlineReveal's border-radius cannot be overridden by a consumer rounded-* utility: scoped CSS compiles .scanline to a [data-v-hash] selector that outranks it.
  • .scan-content's margin: -4px bleeds past the stage zone, and <main> has no overflow-hidden.
  • The primitive's live region sits on the zone root, so no Workspace zone can pass announce.
  • A narrow race where a roster refetch mid-batch can stamp a newly-shared agent unavailable (self-heals on the next load).
  • docker.from_env() sets no timeout=, so a hung daemon can still hold the roster ~60 s via _availability_map.
  • client_portal/service.py remains code-health hotspot Feature/vector log retention #3.

Rebase note

client_portal/router.py and stores/clientPortal.js are shared with #2484 (ent#438 agent canvas — open and conflicting). Additions are region-disjoint; first merged wins.

PortalConversation.vue carries a small disclosed cross-lane touch — 17 insertions / 3 deletions in a file owned by the concurrent Lane A PR. It is exactly a ScanlineReveal wrapper, one import, one historyLoaded ref and one finally assignment; re-applying after a conflict is exactly that: wrap + import + ref + one line.

🤖 Generated with Claude Code

trinity-ability and others added 8 commits September 3, 2026 21:29
)

`_agent_briefing` ran under httpx's `timeout=5.0`, which is a PER-PHASE
value, not a ceiling: the function makes two sequential GETs, each of which
may spend a full timeout in each of connect/read/write/pool. So the "5s"
every caller reasoned about was a floor, and a trickling agent could hold
the call far past it (the a2a_client tarpit shape — a per-read timeout
resets forever).

Adds the belt half of #2163, landable on its own:

* `_BRIEFING_HTTP_TIMEOUT_SECONDS = 2.0` replaces the literal, and
  `_BRIEFING_BUDGET_SECONDS = 3.0` is a real wall clock enforced by the new
  `_bounded_briefing`, which never raises and answers `(briefing, ok)`.
  Both are constants, not settings and not env vars: an engineering bound no
  operator tunes at runtime (the SAMPLE_INTERVAL_SECONDS precedent, #1644),
  and an env read no compose file forwards is inert while reading as
  configurable (#1039).
* `ok` becomes the card's new `briefing_state` on the agent page, so a bound
  trip reports `unavailable` instead of passing for an agent that genuinely
  has no hints. `ok=True` means "reached a verdict inside its budget", never
  "returned data" — an agent exposing nothing legitimately briefs empty.
  The field defaults to `"ready"`, the non-privileged direction: it grants
  nothing and gates no affordance, it only says whether a fetch is owed.
* `_agent_briefing`'s two GETs now run under `asyncio.gather`. Sequential,
  a wall-clock cancel landing in the second call discarded the description
  the first had already returned; gathered, the healthy latency also halves.

Why 2.0/3.0 rather than the issue's "say 1.5s": `GET /api/skills` on the
agent is a synchronous directory scan on the agent-server's own event loop,
so a healthy agent mid-turn can legitimately exceed a second. A tighter
value only trips on working agents. The WAVE-4 measurement confirms both
against the healthy-busy tail before this leaves draft.

Tests pin the COUNT and the BOUND, never a duration on a tiny fixture —
the #2160 lesson — using a stub that is genuinely never resolved.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ydrates them (#2163)

`get_roster` fanned `_agent_briefing` across every card and awaited
`asyncio.gather`, which waits for ALL — so the Workspace's first paint was
bounded by the SLOWEST agent in the fleet, for every user, on every sign-in.
One wedged agent made everybody's sign-in take five seconds regardless of
fleet size. "Best-effort and parallel" bounded the blast radius (a failing
agent left defaults) but never the latency.

The roster now awaits no agent HTTP at all: two SQL reads and one Docker
list. Every card ships `briefing_state="pending"`, and the description +
hint cards are hydrated by a new viewer-scoped read.

`GET /api/enterprise/client-portal/briefings[?agents=a,b]`:

* One route, two shapes. No filter briefs the whole roster (the client's
  background batch, which fills the picker and the composer's `/` typeahead);
  a filter briefs a subset, used for the ACTIVE agent so its hints arrive at
  its own speed rather than the batch's slowest member. A per-agent route
  would re-create the N+1 #2198 removed; an unfiltered-only batch would move
  the floor from the roster onto the hint zone.
* Scope is the roster and the ROSTER's strings are what we iterate — the
  caller's names are only ever tested for set membership, so a crafted name
  cannot steer the agent HTTP target, and an unknown one is dropped rather
  than answered (no existence oracle, Invariant #8).
* No Docker read: `_agent_briefing` attempts `unknown` by design (it reaches
  the agent by DNS), so a stopped container fails its connect under the bound
  and lands `unavailable` — the same verdict a skip would give, one fleet
  Docker call cheaper. `get_agent_card` keeps its single tri-state read
  because the page renders the chip.
* Per-request `Semaphore(16)`, acquired OUTSIDE the wall clock so a queued
  agent does not burn its budget waiting for a permit. Per request, never
  module-level: an asyncio primitive binds to the first loop that waits on it.
* Two limiter keys per viewer — the unfiltered form is far tighter (10/min vs
  60/min), because one call to it costs one bounded agent request per
  rostered agent.

`test_2160`'s "the roster still briefs everyone" is inverted (that fan-out
was the bug), and `test_ent79`'s two briefing assertions move to the new
entry point with the roster gaining a "ships no briefing at all" guard.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ry + briefing adopt the standard motion (#2163)

AC4: while the roster and a thread's history hydrate, the Workspace showed
two static lines — "Opening this conversation…" on the room branch and
"Loading…" in the conversation body — while the only motion anywhere in the
surface was #2159's sidebar skeleton. Both lines are gone, replaced by three
`ScanlineReveal` zones, each keyed on its own "no data yet".

* Stage (`Portal.vue`) — ONE persistent instance wrapping the whole branch
  chain, keyed on `stageZone(...)` over `viewState`: `store.rosterLoaded` (a
  VERDICT) AND `bootstrapResolved`, never `store.loading` (in flight). The
  second term is load-bearing: `activeAgentName`/`pendingSession` are assigned
  only after `refreshThreads()`, so keying on the roster alone reveals the
  stage for `agents[0]`, flashes ITS briefing and fires a wasted hydration
  before remounting for a deep link's real target. A failed roster, an empty
  one, and an unreachable deep-link agent all SNAP (`:reveal="false"`) rather
  than being celebrated.
* Conversation body (`PortalConversation.vue`) — keyed on the verdict
  `historyLoaded`, NOT on `loadingHistory`: the session-adoption path re-runs
  `loadThread` with the transcript already on screen (`session-adopted` sets
  `pendingSession` with no remount by design), so an in-flight key would sweep
  the beam over messages the user just watched arrive — the p13 lie AC4 exists
  to remove.
* Briefing (`PortalBriefing.vue`) — keyed on the card's `briefing_state`.
  `unavailable` neither beams nor reveals: it snaps to "Couldn't load
  suggestions for this agent right now.", reusing the fallback element so the
  raw-gray count stays flat. Avatar and name stay outside the zone; they come
  from the roster and are already correct.

No zone passes `announce`: the primitive puts `role="status"` — an implicit
aria-live region — on the zone ROOT, so the stage would re-announce the whole
conversation including the composer and the history zone every streamed
message. `aria-busy` still rides each root. Moving the primitive's live region
onto its `sr-only` span is a one-line follow-up recorded for #1921/ent#245.

`ScanlineReveal` gains an additive `content-class` prop: `.scan-content` is
the primitive's own element and `:deep()` is forbidden by its contract, so a
zone whose loaded content must FILL a flex column had no hook at all. Default
'' leaves every existing consumer byte-identical.

Client hydration, all decidable rules in the new pure
`components/portal/portalBriefingState.js` (vitest is node-env with no mount
harness, so a rule inside an SFC is one no test can reach):

* the background batch fires from `fetchRoster`'s SUCCESS branch, not from
  `bootstrap()` — both "Try again" buttons call the action directly, so a
  failed-then-retried first load would otherwise strand every non-active card
  pending for the session (principle 21);
* it fires at >= 1 pending card, not >= 2: a deep link into an EXISTING thread
  never mounts `PortalBriefing`, so a one-agent roster would never hydrate;
* the ACTIVE agent's single is driven by `Portal.vue`'s `activeAgent` watcher
  and is never coalesced into the batch, or its hints inherit exactly the
  floor this issue removes;
* `mergeRosterBriefings` carries hydrated cards across a refetch (no rising
  loading edge — p13) while re-arming `unavailable` as `pending`, so one
  earlier blip does not read "couldn't load" until reload;
* `fetchRoster` re-enters loading ONLY with no data on screen, so a retry after
  a failed first load shows the scanline instead of flashing "No agents shared
  with you yet" (a pre-existing p15 lie the AC4 line sat next to).

`loading-gate-baseline.json` regenerated: PortalConversation 2 -> 1 (74 total).
`workspaceRoomsGate.spec.js` F23 follows its roster-verdict arm up a level —
the room branch no longer needs `store.rosterLoaded` because the stage zone
above it is gated on exactly that, which is a stronger qualification (it covers
every stage branch, not just this one).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
… workspace-roster-briefing flow

Rule 1: the requirements entry for the behaviour change, plus every doc that
claimed the superseded shape.

* `requirements/core-agent.md` — new §5.16 `WORKSPACE_ROSTER_BRIEFING_DEFERRED`
  (the four ACs incl. the `kill -STOP` measurement procedure, the bound as
  constants, the server-owned tri-state, the route contract, what stays on
  #1921). §5.13's honest-empty-state bullet said "the roster is fetched once at
  mount", which is no longer where the briefing comes from.
* `architecture.md` — a new paragraph after the #2198 one; the ent#138/ent#380
  paragraph no longer claims "zero extra fetches"; the #2196 paragraph's "so
  #2163 stays free to defer/bound/cache" becomes what #2163 actually did.
* `design-system.md` §6 — the three Workspace zones join the reference
  adoptions, and `content-class` is documented beside the announce caveat that
  is the reason none of them announce.
* NEW `feature-flows/workspace-roster-briefing.md` + its index row — the load
  end to end, the decisions with their rejected alternatives, the test table,
  the AC3 measurement table (numbers filled at verification), and the residuals.
* `workspace-agent-page.md` — its flow tree still said `get_roster`, stale since
  #2160; now `get_agent_card`, and bounded.
* `workspace-sidebar-ia.md` — one pointer, and which skeleton is still #1921's.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…efing, not a roster projection (#2163)

The last doc line still describing the page's capabilities block as "a
projection of the roster briefing" — true of ent#360, false since #2160 gave
the page `get_agent_card` (one briefing, not N) and false in a second way
since #2163 bounded that call.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…er briefs nobody (#2163)

Three properties the review found asserted in prose and verified nowhere.

`_bounded_briefing` sits on two response paths and swallows everything by
design, so `except Exception` versus `except BaseException` is one word of
diff with no visible consequence — and the wider form makes a backend
shutdown read as a failed briefing, absorbing the cancellation and returning
a value into a task being torn down. Pinned by a stub that raises
CancelledError; mutation-checked (the widened clause fails it).

The same helper is the only thing that closes the httpx client `_agent_briefing`
holds open across both GETs: nothing but the cancellation unwinding through
`async with` releases that socket when the wall clock fires. `asyncio.wait_for`
awaits the cancellation before raising, which is what makes it true — pinned by
an async context manager that records its `__aexit__` exc_type, so a refactor
that stops awaiting the cancel, or moves the client outside the bound, leaks one
connection per trip under exactly the condition the bound exists for.

`agents=` present-but-empty and `agents=` absent are opposite answers: an empty
list intersects the roster to nothing, `None` fans out to every agent on it. The
router separates them on `agents is not None`; tightening that to `if agents:`
— the obvious simplification — turns one empty query parameter into a
whole-fleet fan-out AND charges it to the filtered bucket, which is six times
looser precisely because a filtered call costs one agent. Pinned at the route
(both halves) and at the service; mutation-checked.

The client had the same inversion latent: `hydrateBriefings([])` coerced an
empty list to the whole-roster batch, so a future caller that filtered its list
down to nothing would silently fan out across the fleet. Only an omitted/null
argument is the batch now.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…und (#2163)

The AC3 table shipped as `_to be filled at verification_`. Filled, with the
method and its limits stated beside every number.

Method: an offline service-level harness, not a live fleet. The live dev stack
carries exactly one agent container — `agent-trinity-system` — so the plan's
step-3 recipe (`kill -STOP` on a throwaway agent) had no eligible subject: the
only candidate is the orchestrator, which is off limits. The harness drives the
real `get_roster` / `get_agent_card` / `get_briefings` in both trees, stubbing
only the SQL roster read and the Docker read (a constant addend on both sides)
and stubbing the agent HTTP edge at `agent_httpx_client`, so the real `timeout=`
plumbing and the real sequential-vs-concurrent GET structure run.

AC3 is met: with one wedged agent in a fleet of twelve, `/my-agents` goes from
10.003/10.004/10.086 s to 0.000 s, and the active agent's own hints arrive in
0.053 s regardless of the rest of the fleet. Three things the plan predicted and
had not shown: the old `5.0` was a per-phase timeout over two SEQUENTIAL GETs,
so one wedged agent cost 10 s and not 5; the wall clock is not redundant with
the httpx value (it never fires in the wedged shape and is the only thing that
returns at all in the tarpit shape); and the concurrent-GET change halves the
healthy agent page, 0.103 s to 0.051 s.

Step 5b is split honestly. The component is measured: `scan_skills_directory` is
called synchronously from an `async def`, and costs ~0.19 ms per skill (37 ms at
200) — three orders of magnitude under the 2.0 s bound, so the scan itself
cannot trip it. The tail is NOT measured: event-loop contention on an agent
mid-turn needs a real non-system agent, which this host does not have. Named as
a human step. Constants unchanged at 2.0/3.0 — nothing measured contradicts
them, and they are not moved on a guess.

One finding, recorded rather than papered over: `briefing_state` for the same
unreachable agent depends on which door the failure exits by. A tarpit trips the
wall clock and reads `unavailable`; a `kill -STOP` wedge and a refused connect
are swallowed by `_agent_briefing`'s per-leg and outer excepts, return an empty
briefing inside the budget, and read `ready`. So the two commonest unreachable
shapes render as a genuinely hint-less agent, and `shouldRequestBriefing` retries
only `unavailable` — the outcome D4 was written to prevent. It also makes
`get_briefings`' own docstring wrong where it claims a stopped container "lands
as `unavailable`". Not changed here: a verification stage measures, it does not
redesign. Either the behaviour changes or those docstrings do, before the PR
leaves draft. AC3 itself is a latency criterion and is unaffected.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…the failure exited by (#2163)

Measured at verification: `briefing_state` for the SAME unreachable agent
depended on which door the failure took —

  tarpit  (bytes trickle, no per-phase timer fires)  -> unavailable  correct
  wedged  (`kill -STOP`, httpx ReadTimeout at 2.0 s) -> ready        wrong
  refused (container gone, ConnectError, ~0 s)       -> ready        wrong

Structural, not a slip. `ok=False` was reachable only from the availability
skip, a non-tuple return, or the wall clock, while `_agent_briefing` swallows
every HTTP failure one level down — a `try/except` per GET leg AND an outer one
— so a ReadTimeout or a ConnectError returned an ordinary empty `AgentBriefing`
well inside the budget and `_bounded_briefing` truthfully reported that it
"reached a verdict".

The consequence is the one D4 exists to prevent, on the two COMMONEST shapes: a
genuinely hint-less agent on screen ("Start a conversation below."), and no
recovery, because `shouldRequestBriefing` retries only `unavailable`. That is
AC2's "never silently empty" and ent#380's no-dead-chrome rule, both broken. It
also made `get_briefings`' own docstring false where it claimed a stopped or
absent container "lands as `unavailable`".

Reachability is now reported separately from content, on one flag kept where
those excepts already are. Every exit of `_agent_briefing` that got no answer
out of the agent — the availability skip, both legs failing at the transport
layer, a failure before the first request — returns the module-level
`_UNREACHED` sentinel, and `_bounded_briefing` reads it by IDENTITY. Identity,
not equality: `_UNREACHED` IS an empty briefing and compares equal to the one a
healthy hint-less agent legitimately produces, which must stay `ready`. It is
deliberately not a fifth NamedTuple field (the positional shape is a published
contract — `_apply_briefing` and `_briefing_to_model` are positional-tolerant
by design and three test modules unpack all four fields) and deliberately not a
raise (the degrade-never-crash contract has its own tests, and the exits that
still owe an empty briefing keep it). The sentinel never escapes the helper.

Two boundaries drawn on purpose: a response of ANY status counts as reached (a
500 is the agent talking, and a retry fetches the same 500), and ONE answering
leg is enough, because the client renders `unavailable` INSTEAD of the fields —
so calling a half-answered briefing unreachable would hide the description the
other leg did return. Both doors inherit this from `_bounded_briefing`, so the
agent page and the `/briefings` batch cannot disagree about the same agent.

The client's retry rule is unchanged and needed no change: it already retried
`unavailable` once per session. The server simply never reached that state for
the shapes that matter, so this is what activates the rule already there.

Tests drive the REAL `_agent_briefing` (stubbing it skips the very excepts that
produced the defect) and pin every shape at both doors: wedged / refused /
connect-timeout -> unavailable, tarpit -> unavailable via the wall clock,
completed-empty and answered-500 -> ready, one-leg-answered -> ready with its
description, healthy -> ready with hints. Plus a source guard, because the
failure direction is silent: a new answerless exit returning a bare
`AgentBriefing()` would read `ready` again.

Docs corrected rather than the code left to contradict them: the two docstrings
this finding named, the architecture Workspace block, requirements 5.16, and
the flow doc's finding section (which recorded the fix as the lane owner's call
and is now resolved).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@vybe
vybe marked this pull request as ready for review September 4, 2026 10:12

@vybe vybe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validated via /validate-pr. CI fully green: e2e, build, journey-smoke, gitleaks, all six pytest seeds, schema-parity, verify-non-root.

Packaging checked (§4.8/§4.9) — the three backend files are all under src/backend/client_portal/, which already exists on dev and is COPYed at docker/backend/Dockerfile:145; no new top-level package and no new os.getenv var, so nothing needs compose wiring. Security scan clean — the single "email" my regex flagged is @router.get("/briefings", …), a decorator.

The diagnosis is the valuable part. await asyncio.gather(...) waits for all, so "best-effort and parallel" bounded the blast radius (a failing agent left defaults) but never bounded the latency — one wedged agent made every user's sign-in hang, on every sign-in. Making get_roster await no agent HTTP at all (two SQL reads + one Docker list) is the right fix: its latency becomes its own, and the hydration moves off the critical path.

The two-shapes-one-route decision is correct and the alternatives are correctly rejected. A per-agent route re-creates the N+1 that #2198 removed; an unfiltered-only batch just moves the floor from the roster onto the hint zone. Filtering to the active agent so its hints arrive at its own speed rather than the batch's slowest member is what makes that split earn itself. briefing_state being server-owned is also right — a headless client shouldn't have to reinvent a third value from empty fields.

Three things the measurement earned, which I'd have flagged had they only been asserted:

  1. The old 5.0 was never a ceiling — it was httpx's per-phase timeout across two sequential GETs, so the wedged cost was 10s, not 5. Every "5s" in the issue understates it by half, and the PR says so rather than quietly shipping the better number.
  2. The wall-clock bound is not redundant with the httpx one. It never fires in the wedged shape, and it is the only thing that returns at all against a tarpit, where a per-read timeout resets forever — the a2a_client lesson, correctly reapplied.
  3. Concurrency on the two GETs halves the healthy agent page as an unadvertised second win.

The defect found during measurement is the one that matters: briefing_state depended on which exception was raised rather than on reachability, so a ReadTimeout or ConnectError returned an ordinary empty briefing well inside budget and the card claimed ready. Only the tarpit reported unavailable. That is a state lying about itself, and catching it required building the harness — exactly the case for measuring rather than asserting.

Limits stated honestly (no real network, no real agent-server, and the two GETs modelled as fully concurrent where a single-worker uvicorn will serialise them, so the healthy 0.051s is the optimistic end). I'd rather have that sentence than a rounder number.

Fixes #2163 carries a closing keyword. Approving.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants