omi
omi copied to clipboard
[Bounty proposal] fix(edit-tools): guard None/invalid inputs and harden owner resolution in edit tools ($50 proposed)
Summary
In backend/utils/retrieval/tools/edit_tools.py, several input coercions, None guards, and owner UID resolution edge cases lead to unhandled runtime exceptions (AttributeError, TypeError, or crashes during LangChain invocations):
owner(config)crash whenconfigurableisNone:- When callers or LangChain runners pass a config where
configurableis explicitlyNone(e.g.{'configurable': None}),config.get('configurable', {}).get('user_id')raisesAttributeError: 'NoneType' object has no attribute 'get'. owner(config)only inspectedconfig.get('configurable', {}).get('user_id'), ignoring top-level keys likeconfig['user_id']orconfig['uid']used in direct tool calls and testing harness configurations.
- When callers or LangChain runners pass a config where
- Unvalidated inputs in
update_conversation,rename_person,edit_memory, anddelete_memory:- If LLMs pass
correction=Noneor empty whitespace toupdate_conversation, calling.strip()raisesAttributeError: 'NoneType' object has no attribute 'strip'. - In
rename_person, passing non-string or emptynew_nameraisesAttributeError: 'NoneType' object has no attribute 'strip'rather than returning a structured tool error. - In
edit_memory, passingNoneor non-stringnew_textraisesAttributeError: 'NoneType' object has no attribute 'strip'. - In
delete_memory, passingNoneor emptymemory_idraises unhandled exceptions rather than early domain validation.
- If LLMs pass
- Missing default
Noneforconfig: RunnableConfigparameter:- Tool methods declared
*, config: RunnableConfigas a required keyword argument without default= None. Direct tool invocations or direct testing without config raisedTypeError: missing 1 required keyword-only argument: 'config'.
- Tool methods declared
Proposed Changes
- Resilient
owner(config)Resolution &_get_configurableHelper: Safely extract user ID checkingconfigurable.get('user_id') or config.get('user_id') or config.get('uid'), handlingNoneor non-dictconfigurablegracefully. - Safe Input Guards Across All Edit Tools:
Validate non-empty strings for
correction,new_name,new_text, andmemory_id, returning informativetool_errormessages (invalid_correction,invalid_name,invalid_text,invalid_memory_id) instead of crashing. - Optional
config: RunnableConfig = None: Allow direct tool invocations with defaultconfig = None. - Hermetic Unit Tests:
Add
backend/tests/unit/test_edit_tools_guards.pyverifying owner resolution, None guards, empty strings, character limits, and config resilience (8 tests, 100% pass).
Bounty Proposal
Proposed bounty: $50 USDC
Payout address: 0xC345C07229307d4f1c7935aD2cAe48e390215808 (USDC Polygon/Base/Arbitrum)
I have implemented the complete fix and hermetic unit tests in PR #23240.
- Pull Request: https://github.com/BasedHardware/omi/pull/23240
- Unit Tests: 8/8 passing hermetically
- Payout Address:
0xC345C07229307d4f1c7935aD2cAe48e390215808(USDC Polygon/Base/Arbitrum)
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! 🙏