[Bounty proposal] fix(action-item-tools): guard string numeric coercion, fallback top-level config, and validate inputs ($50 proposed)
Summary
In backend/utils/retrieval/tools/action_item_tools.py, several input coercions and edge cases in get_action_items_tool, create_action_item_tool, and update_action_item_tool lead to runtime exceptions or failed tool executions:
- String numeric coercion failure (
TypeError: '>' not supported between instances of 'str' and 'int'):- In
get_action_items_tool: Iflimitoroffsetare passed as numeric strings by an LLM agent (e.g.limit="50"oroffset="0"), the bounds checkif limit > 500:raisesTypeError: '>' not supported between instances of 'str' and 'int'.
- In
- Missing top-level config and UID resolution:
- In
get_action_items_tool,create_action_item_tool, andupdate_action_item_tool: The code assumedconfigurable = cfg.get('configurable')is always a non-None dictionary. If callers pass top-level{"user_id": "..."}or{"uid": "..."}, or ifconfigurableisNone, this crashes withAttributeError: 'NoneType' object has no attribute 'get'or rejects valid configurations with"Error: Configuration format invalid".
- In
- Non-string date values crash on
.replace():- In
get_action_items_tool,create_action_item_tool, andupdate_action_item_tool: If an agent passes non-string types forstart_date,end_date,due_start_date,due_end_date, ordue_at(e.g. integer timestamps or booleans),.replace('Z', '+00:00')raisesAttributeError.
- In
- Description and ID validation:
- In
create_action_item_tool: Calling.strip()on non-string or NonedescriptionraisesAttributeError. - In
update_action_item_tool: Updating an item with empty/whitespace description (description="") was unvalidated, and missing/emptyaction_item_idlacked clean early validation.
- In
Proposed Changes
- Safe Integer Coercion Helper (
_safe_int): Safely parse integers and numeric strings while rejecting booleans,None, and invalid text. - Resilient Config & UID Extraction (
_get_config_and_uid): Safely handle non-dict or absentconfigurabledictionaries and resolveuidfromconfigurable['user_id'], top-leveluser_id, oruidacrossconfigandagent_config_context. - Safe Date Formatting:
Validate that date arguments are strings before calling
.replace('Z', '+00:00'). - Input Guards:
Validate
descriptionstring presence increate_action_item_tool, validate non-emptyaction_item_idand non-emptydescriptioninupdate_action_item_tool. - Hermetic Unit Tests:
Add
backend/tests/unit/test_action_item_tools_guards.pyverifying integer coercion, top-level UID resolution, date guards, and description/ID validations (8 tests, 100% pass).
Bounty Proposal
Proposed bounty: $50 USDC
Payout address: 0xC345C07229307d4f1c7935aD2cAe48e390215808 (USDC Polygon/Base/Arbitrum)
Fix and hermetic test suite opened in PR #23227: https://github.com/BasedHardware/omi/pull/23227
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! 🙏