omi icon indicating copy to clipboard operation
omi copied to clipboard

[Bounty proposal] fix(conversation-tools): guard string numeric coercion, fallback top-level config, and sanitize transcript segments ($50 proposed)

Open Dimank92 opened this issue 1 month ago • 2 comments

Summary

In backend/utils/retrieval/tools/conversation_tools.py, several input coercions and edge cases in get_conversations_tool and search_conversations_tool lead to runtime exceptions or failed retrievals:

  1. String numeric coercion failure (TypeError: '<' not supported between instances of 'int' and 'str'):
    • get_conversations_tool: If limit, offset, or max_transcript_segments are passed as numeric strings by an LLM agent (e.g. limit="10"), bounds checks like min(max_transcript_segments, 1000) and min(limit, 5000) raise TypeError.
    • search_conversations_tool: min(limit, 20) and min(max_transcript_segments, 1000) raise TypeError when values are strings.
  2. Missing top-level config and UID resolution: Both get_conversations_tool and search_conversations_tool extracted configurable = cfg.get('configurable') and immediately called configurable.get('user_id'). When configurable is None (or callers pass top-level {"user_id": "..."}), this crashes with AttributeError: 'NoneType' object has no attribute 'get' and prematurely aborts with "Error: Configuration not available".
  3. Empty / None / Whitespace-only search query: In search_conversations_tool:
    • If query is empty, whitespace-only, or None, query.strip() raises AttributeError: 'NoneType' object has no attribute 'strip', and vector embedding queries are dispatched with empty strings.
  4. Non-string date values crash on .replace(): If an agent passes non-string types for start_date or end_date (e.g. integer timestamps or booleans), start_date.replace('Z', '+00:00') raises AttributeError.
  5. Non-dict / None transcript segment crash in all_person_ids collection: In both get_conversations_tool and search_conversations_tool, extracting person IDs via [s.get('person_id') for s in segments if s.get('person_id')] crashes with AttributeError if transcript_segments contains None or non-dict items.
  6. statuses parameter list support: statuses.split(',') crashes with AttributeError: 'list' object has no attribute 'split' if passed as a list of strings (e.g. ['processing', 'completed']).

Proposed Changes

  1. Safe Integer Coercion Helper (_safe_int): Add _safe_int(val, default) to safely parse integers and numeric strings while rejecting booleans, None, and invalid text.
  2. Resilient Config & UID Extraction (_get_config_and_uid): Safely handle non-dict or absent configurable dictionaries and resolve uid from configurable['user_id'], top-level user_id, or uid across config and agent_config_context.
  3. Early Query Validation: Validate query in search_conversations_tool and annotate with Optional[str] = None to accept omitted arguments gracefully.
  4. Safe Date & Status Parsing: Validate that start_date and end_date are strings before calling .replace(). Support both comma-separated strings and lists/tuples for statuses.
  5. Guarded Person ID Extraction: Ensure isinstance(s, dict) check before s.get('person_id').
  6. Hermetic Unit Tests: Add backend/tests/unit/test_conversation_tools_guards.py verifying integer coercion, top-level UID resolution, query validation, date string validation, transcript segment resilience, and status parsing.

Bounty Proposal

Proposed bounty: $50 USDC Payout address: 0xC345C07229307d4f1c7935aD2cAe48e390215808 (USDC Polygon/Base/Arbitrum)

Dimank92 avatar Oct 22 '26 05:10 Dimank92

Fix and hermetic test suite opened in PR #23220: https://github.com/BasedHardware/omi/pull/23220

Payout address (USDC Polygon / Base / Arbitrum): 0xC345C07229307d4f1c7935aD2cAe48e390215808

Dimank92 avatar Oct 22 '26 05:10 Dimank92

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