omi icon indicating copy to clipboard operation
omi copied to clipboard

[Bounty proposal] fix(chart-tools): add config parameter, guard non-list inputs, and coerce numeric values ($50 proposed)

Open Dimank92 opened this issue 1 month ago • 2 comments

Summary

In backend/utils/retrieval/tools/chart_tools.py, several input coercions and edge cases in create_chart_tool lead to runtime exceptions or failed chart rendering:

  1. Missing config: RunnableConfig = None parameter and config resilience:
    • create_chart_tool lacked config: RunnableConfig = None in its function signature. LangChain tool invocations and callers passing config could raise TypeError: unexpected keyword argument 'config'.
    • If a configuration contained {'configurable': None}, config.get('configurable', {}) returned None, crashing on configurable['chart_data'] = chart_data with TypeError: 'NoneType' object does not support item assignment.
  2. None or non-list labels and values crash with TypeError:
    • If an agent passes labels=None or values=None (or non-list types), len(labels) != len(values) raises TypeError: object of type 'NoneType' has no len().
  3. Numeric string coercion for values:
    • LLMs frequently provide numerical values as string formatted numbers (e.g. ['7.2', '8.1']) or integers. Lack of float coercion could lead to serialization or client-side chart plotting issues, while non-numeric values produced unhandled exceptions.
  4. Case-insensitive chart_type normalization:
    • LLM agents frequently pass uppercase or padded types like 'BAR', 'Line '. Normalizing with .lower().strip() prevents rejecting valid requests.
  5. Labels coercion and Title validation:
    • Non-string labels (e.g. integer timestamps or day numbers [1, 2, 3]) are safely converted to strings.
    • Missing or empty titles are cleanly validated early.

Proposed Changes

  1. Add config: RunnableConfig = None & Safe Config Synchronization: Synchronize chart_data across passed config and _agent_config() (context variable), safely initializing configurable dictionary if missing or None.
  2. List & Length Validation: Validate that labels and values are lists before checking lengths.
  3. Float & Label Coercion: Safely coerce numeric strings and ints in values to floats, and convert label elements to strings.
  4. Type Normalization: Normalize chart_type with .lower().strip().
  5. Hermetic Unit Tests: Add backend/tests/unit/test_chart_tools_guards.py verifying chart creation, case insensitivity, numeric coercions, label coercions, None guards, and config resilience (9 tests, 100% pass).

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 #23236: https://github.com/BasedHardware/omi/pull/23236

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