docs: fix search method return value handling in integration and example docs #3208
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fix #3207
This PR fixes incorrect handling of the search method's return value structure in documentation examples across
docs/integrations/anddocs/examples/directories. The search method returns{"results": [...]}but manyexamples were accessing results directly or using incorrect field names, causing runtime errors when users follow these examples.
Fixes #(issue number - to be filled when issue is created)
Type of change
Changes Made
Problem Patterns Fixed:
mem['text']→mem['memory']for mem in memories→for mem in memories.get('results', [])memories['memories']→memories.get('results', [])Files Updated:
docs/integrations/ (10 files):
multion.mdx- Fixed field name and added results field accesslangchain.mdx- Added safe results field accesslanggraph.mdx- Added safe results field accessautogen.mdx- Fixed both search result handling locationsopenai-agents-sdk.mdx- Added safety checks for resultsagentops.mdx- Fixed iteration patternagno.mdx- Updated memory context constructionelevenlabs.mdx- Fixed memory extraction logicgoogle-ai-adk.mdx- Updated search_memory functionlivekit.mdx- Updated search results handlingdocs/examples/ (5 files):
ai_companion.mdx- Fixed field name and direct iteration issuespersonal-travel-assistant.mdx- Fixed wrong root field accessllamaindex-multiagent-learning-system.mdx- Added results field accessopenai-inbuilt-tools.mdx- Added compatibility handling for resultsmemory-guided-content-writing.mdx- Fixed direct iterationUnified Fix Pattern Applied:
Before (Incorrect):
How Has This Been Tested?
Please delete options that are not relevant.
Note: This is a documentation-only fix. The changes ensure examples match the current API structure without requiring code changes to the library itself.
Impact & Benefits
Checklist:
Additional Notes
This PR ensures that all integration and example documentation now correctly demonstrates the current mem0 API usage patterns. Users following these examples will no longer encounter KeyError or AttributeError exceptions,
significantly improving the developer experience for new users of the mem0 library.
The changes are backward-compatible and use safe access patterns (get() method with defaults) to handle edge cases gracefully.