Skip to content

fix: harden memory tool input validation#5701

Open
MatthiasHowellYopp wants to merge 1 commit intocrewAIInc:mainfrom
MatthiasHowellYopp:feat/valkey-2-memory-tools-hardening
Open

fix: harden memory tool input validation#5701
MatthiasHowellYopp wants to merge 1 commit intocrewAIInc:mainfrom
MatthiasHowellYopp:feat/valkey-2-memory-tools-hardening

Conversation

@MatthiasHowellYopp
Copy link
Copy Markdown
Contributor

Description:

Part 2/4 of adding Valkey as a storage backend for CrewAI. This PR hardens the memory tools against malformed inputs that surface more frequently with the new storage paths.

What changed:

  • memory_tools.py — RecallMemoryTool and RememberTool now handle None, empty lists, and lists of empty strings gracefully, returning descriptive error messages instead of crashing. String inputs are normalized to lists. The queries and contents fields are now optional with min_length=1 validation, and both schemas use extra="forbid" to reject unexpected parameters.

  • en.json — Updated tool descriptions for recall_memory and save_to_memory to include explicit parameter format examples (e.g. {"queries": ["search term"]}), reducing LLM misuse of the tool interface.

Testing:

test_memory_tools.py (15 tests) — Covers None input, empty lists, empty strings, string-to-list conversion, deduplication across queries, and single vs. batch remember paths.

Add None/empty input handling to RecallMemoryTool and RememberTool.
Filter empty strings, convert string inputs to lists, and return
descriptive error messages. Update tool descriptions in en.json to
include explicit parameter examples.

Part 2/4 of Valkey storage implementation.
@MatthiasHowellYopp MatthiasHowellYopp force-pushed the feat/valkey-2-memory-tools-hardening branch from ce19b5e to 32ed03e Compare May 5, 2026 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant