Skip to content

Memory: a new agent starts with the person's and its project's memory indexes (M2) - #120

Merged
lydakis merged 2 commits into
mainfrom
claude/project-thread-k9p3ok
Oct 10, 2026
Merged

lydakis merged 2 commits into
mainfrom
claude/project-thread-k9p3ok

Conversation

@lydakis

@lydakis lydakis commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

Before: a new agent knew about memory only through the memory skill. It had to run ~/.agent/memory show before it could see what earlier agents had saved.

After: a new agent's instructions already carry both indexes, after the skills and profiles indexes and before its role:

  • the person's ~/.agents/memory/MEMORY.md
  • its project's index, when its folder is in a project, from a task's worktree too

This holds for agents the app creates and for those an agent creates with agent run --new --agents, such as a coordinator's tasks. The skill now says to run show only when that section is missing or old.

This is M2 of the shipping plan.

The eval did not run. Decision #7 (run the memory eval on your Mac with real models) is unanswered, and the run needs your word and your Mac, so nothing was measured. This PR builds the composition the memory notes recommend, and the eval can still run against it. If the eval shows on-demand show doing as well, this change is easy to revert.

How:

  • client/src/policy.rs. Shared by the app and the CLI.
    • memory_indexes(workspace) returns the person's index, plus the project's when project(workspace) finds one.
    • instructions(workspace, role, memory) composes those indexes as they are, since an index carries its own # Memory in DIR heading.
    • An index that doesn't exist adds nothing. An unreadable or oversized one, or one behind a link to a missing folder, fails composition the way an AGENTS.md does.
    • The AGENTS.md loop and memory share one append helper.
  • Finding the project. project(dir) reads the name in the nearest .agents/project.toml. In a git worktree it looks first at the same place in the main checkout, so a branch's copy of the file never wins.
    • That mapping is read from the worktree's .git and commondir files rather than by running git, so composing spawns no process.
    • The app's memory script uses the same function; it used to run git rev-parse.
    • The client gains a toml dependency (0.9). It is already in the lock through the app.
  • Callers. The app's compose and the CLI's --agents/--profile composition both pass memory_indexes.
  • Prompt cache. The memory layer sits after everything that changes less often. A bot's instructions are fixed when it is made, so a later save doesn't touch any running bot's cached prefix.

For M3 (memory panel and "memory changed" lines, now in the rich rendering thread): this PR doesn't change the index format, the folders, or what the script writes. Two things affect M3:

  • Agents hold a snapshot of the indexes taken at creation, so M3's "memory changed" lines are what tell a long-running agent its snapshot is old.
  • agent_client::policy::memory_indexes(workspace) and policy::project(dir) are the one place that resolves which index files apply to a folder, so M3 can use them.

Also in this PR: main's app tests didn't build, because the test trigger in trigger/watch.rs lacked the turn_budget_tokens field that #118 added. One line adds turn_budget_tokens: None.

Declined review findings are logged in #108.

Checks:

  • cargo fmt --check and cargo clippy --workspace --all-targets -D warnings are clean.
  • The app node tests pass (218).
  • cargo test --workspace passes except remote::tests::no_ssh_config_changes_what_the_app_forces, which also fails on main in this Linux container.
  • New tests:
    • The composer places indexes after the indexes and before the role, skips a missing or empty one, and fails on an unreadable or dangling one.
    • A worktree finds its project and indexes through the main checkout, even when the branch's committed project file names another project.

Nothing visible to screenshot: this changes the text a new agent is given.

🤖 Generated with Claude Code

… indexes

The shared composer takes the memory indexes a client names and puts each
in as it is, after the skills and profiles indexes and before the role.
The app names the person's index and, in a project, the project's, so a
task no longer needs a first show. The project lookup runs git only when
no project file is found above the folder.

Also fixes main's app test build: watch.rs's test trigger lacked
turn_budget_tokens.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_019xtP72bEUJnpaJshaUzKwG
@lydakis lydakis changed the title Memory: a new agent starts with the person's and its project's memory indexes Memory: a new agent starts with the person's and its project's memory indexes (M2) Oct 10, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-10T08:36:39.778365Z f5a6e38 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bc0991f931

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/client.rs Resolved
Comment thread app/src-tauri/src/main.rs Resolved
Comment thread app/src-tauri/src/memory.rs Resolved
Comment thread client/src/policy.rs Resolved
The client now finds the memory indexes itself, so the CLI's --agents (how
a coordinator starts its tasks) composes them like the app does. The
project is found at the main checkout's place first, from the worktree's
.git and commondir files, so a task never takes a branch's copy of the
project file and composing spawns no git. A memory index behind a link to
a missing folder fails composition instead of being skipped.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_019xtP72bEUJnpaJshaUzKwG
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants