refactor(plugin): hand mem0 search decisions to the agent#4992
Open
gabrielstein-mem0 wants to merge 3 commits intomainfrom
Open
refactor(plugin): hand mem0 search decisions to the agent#4992gabrielstein-mem0 wants to merge 3 commits intomainfrom
gabrielstein-mem0 wants to merge 3 commits intomainfrom
Conversation
The on_user_prompt hook previously ran a blind semantic search using the raw user prompt as the query and injected the top results unconditionally. That undermined the agent's judgment with low-quality context and made heavy API calls on prompts where memory wouldn't help. Replace with a decision rubric injected into context per turn. The agent decides whether memory would improve the response and, if so, runs targeted searches with metadata.type filters and proper query phrasing. Mirror the same rules in mem0-codex/SKILL.md so the skill (loaded once) and the hook (re-asserted per turn) agree. Skip gates preserved: prompts under 20 chars and missing MEM0_API_KEY. - on_user_prompt.sh: API call replaced with stdout rubric injection - hooks.json / codex-hooks.json: statusMessage updated to match new behavior - mem0-codex/SKILL.md: "On every new task" rewritten with search/skip rules, query phrasing guidance, metadata filter table, and a worked example
The plain-string source ("./mem0-plugin") parsed as a marketplace
without errors but caused /plugin install to fail with "Plugin 'mem0'
not found in any marketplace". Claude Code and Cursor require the
object form: {"source": "directory", "path": "..."}. Codex already
uses the object form (with "source": "local") in .agents/plugins.
This reverts commit a23bc9e.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
The
on_user_prompt.shhook previously ran a blind semantic search against the user's raw prompt and injected the top-5 results into context on every turn. This wasted API calls on prompts where memory wouldn't help, and the raw-prompt-as-query approach produced low-recall results that crowded the context window with noise.This PR restructures the hook to be a prompt-injection point rather than a search-execution point. On every substantive prompt, the hook now injects a decision rubric:
search_memoriescalls with different angles, noun-phrased queries ("auth module decisions"vs full sentences),metadata.typefilters scoped by intent (decision/anti_pattern/user_preference/convention).The agent — which has full conversation context — decides whether and how to search. The skill (
mem0-codex/SKILL.md) is updated with the same rules plus a worked example, so the agent has both a load-time reference (skill) and per-turn reinforcement (hook).