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
[Bounty proposal] fix(backend): get_action_items reads every conversation a user has, whatever the limit ($100 proposed) #15201
get_action_items (backend/database/conversations.py) is paginated in name only:
defget_action_items(uid, limit: int=100, offset: int=0, ...):
conversations_ref=conversations_ref.where(filter=FieldFilter('status', '==', 'completed'))
...
fordocinconversations_ref.stream(): # no .limit(), no budget
...
decrypted_data=_prepare_conversation_for_read(conversation_data, uid)
...
returnaction_items[offset:offset+limit] # the only bound
Every call streams every completed conversation the user has ever had and decrypts each one that carries action items, then throws almost all of it away. limit bounds the response, not the work.
Seven routers reach it: action_items.py, chat_first.py, developer.py, integration.py, mcp.py, mcp_sse.py, tools.py. The MCP and tools paths are agent-driven and call it several times inside one session, so the cost lands on exactly the users with the most history, repeatedly.
This is FC-bounded-read-exceeds-request-budget, which is open with scope_hints: ["backend/**"]: "A request-scoped collection read must bound its aggregate document work low enough to finish within the request middleware budget; a large per-query limit is not a sufficient bound."
Fix
Stop the scan once offset + limit eligible items are in hand. That is exact, not a heuristic: the stream is ordered by created_at descending, each flattened item inherits its conversation's created_at, and the final sort uses that same key, so the early items are the ones the slice keeps.
PR follows, with a query double that counts documents pulled: against 200 conversations a 10 item page reads at most 6 on the fix and all 200 on main, plus three cases that pin the returned page so the bound cannot quietly change results.
Bounty: $100 proposed, since it is a per-call full-collection read and decrypt on the agent paths, worst for the heaviest accounts.
Activity
fix(backend): stop the action-item scan once the page is filled (#15202)
fix(backend): stop the action-item scan once the page is filled (Base…