1. Capture: hooks, not save tools
Most memory tools expose a save call and hope the model uses it. Glen's plugins attach to lifecycle hooks the agent fires anyway, and each hook runs one glen CLI command. The model never has to think about memory for capture to happen.
| Agent | Hooks Glen uses | What gets recorded |
|---|---|---|
| Claude Code | SessionStart, UserPromptSubmit, Stop, PostToolUse on Bash | Prompt, reply, tool calls and results, thinking blocks, repo, branch, commits |
| Codex | The same four, in ~/.codex/hooks.json | Prompt and final reply |
| Cursor | sessionStart, beforeSubmitPrompt, afterAgentResponse, afterShellExecution | Each prompt and response |
| Grok Build | Plugin installed by glen install --agent grok | Sessions, with recall through glen search |
| Pi | Package installed by pi install npm:@tryglen/pi | Sessions, with recall each turn |
The PostToolUse hook on Bash links every git commit to the session that made it. That link is what later lets glen code-search go from a line of code back to the conversation behind it.
2. Store: one organization memory
Captured turns go to a hosted memory owned by your organization. Integrations add public Slack channels, GitHub (which can include private repos), tickets, docs and meeting transcripts. You don't manage an index or a schema; you install plugins and connect sources.
Two things happen to the store over time. Decisions get reversed, and Glen aims to follow the one that stuck. And some memories turn out wrong: glen forget stops one being recalled, and glen restore reverses that.
3. Recall: injected or searched
- Injected. In Claude Code and Codex, UserPromptSubmit sends the prompt with repo and branch, and matching memories join the context before the model reads it. Pi recalls at the start of every turn.
- Searched. Cursor and Grok Build can't add context from a hook, so a rule tells the agent to run
glen search. Any agent or person can do the same. - Traced.
glen code-search <path:start-end> "<question>"follows git blame to the agent sessions that wrote those lines.
The same pipeline over MCP
Agents without a Glen plugin can reach the memory through the remote MCP server at https://mcp.tryglen.com/mcp (Streamable HTTP, OAuth 2.1 or a personal API key). It exposes 22 tools, among them glen_search, glen_code_search, glen_forget and glen_import, with a 60 second request limit and a 4.5 MB request size limit. Setup per client is covered on memorymcp.dev.
Does the pipeline pay for its round trips? Glen's replay of 100 merged PRs found 29% fewer tokens and 21% faster runs with memory, quality at parity or better. Recall in that test was injected before the first turn.
Frequently asked questions
How does an AI agent retrieve memories?
Either the memory is injected into context before the model reads the prompt, or the agent calls a search tool when it decides it needs past context. Glen does injection where the agent's hooks allow it and search everywhere.
Does agent memory slow every prompt down?
Each hook is a network round trip. In Glen's PR replay, runs with memory were still 21% faster overall with that time counted.
What does Glen record from Codex?
The prompt and the final reply for each turn, plus repo and branch, through hooks that glen install registers in ~/.codex/hooks.json.
Can I delete a wrong memory?
Run glen forget on it and it stops being recalled. It is reversible with glen restore, so a mistaken forget can be undone.