Guide10 min read

Nikos Dritsakos, Founder

Code search, AGENTS.md and session memory: which context source answers which question

Code search finds where something is implemented, AGENTS.md says which rules an agent follows, and recorded sessions explain why the team made a decision. How Sourcegraph, AGENTS.md, Claude Code's local memory, Glen and Sentra compare on what they store and when an agent can retrieve it.

On this page
  1. TL;DR
  2. What "context" means for a coding agent
  3. Codebase indexing and code search
  4. Standing instructions: AGENTS.md and CLAUDE.md
  5. Local agent memory versus team decision memory
  6. Compare context sources by storage and retrieval
  7. Walkthrough: a decision recorded in Claude Code, found later in Cursor
  8. Where Glen fits against Sourcegraph, Sentra, and local memory
  9. Setup checklist for layering context sources
  10. FAQs
  11. Conclusion

TL;DR

  • Where is the implementation? Code search tools such as Sourcegraph help an agent find files, symbols, and changes.
  • What rule should the agent follow? Repository instructions such as AGENTS.md give an agent standing guidance for relevant work.
  • Why did the team make a decision? Glen lets teammates search decisions recorded across coding-agent sessions. Glen does not index the codebase or expand an agent’s context window.
  • Use code search for implementations, repository instructions for standing rules, and recorded sessions for decisions that were discussed but not documented elsewhere.

What "context" means for a coding agent

A coding agent retrieves code, standing instructions, and prior decisions from different sources. Context retrieval selects relevant material outside the current conversation, such as a function definition or a previous decision. Context injection places retrieved material in the agent’s task context. Neither expands the model’s context window. Selecting a relevant excerpt helps the agent use the space it already has.

Use a code search tool to locate an implementation by file or symbol. Use an AGENTS.md file to tell an agent which repository rules apply, such as which tests to run. Those instructions need not preserve the discussion that produced a rule.

To find why a decision was made, the agent needs a record of the earlier reasoning. Glen lets you search decisions captured from supported coding-agent sessions, provided the session was recorded and the searching agent has access. The phrase “context memory” can refer to local agent notes, repository instructions, or searchable team decisions. Compare these tools by what they store, when an agent can retrieve it, and what they leave out.

Code search helps a coding agent find the implementation it needs to inspect before making a change. Sourcegraph Code Search supports keyword and regex queries for matching text, symbol search for named code elements, and commit and diff search for changes. An agent can use a supported Sourcegraph integration to search for codebase context. Check Sourcegraph’s current integration documentation for the setup available to your agent. Sourcegraph can search specific branches and revisions. Code search is therefore a more useful label here than assuming every query works through the same indexing process.

Code search can show where code lives and how it changed. Explaining why someone chose an approach requires a record of that reasoning. A commit search may find that reasoning if a developer wrote it in the commit message. The consulted Sourcegraph docs do not establish retrieval of a teammate’s earlier coding-agent conversation when that reasoning never entered the repository or commit history.

Standing instructions: AGENTS.md and CLAUDE.md

AGENTS.md gives coding agents standing repository instructions, such as setup commands, test steps, and coding conventions. You write and maintain the file. Nested AGENTS.md files can provide instructions for a subproject. AGENTS.md is a cross-agent convention, but each agent determines how it discovers and loads those files.

Claude Code loads CLAUDE.md at the start of a conversation for persistent project instructions. Claude Code’s treatment of AGENTS.md depends on its version and project configuration. Check Claude Code’s current instruction-loading rules before relying on an AGENTS.md file or assuming it takes precedence over CLAUDE.md.

Instruction files provide context, not enforcement. A rule might tell an agent to use an existing job queue, but the file cannot make the agent comply. You must also keep the rule current. Unless you record why you chose that queue, the instruction alone cannot give a later agent the decision’s reasoning.

Local agent memory versus team decision memory

Claude Code’s auto memory can retain a developer’s corrections, preferences, and project decisions across sessions. Claude stores those notes locally, so opening the same repository on a teammate’s machine does not give that teammate access to them. Claude also does not save something after every session. If you work alone in Claude Code, that local memory may cover what you need.

Glen lets you search reasoning recorded in supported coding-agent sessions. If a teammate later asks why you chose one retry strategy over another, they need the reasoning from the earlier agent session, not just a note about your preferences. With a supported coding-agent plugin configured to record sessions, Glen lets people with access to the same organization search that history. When Glen returns source citations, open them to check the answer against the recorded conversation. Glen does not index the codebase or enlarge an agent’s context window. Use Glen when a teammate needs to find reasoning preserved in a completed, recorded agent session.

Compare context sources by storage and retrieval

The table separates what each source stores from how an agent retrieves it and what it cannot answer.

Context sourceHow it’s enteredRetrieval triggerBest-fit questionLimits
SourcegraphCode and commit history in connected repositoriesA developer or agent searches code, symbols, commits, or diffs“Where is this implemented, and how did it change?”The consulted docs do not establish capture of teammates’ coding-agent conversations.
AGENTS.md / CLAUDE.mdA person writes project instructions in files the agent readsThe agent loads applicable files according to its loading rules“What convention should the agent follow?”Instructions provide context, not enforcement or a record of past discussions.
Claude Code local memoryClaude Code saves selected notes on one machineClaude Code loads its memory index at conversation start and retrieves topic notes as needed“What correction or preference did my agent retain?”Memory does not automatically travel across machines, and Claude does not save every session.
GlenA supported coding-agent plugin records sessionsA connected agent searches recorded memory“Why did a teammate make this decision?”Glen does not index the codebase or guarantee recall on every turn.
SentraConnected company sources supply permission-scoped factsAn agent queries Sentra through MCP or API“What do company records say about this project?”Its cited docs do not establish automatic coding-agent session recording through MCP.

