Skip to content

[Bounty proposal] fix(file-tools): guard string end_seconds coercion, fallback top-level session config, and validate question ($50 proposed) #23199

Closed as not planned

Description

@Dimank92

Summary

In backend/utils/retrieval/tools/file_tools.py, invoking search_files_tool exhibits several resilience and input-type failure modes:

  1. String end_seconds TypeError:
    When LLM tool calls supply end_seconds as a string (e.g., "15") with start_seconds=None, line 203 previously executed:
    start = start_seconds if start_seconds is not None else max(0, (end_seconds or 0) - 5)
    In Python, ("15" or 0) - 5 raises an unhandled TypeError: unsupported operand type(s) for -: 'str' and 'int'.
  2. Missing top-level config fallback:
    user_id and chat_session_id are only checked in cfg.get('configurable', {}). In standard LangChain/LangGraph invocations or alternate runnables where configuration provides top-level user_id or chat_session_id, the tool previously defaulted to empty strings without fallback.
  3. Unhandled non-numeric / malformed timestamps:
    Non-numeric strings or invalid float values (such as nan, inf, or malformed text) passed into timestamp fields can cause unexpected math or conversion errors in downstream file window slicing.
  4. Empty question validation:
    Empty or whitespace-only questions were passed down to vision/multimodal LLM processing instead of returning an immediate validation message.
  5. Single string file_ids coercion:
    If an LLM supplies a single string file_ids="file_123" instead of a list, iterating or testing membership treats the string as a sequence of single characters unless normalized to [file_ids].

Proposed Changes

  1. Timestamp Sanitization (_parse_seconds):
    Add helper _parse_seconds to safely coerce int, float, or numeric strings to finite non-negative floats, while safely ignoring None, booleans, non-numeric strings, and infinities/NaNs.
  2. Safe Window Calculation:
    Safely compute (start, end) using sanitized numeric floats, preventing string subtraction TypeError.
  3. Top-Level Configuration Resolution:
    Support fallback to top-level user_id and chat_session_id in cfg if not present under configurable.
  4. Empty Question & Single File ID Guards:
    Validate non-empty question string and normalize single-string file_ids to a list.
  5. Hermetic Unit Tests:
    Add backend/tests/unit/test_file_tools_coercion_and_guards.py covering:
    • _parse_seconds behavior with ints, numeric strings, negative bounds, booleans, NaNs, and text.
    • Rejection of empty/whitespace questions.
    • Top-level user_id / chat_session_id resolution.
    • String end_seconds coercion without TypeError.
    • Single string file_ids coercion.

Bounty Proposal

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

Activity

  1. Dimank92 commented on Oct 22, 2026

    @Dimank92
    ContributorAuthor

    PR created with comprehensive hermetic unit tests: #23200

    Bounty proposal: $50 USDC
    Payout address: 0xC345C07229307d4f1c7935aD2cAe48e390215808 (USDC Polygon/Base/Arbitrum)

  2. moved this from Someday to In progress in omi TODO / bountieson Oct 22, 2026
  3. moved this from Someday to In progress in omi TODO / bountieson Oct 22, 2026
  4. undivisible commented on Oct 22, 2026

    @undivisible
    Collaborator

    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! 🙏

  5. moved this from In progress to In review in omi TODO / bountieson Oct 22, 2026
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