Multica Eve
d4dac0e77c
perf(agents): index-backed latest-terminal lookup in task snapshot (MUL-5436) ( #6085 )
...
ListWorkspaceAgentTaskSnapshot took each agent's latest completed/failed
task with a workspace-wide DISTINCT ON, so every presence load read and
sorted the workspace's whole terminal history. Neither existing index
matches that shape: (agent_id, status) has no completed_at, and migration
231's (completed_at) partial index is completed_at-first for the Usage
rollups.
Replace the outcome half with a per-agent JOIN LATERAL Top-1 and add a
partial index on (agent_id, completed_at DESC NULLS LAST, created_at DESC,
id DESC) WHERE status IN ('completed','failed'). On a 40-agent workspace
with 200k terminal rows this goes from 6631 shared buffers / 48.3 ms to
162 buffers / 0.1 ms, with an identical row set.
The (created_at, id) tie-break also makes the pick deterministic when
completed_at ties or is NULL — completed_at DESC alone left the winner up
to the plan.
Report #6075 asked to delete the outcome half as dead code, but PR #2608
made the Squad hover card (AgentLivePeekCard) read those rows for its
"last activity" line, so removing them would be a product regression for
shipped desktop builds. The response contract is unchanged here; splitting
the outcome into a lazy endpoint stays follow-up work.
Also tighten pickLatestTerminal to completed/failed only, matching the
snapshot's filter — it accepted cancelled, which the endpoint never
returns and which would have masked an agent's last real outcome.
Co-authored-by: Eve <eve@multica-ai.local >
Co-authored-by: multica-agent <github@multica.ai >
2026-07-29 14:28:44 +08:00
..
2026-07-15 03:09:56 +08:00
2026-07-15 03:09:56 +08:00
2026-07-15 03:09:56 +08:00
2026-07-03 14:18:43 +08:00
2026-07-29 13:08:48 +08:00
2026-07-22 16:38:50 +08:00
2026-07-23 10:56:53 +08:00
2026-07-23 10:56:53 +08:00
2026-07-03 14:18:43 +08:00
2026-07-29 12:47:14 +08:00
2026-07-29 14:01:09 +08:00
2026-07-29 14:01:09 +08:00
2026-07-03 14:18:43 +08:00
2026-07-03 17:56:02 +08:00
2026-07-22 15:38:38 +08:00
2026-07-22 15:38:38 +08:00
2026-07-03 17:56:02 +08:00
2026-07-29 12:47:14 +08:00
2026-07-29 14:28:44 +08:00
2026-07-23 15:40:18 +08:00
2026-07-29 12:47:14 +08:00
2026-07-29 14:28:44 +08:00
2026-07-15 03:09:56 +08:00
2026-07-15 03:09:56 +08:00
2026-07-17 16:44:31 +08:00
2026-07-17 16:44:31 +08:00
2026-07-07 20:49:42 +08:00
2026-07-16 15:23:56 +08:00
2026-07-15 03:09:56 +08:00
2026-07-07 20:49:42 +08:00
2026-07-15 03:09:56 +08:00
2026-07-14 18:29:05 +08:00
2026-07-15 03:09:56 +08:00
2026-07-15 00:52:27 +08:00
2026-07-27 13:12:06 +08:00
2026-07-15 00:52:27 +08:00
2026-07-15 00:52:27 +08:00
2026-07-27 15:44:39 +08:00
2026-07-07 13:20:30 +08:00
2026-07-08 21:58:16 +08:00
2026-07-24 11:30:27 +08:00
2026-07-14 09:37:02 +08:00
2026-07-09 13:49:07 +08:00
2026-07-09 13:49:07 +08:00
2026-07-24 11:30:27 +08:00
2026-07-22 16:52:34 +08:00
2026-07-22 16:52:34 +08:00
2026-07-14 19:56:17 +08:00
2026-07-15 03:09:56 +08:00
2026-07-27 14:26:23 +08:00
2026-07-27 14:26:23 +08:00
2026-07-16 15:23:56 +08:00
2026-07-12 14:23:30 +08:00
2026-07-10 16:15:10 +08:00
2026-07-20 15:38:31 +08:00
2026-07-15 03:09:56 +08:00
2026-07-29 13:15:10 +08:00
2026-07-29 13:15:10 +08:00
2026-07-24 16:39:22 +08:00
2026-07-24 16:39:22 +08:00
2026-07-14 11:53:42 +08:00
2026-07-14 11:53:42 +08:00
2026-07-27 15:44:39 +08:00
2026-07-17 13:40:23 +08:00
2026-07-27 13:12:06 +08:00
2026-07-15 03:09:56 +08:00
2026-07-10 13:43:45 +08:00
2026-07-14 11:53:42 +08:00
2026-07-14 11:53:42 +08:00
2026-07-17 12:33:36 +08:00
2026-07-14 11:56:30 +08:00
2026-07-14 11:56:30 +08:00
2026-07-29 14:01:09 +08:00
2026-07-29 13:08:48 +08:00
2026-07-27 18:40:48 +08:00
2026-07-29 13:08:48 +08:00
2026-07-20 12:46:39 +08:00
2026-07-27 15:44:39 +08:00
2026-07-27 02:49:30 +08:00
2026-07-28 16:19:35 +08:00
2026-07-28 16:19:35 +08:00
2026-07-22 16:52:34 +08:00
2026-07-07 14:43:19 +08:00
2026-07-27 15:44:39 +08:00
2026-07-16 14:58:42 +08:00
2026-07-13 16:42:46 +08:00
2026-07-03 16:10:19 +08:00
2026-07-14 11:56:30 +08:00
2026-07-15 03:09:56 +08:00
2026-07-15 03:09:56 +08:00
2026-07-10 09:11:29 +08:00
2026-07-13 16:15:58 +08:00
2026-07-22 20:33:15 +08:00
2026-07-27 13:12:06 +08:00
2026-07-22 20:33:15 +08:00
2026-07-22 22:43:34 +08:00
2026-07-16 13:31:06 +08:00
2026-07-13 13:08:04 +08:00
2026-07-23 15:58:25 +08:00
2026-07-23 15:58:25 +08:00
2026-07-06 19:11:47 +08:00
2026-07-13 13:08:04 +08:00
2026-07-17 19:21:27 +08:00
2026-07-23 12:03:27 +08:00
2026-07-17 19:21:27 +08:00
2026-07-23 15:58:25 +08:00
2026-07-23 17:54:52 +08:00
2026-07-23 17:54:52 +08:00
2026-07-23 15:58:25 +08:00
2026-07-15 03:09:56 +08:00
2026-07-22 22:43:34 +08:00
2026-07-13 18:13:44 +08:00
2026-07-13 18:13:44 +08:00
2026-07-08 16:19:41 +08:00
2026-07-08 16:19:41 +08:00
2026-07-03 14:18:43 +08:00
2026-07-03 14:18:43 +08:00
2026-07-15 03:09:56 +08:00
2026-07-15 17:52:10 +08:00
2026-07-15 17:52:10 +08:00
2026-07-23 01:57:44 +08:00
2026-07-23 01:57:44 +08:00
2026-07-13 13:22:02 +08:00
2026-07-07 17:35:33 +08:00
2026-07-07 17:35:33 +08:00
2026-07-24 11:30:27 +08:00
2026-07-15 22:37:57 +08:00
2026-07-15 22:37:57 +08:00
2026-07-17 11:11:52 +08:00
2026-07-13 20:07:24 +08:00
2026-07-02 18:31:45 +08:00
2026-07-07 12:01:14 +08:00
2026-07-08 16:00:17 +08:00
2026-07-12 02:53:17 +08:00
2026-07-12 02:53:17 +08:00
2026-07-22 15:38:38 +08:00
2026-07-22 15:38:38 +08:00
2026-07-23 15:40:18 +08:00
2026-07-09 15:07:11 +08:00
2026-07-15 00:52:27 +08:00
2026-07-16 13:54:01 +08:00
2026-07-16 13:54:01 +08:00
2026-07-16 13:54:01 +08:00
2026-07-16 13:54:01 +08:00
2026-07-16 13:54:01 +08:00
2026-07-27 18:40:48 +08:00
2026-07-06 12:34:51 +08:00
2026-07-06 12:34:51 +08:00
2026-07-06 12:34:51 +08:00
2026-07-22 15:38:38 +08:00
2026-07-22 14:38:31 +08:00
2026-07-22 14:38:31 +08:00
2026-07-09 15:07:11 +08:00
2026-07-22 20:33:15 +08:00
2026-07-22 20:33:15 +08:00
2026-07-15 03:09:56 +08:00
2026-07-08 14:51:54 +08:00
2026-07-03 14:18:43 +08:00
2026-07-22 20:33:15 +08:00
2026-07-15 03:09:56 +08:00
2026-07-15 03:09:56 +08:00
2026-07-15 03:09:56 +08:00
2026-07-15 03:09:56 +08:00
2026-07-14 13:16:50 +08:00
2026-07-16 15:23:56 +08:00
2026-07-24 16:39:22 +08:00
2026-07-24 16:39:22 +08:00
2026-07-24 18:30:20 +08:00
2026-07-24 16:39:22 +08:00
2026-07-14 18:29:05 +08:00
2026-07-14 18:29:05 +08:00
2026-07-14 16:20:33 +08:00
2026-07-14 16:20:33 +08:00
2026-07-14 16:20:33 +08:00
2026-07-03 14:18:43 +08:00
2026-07-24 18:30:20 +08:00
2026-07-15 00:52:27 +08:00