Walkthrough: a decision recorded in Claude Code, found later in Cursor

A developer can record the reasoning for a checkout retry limit in Claude Code, then have a teammate search for it from Cursor. This is an illustrative sequence based on Glen’s documentation, not a live test or a verified search result.

First, the developer installs the CLI with npm install -g @tryglen/cli, runs glen login and glen install --agent claude, and starts a new Claude Code session. In that session, the developer explains the retry decision and its rationale. Glen’s Claude Code documentation describes the hooks used to capture supported session activity. Before using this walkthrough to describe exactly which prompts, replies, tool results, workspace details, or commits are retained, verify those details against the current documentation.

Later, a teammate signs in to the same Glen organization and installs the Glen Cursor plugin using the steps in Glen’s Cursor documentation. In a new chat, the teammate asks, “Why is the checkout retry cap three? Check Glen before you change it.” Cursor can run glen search in its shell when needed. Glen’s Cursor documentation describes its recording and search behavior. In this example, the teammate explicitly asks Cursor to search; the workflow does not rely on Glen memory being supplied on every turn.

If the completed session is recorded and available to the teammate, Glen search may return an answer with citations to that session. The teammate should open those citations and check the recorded explanation and linked commit before changing the cap. A generated answer can misread a session or rely on an outdated decision, and this example does not guarantee a particular search result.

Where Glen fits against Sourcegraph, Sentra, and local memory

Sourcegraph fits when you need to find an implementation or trace a change across repositories. Sourcegraph can surface a decision’s rationale when someone put it in a searchable commit message. The cited Code Search documentation does not establish that it records teammates’ coding-agent conversations.

Sentra’s agent-memory documentation positions it as a way for agents to query permission-scoped information from connected company sources. Confirm the specific source types and access controls in Sentra’s current documentation before relying on them for a deployment. Glen has a narrower fit. Its coding-agent integrations record supported agent sessions so a teammate can search for a past decision and inspect citations to the session that produced the answer. Connecting an agent to Sentra through MCP should not be assumed to record its session turns in the same way.

You may not need either service if the knowledge stays close to one developer or one repository. Put standing project instructions in AGENTS.md or the instruction file your agent reads. For solo work, Claude Code’s local memory can retain preferences, corrections, and some decisions across sessions, though it does not travel across machines. Glen fits when several people or supported agents need to search the reasoning recorded in one another’s sessions.

Setup checklist for layering context sources

  1. Write short repository rules in AGENTS.md or the instruction file your agent loads. Keep standing rules there, such as test commands and coding conventions, rather than the history behind each decision.
  2. Add code search if you need to find implementations, references, or changes. Search code before asking a decision-memory tool where a function lives.
  3. Install the documented Glen integration for each agent that should record sessions. Follow the Claude Code setup or Cursor setup for that agent. For Claude Code, install the CLI, run glen login and glen install --agent claude, then start a new session. Confirm that the agent is connected to the intended Glen organization and that recording is enabled.
  4. Explain a real decision and its rationale in a completed agent session. For example, record why checkout retries stop after three attempts. Incognito does not write to team memory, while off mode neither records nor recalls.
  5. Have a teammate connect Cursor to the same Glen organization and start a new chat. Ask the agent to run glen search for the checkout decision. Cursor searches on demand, so do not expect guaranteed recall on every turn.
  6. Open the sources cited in Glen’s answer and check that they support the decision and remain current.

An MCP-only connection does not automatically record sessions or expand an agent’s context window. Glen does not document a self-hosted deployment option.

FAQs

  • Does Glen replace AGENTS.md or code search? No. AGENTS.md carries repository instructions, and code search finds implementations and commit history. Glen helps you search decisions recorded in coding-agent sessions.
  • Does connecting through MCP automatically record sessions? No. Glen’s MCP connection lets a client search memory, but it does not record that client’s chat sessions. Recording requires a supported agent plugin.
  • Does “context memory” mean a bigger context window? No. The phrase can refer to local notes, repository instructions, or searchable team records. Retrieval supplies relevant material to an agent within its existing context window.
  • Can incognito or off modes keep content out of team memory? Glen’s Claude Code documentation describes incognito as not writing to team memory and off mode as neither recording nor recalling content. Check the mode before discussing sensitive material.
  • Is Glen self-hosted? Glen does not document a self-hosted deployment option. If self-hosting is required, ask Glen to confirm its deployment options before choosing it.

Conclusion

If a decision’s reasoning lives in a recorded coding-agent session rather than the repository, Glen gives teammates with access a way to search for it and check the cited source. For setup and agent-specific recording and search details, see the Glen coding-agent guide.

More field notes

Fix your agents’ amnesia.

Start on your own or with up to two teammates. Your first 15,000 memories are free, no credit card.

Start free