Skip to content

[Bounty proposal] fix(backend): get_action_items reads every conversation a user has, whatever the limit ($100 proposed) #15201

Closed

Description

@singhharsh1708

Summary

get_action_items (backend/database/conversations.py) is paginated in name only:

def get_action_items(uid, limit: int = 100, offset: int = 0, ...):
    conversations_ref = conversations_ref.where(filter=FieldFilter('status', '==', 'completed'))
    ...
    for doc in conversations_ref.stream():        # no .limit(), no budget
        ...
        decrypted_data = _prepare_conversation_for_read(conversation_data, uid)
    ...
    return action_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.

cc @kodjima33 @josancamon19

Activity

  1. moved this from Someday to In progress in omi TODO / bountieson Sep 20, 2026
  2. added a commit that references this issue on Sep 22, 2026
    d13136b
  3. moved this from In progress to In review in omi TODO / bountieson Sep 22, 2026
  4. added a commit that references this issue on Nov 25, 2026
    96b847c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions