omi icon indicating copy to clipboard operation
omi copied to clipboard

[Bounty proposal] fix(demand-processing-tools): add config resilience, clamp hours/limit, and guard UID ($50 proposed)

Open Dimank92 opened this issue 1 month ago • 2 comments

Summary

In backend/utils/retrieval/tools/demand_processing_tools.py, several input coercions and edge cases in process_recent_conversations can cause unhandled runtime exceptions (AttributeError, TypeError, or crashes during LangChain invocations):

  1. config.get('configurable', {}).get('user_id') crash when configurable is None or config missing:
    • If config is {'configurable': None} or None, calling .get('configurable', {}).get('user_id') raises AttributeError: 'NoneType' object has no attribute 'get'.
    • config was also required as a positional argument without default = None, raising TypeError: missing 1 required positional argument on direct calls.
  2. Unbounded and uncoerced hours and limit:
    • The tool docstring states: Bounded to the last six hours and twenty obligations.
    • However, hours and limit were passed directly without clamping or coercing numeric string inputs, allowing unbounded or invalid negative/oversized values.
  3. Top-level UID fallback:
    • Top-level user_id or uid keys in config are now supported for integration tests and custom runners.
  4. Error handling:
    • Exceptions during processing are caught, logged with sanitization, and return a clean failure JSON ({"ready": False, "error": ...}) instead of crashing the turn.

Proposed Changes

  1. Resilient _resolve_uid(config): Extract user ID safely from nested configurable or top-level config.
  2. Make config: RunnableConfig = None Optional: Prevent positional argument errors when invoked without config.
  3. Clamping & Coercion: Clamp hours to 1..6 and limit to 1..20 as documented, safely coercing string numbers.
  4. Hermetic Unit Tests: Add backend/tests/unit/test_demand_processing_tools_guards.py verifying UID resolution, clamping, error handling, and permission checks (5 tests, 100% pass).

Bounty Proposal

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

Dimank92 avatar Oct 22 '26 05:10 Dimank92

I have implemented the complete fix and hermetic unit tests in PR #23246.

  • Pull Request: https://github.com/BasedHardware/omi/pull/23246
  • Unit Tests: 5/5 passing hermetically
  • Payout Address: 0xC345C07229307d4f1c7935aD2cAe48e390215808 (USDC Polygon/Base/Arbitrum)

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