omi
omi copied to clipboard
[Bounty proposal] fix(chart-tools): add config parameter, guard non-list inputs, and coerce numeric values ($50 proposed)
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:
- Missing
config: RunnableConfig = Noneparameter and config resilience:create_chart_toollackedconfig: RunnableConfig = Nonein its function signature. LangChain tool invocations and callers passingconfigcould raiseTypeError: unexpected keyword argument 'config'.- If a configuration contained
{'configurable': None},config.get('configurable', {})returnedNone, crashing onconfigurable['chart_data'] = chart_datawithTypeError: 'NoneType' object does not support item assignment.
Noneor non-listlabelsandvaluescrash withTypeError:- If an agent passes
labels=Noneorvalues=None(or non-list types),len(labels) != len(values)raisesTypeError: object of type 'NoneType' has no len().
- If an agent passes
- 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.
- LLMs frequently provide numerical values as string formatted numbers (e.g.
- Case-insensitive
chart_typenormalization:- LLM agents frequently pass uppercase or padded types like
'BAR','Line '. Normalizing with.lower().strip()prevents rejecting valid requests.
- LLM agents frequently pass uppercase or padded types like
- 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.
- Non-string labels (e.g. integer timestamps or day numbers
Proposed Changes
- Add
config: RunnableConfig = None& Safe Config Synchronization: Synchronizechart_dataacross passedconfigand_agent_config()(context variable), safely initializingconfigurabledictionary if missing or None. - List & Length Validation:
Validate that
labelsandvaluesare lists before checking lengths. - Float & Label Coercion:
Safely coerce numeric strings and ints in
valuesto floats, and convert label elements to strings. - Type Normalization:
Normalize
chart_typewith.lower().strip(). - Hermetic Unit Tests:
Add
backend/tests/unit/test_chart_tools_guards.pyverifying 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)
Fix and hermetic test suite opened in PR #23236: https://github.com/BasedHardware/omi/pull/23236
Payout address (USDC Polygon / Base / Arbitrum):
0xC345C07229307d4f1c7935aD2cAe48e390215808
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! 🙏