Skip to content

Commit 31e7a5b

Browse files
docs: explain ambiguous project recovery flow
1 parent 2743714 commit 31e7a5b

1 file changed

Lines changed: 61 additions & 2 deletions

File tree

docs/AGENT-SETUP.md

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,29 @@ When present, `project_name` is used for writes from the repo and its subdirecto
4141

4242
**Recommended first call:** `mem_current_project` — confirms which project Engram detected before you start writing. Returns `project_source` (how it was detected) and `available_projects` (if cwd is ambiguous).
4343

44-
If a write tool returns `ambiguous_project`, the agent must not guess. Ask the user to choose one of `available_projects`, then retry only `mem_save` or `mem_save_prompt` with both fields:
44+
If a write tool returns `ambiguous_project`, the agent must not guess. This happens when the MCP server is started from a parent directory that contains multiple repositories, for example:
45+
46+
```text
47+
/Users/you/work
48+
├── alan-thegentleman/
49+
├── angular-18-jest-playwright/
50+
└── engram/
51+
```
52+
53+
The first write fails with an error like:
54+
55+
```json
56+
{
57+
"error_code": "ambiguous_project",
58+
"available_projects": [
59+
"alan-thegentleman",
60+
"angular-18-jest-playwright",
61+
"engram"
62+
]
63+
}
64+
```
65+
66+
Ask the user to choose exactly one value from `available_projects`, then retry only `mem_save` or `mem_save_prompt` with both recovery fields:
4567

4668
```json
4769
{
@@ -50,7 +72,44 @@ If a write tool returns `ambiguous_project`, the agent must not guess. Ask the u
5072
}
5173
```
5274

53-
This recovery path is accepted only after cwd detection is ambiguous and only when `project`, after trimming surrounding whitespace, exactly matches one of the reported `available_projects`. Do not send normalized variants or guesses: if `available_projects` contains `foo--bar`, the retry must use `foo--bar`, not `foo-bar`; empty/whitespace choices are rejected. In all non-ambiguous cases, `.engram/config.json`/git/cwd detection remains authoritative and the explicit `project` is ignored. Alternatives: `cd` into the target repo before starting the MCP server, or add repo `.engram/config.json`.
75+
On success, Engram writes to the selected project and reports the recovery source:
76+
77+
```json
78+
{
79+
"project": "engram",
80+
"project_source": "user_selected_after_ambiguous_project",
81+
"project_path": "/Users/you/work/engram"
82+
}
83+
```
84+
85+
### Ambiguous-project recovery rules
86+
87+
This is a narrow rescue path, not a free-form project override:
88+
89+
- Recovery is accepted only after cwd detection failed with `ambiguous_project`.
90+
- `project_choice_reason` must be exactly `user_selected_after_ambiguous_project`.
91+
- `project`, after trimming surrounding whitespace, must exactly match one of the reported `available_projects`.
92+
- Normalized variants and guesses are rejected: if `available_projects` contains `foo--bar`, retry with `foo--bar`, not `foo-bar`.
93+
- Empty or whitespace-only choices are rejected.
94+
- In all non-ambiguous cases, `.engram/config.json`/git/cwd detection remains authoritative and the explicit `project` field is ignored.
95+
96+
Mental model:
97+
98+
```text
99+
mem_save fails with ambiguous_project
100+
101+
Engram returns available_projects
102+
103+
agent asks the user to choose one exact value
104+
105+
agent retries with project + project_choice_reason
106+
107+
Engram validates the choice came from ambiguity
108+
109+
Engram saves to the selected project
110+
```
111+
112+
Alternatives: `cd` into the target repo before starting the MCP server, or add repo `.engram/config.json`.
54113

55114
**Read tools** (`mem_search`, `mem_context`, `mem_get_observation`, `mem_stats`, `mem_timeline`) accept an optional `project` override validated against the store. Omit it to auto-detect.
56115

0 commit comments

Comments
 (0)