19c1956630
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
40 lines
827 B
JSON
40 lines
827 B
JSON
{
|
|
"hooks": {
|
|
"SessionStart": [
|
|
{
|
|
"matcher": "startup|resume",
|
|
"hooks": [
|
|
{
|
|
"type": "command",
|
|
"command": "${CODEX_PLUGIN_ROOT}/scripts/on_session_start.sh",
|
|
"statusMessage": "Loading mem0 context..."
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"UserPromptSubmit": [
|
|
{
|
|
"hooks": [
|
|
{
|
|
"type": "command",
|
|
"command": "${CODEX_PLUGIN_ROOT}/scripts/on_user_prompt.sh",
|
|
"statusMessage": "Checking memory relevance...",
|
|
"timeout": 5
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"Stop": [
|
|
{
|
|
"hooks": [
|
|
{
|
|
"type": "command",
|
|
"command": "${CODEX_PLUGIN_ROOT}/scripts/on_stop_codex.sh",
|
|
"timeout": 10
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
}
|