Skip to content

fix(workspace): agent page initial load is slow — profile and parallelize build_page #2160

Closed

Description

@vybe

Summary

Opening an agent's page in the Workspace (ent#360, PR #2147) takes noticeably long before anything useful renders. The page payload is assembled server-side in one shot, so the client waits on the slowest sub-read before seeing anything.

Context

src/backend/client_portal/agent_page.py::build_page composes health, windowed stats, operator asks, recent work, reports metadata and last-active into a single response. If those reads run sequentially (or any of them is an unindexed/wide query), first paint is bounded by their sum. Part of the Workspace polish pass following ent#357–ent#361.

Acceptance Criteria

  • Profile build_page on a realistic dataset and record where the time goes (health probe, stats window, asks, recent work, reports) — findings noted on this issue before the fix
  • Independent sub-reads run concurrently (or below-the-fold sections load progressively) — the page shell with header/identity renders promptly instead of blocking on the full payload
  • Any hot query gets an index or a bounded window; no unbounded scans on schedule_executions/agent_activities for one page load
  • The page shows an honest loading state per section while data arrives (design-system data-loading motion standard) — never a blank/hung-looking page
  • Repeat visits within a short window don't refetch identical windowed stats (consider the ${name}:${window} cache convention from stores/executions.js)

Technical Notes

  • Backend: src/backend/client_portal/agent_page.py (build_page, _health, _stats, _asks, _recent_work, reports, _last_active)
  • Frontend: src/frontend/src/components/portal/PortalAgentPage.vue
  • _health reaches the live container — that read must never gate first paint for the rest of the page

Activity

  1. added
    priority-p1
    type-bug
    theme-ui-ux
    status-ready
    on Aug 13, 2026
  2. added
    status-in-progress
    and removed
    status-ready
    on Aug 13, 2026
  3. self-assigned this
    on Aug 13, 2026
  4. dolho commented on Aug 13, 2026

    @dolho
    Contributor

    Profile (AC1) — recorded before the fix

    Measured on the live instance against evt-boss (1600 executions, 16 reports), Postgres backend, window 30d. Each sub-read timed individually inside the backend container:

    sub-read time
    _health 4.0 ms
    _stats(30d) 12.5 ms
    _asks 3.1 ms
    _recent_work 2.1 ms
    _last_active 4.9 ms
    reports 6.0 ms
    sum 32.7 ms

    build_page is not the bottleneck. The premise in the issue — that the sub-reads run sequentially and first paint is bounded by their sum — is true but the sum is 33 ms. Parallelising them would buy ~20 ms and is not worth the concurrency.

    The endpoint, however, is ~150 ms:

    GET /agents/evt-boss/page?window=30d   0.167s / 0.152s / 0.144s
    

    The missing ~115 ms is one line I wrote in ent#360's router:

    roster = await service.get_roster(email, include_owned=principal.is_platform)
    card = next((a for a in roster.agents if a.name == agent_name), None)

    Opening ONE agent's page builds the entire roster — and get_roster fans _agent_briefing across every agent: a Docker lookup plus up to two agent HTTP calls each, at a 5 s timeout, awaited with gather. So the page pays for N agents to render 1, and inherits the floor documented in #2163: the page's load time is bounded by the slowest agent in the fleet, not by the agent you opened. One wedged agent ⇒ a 5 s agent page for an unrelated agent. That is the fleet-scale version of what was reported as "noticeably long".

    Two corrections to the issue's technical notes while I'm here:

    So the fix is to stop building N cards to render one, not to parallelise a 33 ms body. AC5 (client-side window cache) still stands on its own merit — switching 7d→30d→7d refetches identically today.

  5. added
    status-in-dev
    and removed
    status-in-progress
    on Aug 13, 2026
  6. removed
    status-in-dev
    on Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

priority-p1theme-ui-uxtype-bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions