[Bounty proposal] fix(conversation-tools): resolve top-level user_id, coerce limit/segments, and guard None configurable ($50 proposed)
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
-
Broken
user_idresolution for top-level configurations and None configurable:- In both
get_conversations_toolandsearch_conversations_tool:
Whenconfigurable: Any = cfg.get('configurable') uid = configurable.get('user_id')configis a dictionary containing top-leveluser_id(e.g.{"user_id": "test_uid"}),configurableisNone. Calling.get('user_id')onNoneraises an unhandledAttributeError: 'NoneType' object has no attribute 'get'. - In
_render_addressable_conversations:
Ifcollected = configurable.get('conversations_collected', [])configurableis passed asNone, this immediately raisesAttributeError.
- In both
-
Fatal
TypeError: '<' not supported between instances of 'int' and 'str'on stringlimitormax_transcript_segments:- In
get_conversations_toolandsearch_conversations_tool:
When an LLM agent provides arguments with string numbers (e.g.if max_transcript_segments != -1: max_transcript_segments = min(max_transcript_segments, 1000) limit = min(limit, 5000)limit="20"ormax_transcript_segments="50"), callingmin()between an int and str raisesTypeError, failing the tool turn.
- In
-
Missing input sanitization on search
query: Insearch_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 extractinguser_idfrom either nestedconfigurableor top-levelcfg, safely guaranteeingconfigurableis a dictionary. - Guarded
_render_addressable_conversationsto ensureconfigurableis always a dictionary. - Defensively coerced and clamped
limit,offset, andmax_transcript_segmentsto valid integer ranges. - Normalized and validated non-empty
querybefore 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
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.
I would like to work on this. I will open a pull request that addresses the acceptance criteria.
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! 🙏