Skip to content

Commit 020f7e8

Browse files
committed
fix: require MemoryOS lookup before project changes
1 parent d9eb1fc commit 020f7e8

4 files changed

Lines changed: 33 additions & 13 deletions

File tree

AGENTS.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,24 @@ memory import-pending --dry-run
2424

2525
Do not fall back to the system Python or the repository-local `./memory` file. If `memory` is unavailable, install the project into the active virtual environment first.
2626

27-
## MemoryOS retrieval
27+
## Required MemoryOS Lookup
2828

29-
At the start of a task, search or load project context when the work may depend on an earlier decision, investigation, error, review, PR, or handoff. Use the installed CLI:
29+
Before substantive work that changes tracked files, project behavior, configuration, or leads to a Git commit, complete this lookup gate with the installed CLI:
3030

3131
```bash
3232
memory context <project> --session
33-
memory search "<specific topic>" --project <project>
33+
memory search --project <project> --query "<task terms>"
3434
```
3535

36-
Do not run a memory search by rote before every task. Use it when prior local knowledge is likely to change the work, then rely on the results that are relevant to the current task.
36+
Before creating a commit, also run:
37+
38+
```bash
39+
memory search --project <project> --query "commit convention release"
40+
```
41+
42+
Do not edit tracked files or create a commit until the lookup gate completes. It does not apply to simple read-only commands such as `pwd`, `git status`, or `memory --help`.
43+
44+
In commentary, report exactly one outcome: `MemoryOS lookup: found <note title or id>; applying <constraint>.`, `MemoryOS lookup: no relevant records for <terms>.`, or `MemoryOS lookup: unavailable: <reason>.`
3745

3846
## Rules
3947

@@ -46,6 +54,8 @@ Do not run a memory search by rote before every task. Use it when prior local kn
4654

4755
## MemoryOS workflow
4856

57+
The repository owner authorizes a local-only summary of the current task to the configured MemoryOS home. It must not send data to a network destination or include credentials, secrets, or full private file contents.
58+
4959
After every successfully completed task, after checks and before the final response to the user, the agent must update MemoryOS with the installed CLI:
5060

5161
```bash

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ memory learn --from-session --actor codex --source codex
4141

4242
MemoryOS is not built into Codex. Codex follows the instructions in a project's `AGENTS.md`, and those instructions tell it when to search local memory and when to save useful task results.
4343

44-
Generate a project-specific instruction file after installing MemoryOS. Use a temporary filename when the project already has `AGENTS.md`, then merge the generated MemoryOS sections into that file. If it has no `AGENTS.md`, rename the generated file to `AGENTS.md`.
44+
Generate a project-specific instruction file after installing MemoryOS. Use a temporary filename when the project already has `AGENTS.md`, then merge the generated MemoryOS sections into that file. If it has no `AGENTS.md`, rename the generated file to `AGENTS.md`. Projects with an older generated file must regenerate it or manually merge the latest MemoryOS sections.
4545

4646
macOS or Linux:
4747

@@ -57,7 +57,7 @@ Windows PowerShell:
5757
memory agents my-project --target "C:\path\to\my-project\MEMORYOS-AGENTS.md"
5858
```
5959

60-
Make sure the installed `memory` command is available in the environment Codex uses. With these instructions in the project, Codex can search when a task depends on earlier decisions, investigations, errors, or handoff context. It should not run a memory search by rote before every task, and it saves useful experience after completed work.
60+
Open Codex with the real repository root as its workspace. An `AGENTS.md` in a different folder, copy, or staging workspace is not loaded into that session. Make sure the installed `memory` command is available in the environment Codex uses. With these instructions in the project, Codex performs a required lookup before substantive changes and commits, reports the lookup outcome in commentary, and saves useful experience after completed work.
6161

6262
Continue with the [examples](#examples), [CLI reference](CLI.md), [architecture](ARCHITECTURE.md), and [privacy notes](PRIVACY.md) below. The repository contains the engine only; keep your actual memory folder outside it.
6363

memoryos/api.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,11 +1607,17 @@ def generate_agents(self, project: str, target: str | Path = "AGENTS.md") -> Pat
16071607
- Rebuild index: `memory rebuild`
16081608
- Doctor: `memory doctor`
16091609
1610-
## MemoryOS Retrieval
1610+
## Required MemoryOS Lookup
16111611
1612-
- At the start of a task, search or load context when earlier decisions, investigations, errors, reviews, PRs, or handoffs may be relevant.
1613-
- Use `memory context {project} --session` for a compact handoff, or `memory search "<specific topic>" --project {project}` for a focused question.
1614-
- Do not run a memory search by rote before every task.
1612+
Before substantive work that changes tracked files, project behavior, configuration, or leads to a Git commit:
1613+
1614+
1. Run `memory context {project} --session`.
1615+
2. Run `memory search --project {project} --query "<task terms>"`.
1616+
3. Before creating a commit, also run `memory search --project {project} --query "commit convention release"`.
1617+
1618+
Do not edit tracked files or create a commit until the lookup gate completes. It does not apply to simple read-only commands such as `pwd`, `git status`, or `memory --help`.
1619+
1620+
In commentary, report exactly one outcome: `MemoryOS lookup: found <note title or id>; applying <constraint>.`, `MemoryOS lookup: no relevant records for <terms>.`, or `MemoryOS lookup: unavailable: <reason>.`
16151621
16161622
## Current Memory Stats
16171623
@@ -1624,6 +1630,7 @@ def generate_agents(self, project: str, target: str | Path = "AGENTS.md") -> Pat
16241630
- Work local first.
16251631
- Do not send private, work, or health data to external APIs automatically.
16261632
- Preserve Markdown frontmatter IDs.
1633+
- The repository owner authorizes a local-only summary of the current task to the configured MemoryOS home. It must not send data to a network destination or include credentials, secrets, or full private file contents.
16271634
- After useful completed work, record important decisions, errors, commands, and architecture changes with `memory learn --from-session --actor codex --source codex`.
16281635
"""
16291636
path.write_text(body, encoding="utf-8")

tests/test_init.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,19 @@ def test_cli_reports_empty_home_and_next_step(self) -> None:
4646
self.assertIn("initialized: empty memory home", output.getvalue())
4747
self.assertIn("next: memory learn", output.getvalue())
4848

49-
def test_generate_agents_includes_retrieval_and_learning_workflow(self) -> None:
49+
def test_generate_agents_includes_required_lookup_and_learning_workflow(self) -> None:
5050
self.memory.init()
5151
target = Path(self.temp.name) / "MEMORYOS-AGENTS.md"
5252

5353
self.memory.generate_agents("demo", target)
5454

5555
body = target.read_text(encoding="utf-8")
5656
self.assertIn("memory context demo --session", body)
57-
self.assertIn('memory search "<specific topic>" --project demo', body)
58-
self.assertIn("Do not run a memory search by rote", body)
57+
self.assertIn('memory search --project demo --query "<task terms>"', body)
58+
self.assertIn('memory search --project demo --query "commit convention release"', body)
59+
self.assertIn("Do not edit tracked files or create a commit", body)
60+
self.assertIn("MemoryOS lookup: found <note title or id>", body)
61+
self.assertIn("The repository owner authorizes a local-only summary", body)
5962
self.assertIn("memory learn --from-session --actor codex --source codex", body)
6063

6164
def test_repeat_init_preserves_existing_user_note(self) -> None:

0 commit comments

Comments
 (0)