omi icon indicating copy to clipboard operation
omi copied to clipboard

[Bounty proposal] fix(conversation-tools): resolve top-level user_id, coerce limit/segments, and guard None configurable ($50 proposed)

Open Dimank92 opened this issue 1 month ago • 3 comments

Summary

In backend/utils/retrieval/tools/conversation_tools.py, get_conversations_tool and search_conversations_tool provide core retrieval and transcript search capabilities for user conversations.

Runtime Crashes & Vulnerabilities

  1. Broken user_id resolution for top-level configurations and None configurable:

    • In both get_conversations_tool and search_conversations_tool:
      configurable: Any = cfg.get('configurable')
      uid = configurable.get('user_id')
      
      When config is a dictionary containing top-level user_id (e.g. {"user_id": "test_uid"}), configurable is None. Calling .get('user_id') on None raises an unhandled AttributeError: 'NoneType' object has no attribute 'get'.
    • In _render_addressable_conversations:
      collected = configurable.get('conversations_collected', [])
      
      If configurable is passed as None, this immediately raises AttributeError.
  2. Fatal TypeError: '<' not supported between instances of 'int' and 'str' on string limit or max_transcript_segments:

    • In get_conversations_tool and search_conversations_tool:
      if max_transcript_segments != -1:
          max_transcript_segments = min(max_transcript_segments, 1000)
      limit = min(limit, 5000)
      
      When an LLM agent provides arguments with string numbers (e.g. limit="20" or max_transcript_segments="50"), calling min() between an int and str raises TypeError, failing the tool turn.
  3. Missing input sanitization on search query: In search_conversations_tool, empty or null queries proceed into downstream keyword queries and embedding calls (gemini_embed_query(query)) without early input validation.

Fix

  • Introduced _extract_user_context(cfg) helper extracting user_id from either nested configurable or top-level cfg, safely guaranteeing configurable is a dictionary.
  • Guarded _render_addressable_conversations to ensure configurable is always a dictionary.
  • Defensively coerced and clamped limit, offset, and max_transcript_segments to valid integer ranges.
  • Normalized and validated non-empty query before triggering search and embedding calls.
  • Added comprehensive hermetic unit tests in backend/tests/unit/test_conversation_tools.py.

Bounty Proposal

  • Proposed tier: $50 (Targeted bug fix + unit test coverage)
  • Settlement: Base Mainnet USDC / Stripe / Singapore Card

Dimank92 avatar Oct 21 '26 20:10 Dimank92

Resolved in PR #23114. Added _extract_user_context helper for robust user_id resolution, parameter integer coercion, empty query validation, and full unit test suite in backend/tests/unit/test_conversation_tools.py.

Dimank92 avatar Oct 21 '26 20:10 Dimank92

I would like to work on this. I will open a pull request that addresses the acceptance criteria.

airdropia avatar Oct 21 '26 23:10 airdropia

Thanks for putting this together. We aren't doing bounties at the moment, so we're closing the bounty proposal issues for now — thanks for the fix! 🙏

undivisible avatar Oct 22 '26 12:10 undivisible