Skip to content

fix(demand-processing-tools): harden process_recent_conversations validation, numeric coercion, and config resilience - #23336

Closed
Dimank92 wants to merge 1 commit into
BasedHardware:mainfrom
Dimank92:fix/demand-processing-tools-resilience
Closed

Dimank92 wants to merge 1 commit into
BasedHardware:mainfrom
Dimank92:fix/demand-processing-tools-resilience

Conversation

@Dimank92

@Dimank92 Dimank92 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #23337

Hardens backend/utils/retrieval/tools/demand_processing_tools.py against edge cases, unhandled type mismatches, and runtime failures during fresh conversation demand processing:

  1. Config Extraction Resilience:

    • Safely extracts configurable even if config.get('configurable') returns None, eliminating unhandled AttributeError crashes.
    • Adds fallback to agent_config_context when running inside the agentic retrieval loop without direct config kwargs.
    • Raises PermissionError('authenticated owner required') consistently if user ID cannot be resolved.
  2. Numeric Type & Bounds Coercion:

    • utils.conversations.demand_processing.process_recent strictly requires type(hours) is int (1..6) and type(limit) is int (1..20).
    • Coerces string-encoded numbers ("4", "15") and floats (2.0, 5.0) from LLM tool calls safely to int.
    • Clamps out-of-range values to valid boundaries (1 <= hours <= 6, 1 <= limit <= 20), preventing ValueError('hours must be 1..6 and limit 1..20') crashes.
  3. Graceful Error Handling:

    • Catches downstream storage/dependency failures (e.g. Redis unavailability) and returns structured JSON with ready=False and status details rather than unhandled exceptions bubbling up to break the agent stream.
  4. Hermetic Test Suite:

    • Adds 10 dedicated hermetic unit tests in backend/tests/unit/test_demand_processing_tools.py covering default arguments, coercion, clamping, fallbacks, authentication guards, and exception recovery.
    • 100% pass rate across new tests (10/10) and existing regressions in test_demand_processing.py (29/29).

Bounty Settlement Details

  • Proposed Bounty: $50–$100 USDC
  • Payout Wallet (Polygon / Base / Arbitrum / Stellar): 0xC345C07229307d4f1c7935aD2cAe48e390215808

…idation, numeric coercion, and config resilience

- Prevent AttributeError on None configurable in process_recent_conversations
- Add agent_config_context fallback for UID resolution
- Safely coerce and clamp hours (1..6) and limit (1..20) to prevent ValueError crashes in process_recent
- Handle downstream exceptions gracefully returning structured error JSON
- Add 10 hermetic unit tests in backend/tests/unit/test_demand_processing_tools.py
@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks for the contribution! Closing this one: the guarded inputs are server-derived (authenticated identity, internal identifiers) rather than attacker-controlled, so the hardening adds validation surface without fixing an observable bug. We take hardening PRs when they address a real failure — a crash, a user-visible 500, or a maintainer-confirmed bounty issue.

If you have evidence of an actual failure path (report, log, repro), comment here and it goes straight to a maintainer. Thanks again for contributing!

@github-actions

Copy link
Copy Markdown
Contributor

Hey @Dimank92 👋

Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request.

After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:

  • Project standards — Ensuring consistency across the codebase
  • User needs — Making sure changes align with what our users need
  • Code best practices — Maintaining code quality and maintainability
  • Project direction — Keeping aligned with our product principles and locked invariants

Before your next PR, please skim:

  • PRODUCT.md — product north star
  • Product invariants — locked rules (shared chat, memory tiers, agent control plane, integrations, brand)

If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing.

Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out.

Thank you for being part of the Omi community!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants