You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A2A ListTasks: push all-sessions listing down to SQL #2197
The store-backed ListTasks handles an all-sessions query (empty contextId) by loading every session for the user, then every task per session, then filtering, sorting, and paginating in memory. Latency and memory scale with the user's total task count even for a small page, and it issues N+1 queries (one ListSessions plus one ListTasksForSession per session).
Proposed fix
Add a single sqlc query that does the work server-side:
-- name: ListTasksForUser :manySELECT task.*, COUNT(*) OVER() AS total
FROM task
JOIN session ONsession.id=task.session_idWHEREsession.user_id= $1ANDtask.deleted_at IS NULLANDsession.deleted_at IS NULLORDER BYtask.idLIMIT $2 OFFSET $3;
and a ListTasksForUser method on the database client, then have collectUserTasks use it for the all-sessions path. The single-session path can reuse the same shape with a session_id predicate.
Open question: status filters
status and statusTimestampAfter live inside task.data, which is a TEXT column, so filtering them in SQL needs either:
(data::jsonb -> 'status' ->> 'state') casts per row (no index, and the cast errors on any malformed row), or
a migration adding generated columns (e.g. status_state, status_timestamp) or converting data to JSONB, with indexes.
Option 2 is the durable one but needs a new numbered migration (migration files are immutable in CI). A middle ground that already removes the N+1 and unbounded scan: push only the join + LIMIT/OFFSET down and keep the two JSON filters in memory on the fetched page window when no filter is set; when a filter is set, fall back to the current in-memory path until the schema supports it.
Resolved by #2598: the cross-session ListTasks path was removed and the new a2agateway listing filters, paginates and counts in SQL. Closing, #2302 is closed for the same reason.
Activity
EItanya commentedon Jul 9, 2026
This makes sense to me. Can we start with option 1 for status for now?
QuentinBisson commentedon Sep 8, 2026
Resolved by #2598: the cross-session ListTasks path was removed and the new
a2agatewaylisting filters, paginates and counts in SQL. Closing, #2302 is closed for the same reason.