Skip to content

fix(memory): show memories saved under a context label - #4062

Merged
kovtcharov-amd merged 6 commits into
amd:mainfrom
kovtcharov:fix/memory-context-labels-visible
Sep 28, 2026
Merged

kovtcharov-amd merged 6 commits into
amd:mainfrom
kovtcharov:fix/memory-context-labels-visible

Conversation

@kovtcharov

Copy link
Copy Markdown
Contributor

A memory the model filed under "work" or "personal" was saved and never shown again. The remember tool offered a context label, and gaia memory bootstrap writes "work" rows. But a default session reads only "global" rows, and nothing in GAIA switches to another context. In a learning benchmark the user stated two standing rules, and the model saved them with context='work'. Sessions 2–4 ran on the same store, never saw the rules, and all three failed to follow them.

A default session now shows memories from every context, and that also fixes rows already on disk. An agent that picked its own context, such as email, keeps it plus "global". The model can no longer choose a label: remember and update_memory store under the agent's active context. I dropped the parameter rather than validating it. Validation would mean either rejecting the call, which wastes a turn, or quietly relabelling it, which is a silent substitution. The model can't know the agent's scoping anyway.

🔍 Technical details
  • The same "global means unscoped" rule applies to the reminder list in the per-turn context and to extraction's duplicate search. recall already searches every context unless the model filters.
  • Sensitive rows stay out as before.
  • A model that still passes context= gets the loop's structured "unexpected argument" error and can retry without it.
  • Docs updated: the memory guide's context section, which showed the model storing into "personal" by chat, and the SDK page's filter description and tool card. Also updated the bootstrap docstring that described the old global-only read.
  • The per-request retrieval in feat(memory): surface memories relevant to each request, with their age #4061 gets the same rule in a follow-up commit on that branch.

Test plan

  • pytest tests/unit/test_memory_context_visibility.py: 6 new tests on a real on-disk store. A "work" preference saved in one session is in the next session's system prompt, and a "personal" reminder reaches the next turn (both fail on main). Sensitive rows stay out. Email scoping holds. remember stores under the active context, and neither tool accepts context
  • pytest tests/unit -k "memory or bootstrap": 1108 passed. Two existing tests updated because they encoded the old global-only read and the model-chosen label
  • python util/lint.py --black --isort on changed files
  • gaia eval agent on the memory categories vs the committed baseline (memory tool schema changed)

The remember tool let the model file a memory under 'work' or 'personal', and
bootstrap writes 'work' rows, but a default session reads only 'global' rows
and nothing sets another context. Those memories were stored and never shown
again. In a learning benchmark two standing rules saved with context='work'
were missing from the next three sessions.

- Read side: a default ('global') session now reads every non-sensitive
  context in the stable prompt, the reminder context, and the extraction
  dedup search. An agent that set its own context (email) keeps it + global.
- Write side: remember and update_memory no longer take a context. New
  memories go under the agent's active context, so a model-picked label can't
  hide one.
@github-actions

Copy link
Copy Markdown
Contributor

Request changes — the core fix is right and well-tested, but widening the read scope also widens a gap in the "sensitive" privacy flag, and one doc still describes the old, now-removed behaviour.

Memories the model filed under a label like "work" or "personal" were written and never read back. Making a default session read every context (and taking the label away from the model) is the right call, and it repairs rows already on disk without a migration.

Two things to fix before merge:

  • Private reminders now reach the prompt. Marking a memory sensitive is documented as keeping it out of the system prompt, but the upcoming/overdue reminder list never checked that flag. It only ever showed default-scope items, so the gap was narrow; after this change it shows items from every context, so a reminder the user deliberately marked private can now be injected into the model's turn — which for a cloud model means it leaves the machine. The same list also skips the credential-masking step the other memory sections run. Worth closing the flag check here in this PR, since this is what makes it reachable. The PR's own "sensitive stays out" test covers the system-prompt path only, so an equivalent test on the per-turn path would lock it down.
  • The memory spec still documents the removed parameter. The architecture spec shows remember taking a context label, has several examples passing one (which would now raise), and still states the old "global plus active context" read rule. Per the project's doc-sync rule a behaviour change updates every doc that describes it, not just the guide and SDK page.

Also: the agent eval on the memory categories is still unchecked in the test plan. The project requires it whenever a tool's schema or docstring changes, which this PR does (a parameter was dropped) — please run it against the committed baseline before merge, or say explicitly why it's being waived.

Real-world evidence

N/A — no evidence-bundle.md was produced for this PR, and the change touches no CLI/API/MCP/UI surface directly; it is SDK-internal memory behaviour. The PR's own evidence is the six new unit tests against a real on-disk store, which the description reports as passing and failing on main. The outstanding gaia eval agent run is the evidence gap that matters here, since the change alters what the model is told it can pass to remember. My verdict rests on static review of the diff plus the surrounding memory code.

🔍 Technical details

🟡 Sensitive reminders bypass the sensitivity filter (src/gaia/agents/base/memory.py:2385)

_build_dynamic_memory_context() calls store.get_upcoming(...), and that query filters on due_at, superseded_by, reminded_at and (optionally) context — there is no sensitive = 0 condition (memory_store.py:1469-1490). Before this PR the call passed context="global" in a default session, so only global rows could surface. With _read_scope() returning None, every context's reminders now enter the per-turn block, including sensitive=1 rows filed under personal. docs/guides/memory.mdx:331 states sensitive data "will not be broadcast in the system prompt"; this path contradicts that. The knowledge path also runs _redact_credentials() (memory.py:2435) while the upcoming path does not.

                for item in store.get_upcoming(
                    within_days=7, context=self._read_scope()
                )
                if item["id"] not in self._reminders_surfaced and not item.get("sensitive")
            ][:10]

(Filtering in SQL via a sensitive = 0 predicate on get_upcoming is the cleaner fix if you'd rather not have the limit consumed by rows that get dropped afterwards.) A test mirroring test_sensitive_rows_stay_out against get_memory_dynamic_context() would pin it.

🟡 docs/spec/agent-memory-architecture.md still documents the removed context parameter

  • :996 — the remember() signature still lists context: str = "", and :1004 still says "Use context to scope memories".
  • :1009, :1143, :1298, :1312, :1328, :1333, :1336, :1350, :1364 — examples call remember(..., context="work"/"personal"), which now raises TypeError.
  • :1182-1183 — "System prompt includes global + active context items" and "remember() defaults to the active context (overridable per call)" are both now wrong.

CLAUDE.md's doc-sync rule ("a functional change must update EVERY doc that describes it") covers this file alongside the guide and SDK page you did update.

🟢 Dead local (src/gaia/agents/base/memory.py:2372)

ctx in _build_dynamic_memory_context() is now unused — the only consumer was the get_upcoming call that moved to _read_scope().

        store = self._memory_store

🟢 Duplicate scope logic (src/gaia/agents/base/memory.py:2434)

_get_context_items() re-derives the global → None mapping that _read_scope() already owns, and its context: str annotation no longer matches what it forwards. Since every caller passes self._memory_context, it could drop the parameter and call self._read_scope() directly — one place to change if the rule ever moves.

🟢 get_by_category_contexts(..., context="global") is now unreachable from production code

_get_context_items() maps "global" to None, so the explicit elif context == "global" branch (memory_store.py:1398) is only exercised by tests. Fine to keep as a store-level API, but worth a note in the docstring that the mixin no longer takes that path.

Strengths

  • The root cause is diagnosed precisely and the fix repairs existing rows with no migration — global meaning "unscoped" rather than "a context named global" is the right model, and recall already behaved that way, so the surfaces are now consistent.
  • Dropping the model-facing context parameter instead of validating it is the correct call, and the reasoning in the description (reject wastes a turn, relabel is a silent substitution) matches the project's no-silent-fallback rule.
  • tests/unit/test_memory_context_visibility.py tests through a real on-disk store across two sessions rather than mocking, so it reproduces the actual cross-session failure; the module docstring records the benchmark evidence for why.
  • Scoped agents are genuinely covered — the email agent's init_memory(context="email") path is asserted to still exclude other contexts' rows.

@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

Merged current main into this branch — it was behind, but nothing in the PR's own change had to move. The overlap with main was in the memory docs and memory.py, and all of it auto-merged.

🔍 Technical details

Merge commit 9b2b37473 (git merge origin/main, no rebase/force-push). Auto-merged: docs/guides/memory.mdx, docs/sdk/sdks/memory.mdx, src/gaia/agents/base/memory.py. PR content vs main: 7 files, +230/-55.

Tests: python -m pytest tests/unit/test_memory_context_visibility.py tests/unit/test_memory_mixin.py tests/unit/test_starter_skills.py -q → 496 passed, 15 skipped.

kovtcharov and others added 3 commits September 21, 2026 21:27
_build_dynamic_memory_context reads the scope through _read_scope() now,
so the old ctx binding is unused and pylint W0612 reds the gate.
Marking a memory sensitive is documented as keeping it out of the prompt,
but the upcoming/overdue reminder list never checked the flag. It only
ever showed default-scope rows, so the gap was unreachable; reading every
context makes it reachable, and a reminder the user marked private could
be injected into the turn — which for a cloud model means it leaves the
machine.

get_upcoming now filters sensitive rows in SQL, so private rows cannot
consume the limit and leave the visible list empty. The same list also
skipped the credential masking the other memory sections run, so it now
goes through _redact_credentials too. The dashboard keeps its access via
an include_sensitive query param, matching /api/memory/knowledge.

Also syncs docs/spec/agent-memory-architecture.md, which still showed
remember() and update_memory() taking a context label and still described
the old global-plus-active-context read rule.
@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

Closed the privacy gap this PR made reachable: a reminder the user marked private can no longer reach the model's turn.

Marking a memory sensitive is documented as keeping it out of the prompt, but the upcoming/overdue reminder list never checked the flag. It only ever showed default-scope rows, so the gap was unreachable — widening the read to every context is what made it live. A private reminder could then be injected into the turn, which for a cloud model means it leaves the machine.

Filtering happens in SQL rather than after the fact, so ten private rows can't consume the limit and leave the visible list empty. The same list also skipped the credential masking every other memory section runs, so it goes through that now too. The dashboard keeps its access through an include_sensitive parameter, matching what /api/memory/knowledge already documents.

Also synced the memory spec, which still showed remember() and update_memory() taking a context label and still described the old read rule.

🔍 Technical details

The fix. MemoryStore.get_upcoming gains include_sensitive: bool = False adding a sensitive = 0 predicate — consistent with get_all, search, and get_by_category*, which all already exclude sensitive by default; get_upcoming was the outlier. _build_dynamic_memory_context now wraps the result in _redact_credentials, whose own docstring says "only what reaches the model is masked" — this path reaches the model. /api/memory/upcoming exposes include_sensitive so the dashboard keeps showing them on request.

Three tests added to tests/unit/test_memory_context_visibility.py under TestSensitiveRemindersStayOutOfTheTurn, all three failing before the fix:

FAILED test_a_sensitive_reminder_never_reaches_the_turn
FAILED test_a_sensitive_reminder_does_not_crowd_out_a_visible_one
FAILED test_a_credential_shaped_reminder_is_masked

The middle one is the reason for filtering in SQL: 10 sensitive rows + 1 visible one, and the visible one must still appear.

Docs. In docs/spec/agent-memory-architecture.md: dropped context from the remember/update_memory signatures, removed it from the 8 remember(...) examples that would now raise, and rewrote the two read-rule lines. store(...) and recall(..., context=) examples are left alone — those APIs still take it. Verified with a scan across every docs/**/*.md{,x}: no remember()/update_memory() example passes context= anymore.

Tests.

$ pytest tests/unit/test_memory_context_visibility.py
9 passed

$ pytest tests/unit/test_memory_context_visibility.py tests/unit/test_memory_store.py \
         tests/unit/test_memory_mixin.py tests/unit/test_memory_router.py \
         tests/integration/test_memory_api_integration.py tests/integration/test_memory_integration.py
2 failed, 955 passed, 2 skipped

Both failures (test_fresh_install_gets_current_schema — schema version is 4 on main, test pins 3; test_consolidation_endpoint — 503, needs a live service) reproduce identically on origin/main.

Merged current main (branch was 129 behind). Clean, and I verified no duplicate blocks or stray markers landed: repo-wide conflict-marker grep empty, and all 370 merge-touched .py files AST-parse.

Still open from the review: the gaia eval agent run on the memory categories.

@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

Re-merged current main (129 commits further since the last sync) — clean, no conflicts left after resolving one docstring collision, and the memory test suite still passes in full. What's still missing before this can merge is the one item the last review left open: the gaia eval agent run on the memory categories, which this diff requires because it changes the remember/update_memory tool schemas the model sees.

I attempted it twice against a local backend and both runs came back INFRA_ERROR for reasons unrelated to this PR's code — this machine currently has several other agents each running their own gaia eval agent invocation plus ~19 concurrent Claude Code sessions, and the local LLM backend couldn't keep up: the second attempt's own trace shows every turn rejected with "server is busy processing other chat requests," then the backend went unreachable entirely. Not a result I can present as a verdict on the PR's behavior — no scenario actually got a scored agent turn.

Still needed before merge: gaia eval agent --category gaia_memory (15 scenarios), run somewhere with exclusive access to the LLM backend, compared against — or explicitly waived per — the eval requirement in CLAUDE.md.

🔍 Technical details

Merge. Fetched fix/memory-context-labels-visible, merged origin/main (was 129 commits behind). One real conflict in src/gaia/agents/base/memory.py: an unrelated main commit (#4038, tool-description budget) reformatted remember()'s docstring into an Args: block that still listed context: Scope — 'work'/'personal'/'global', colliding with this PR's removal of that parameter. Resolved by keeping the Args: format (required by the new --tool-descriptions lint gate) and dropping the stale context line — remember's signature already has no context param on either side, so this was purely a docstring conflict, not a logic conflict. Verified: no duplicate-block markers repo-wide after merge, all touched .py files AST-parse and py_compile clean, no duplicate function defs in memory.py.

Tests: pytest tests/unit/test_memory_context_visibility.py tests/unit/test_memory_store.py tests/unit/test_memory_mixin.py → 694 passed.

Lint: python util/lint.py --black --isort --tool-descriptions clean (83 flagship tool schemas within budget). python util/lint.py --all reports one pylint error (os.getuid no-member in src/gaia/security.py:428) — confirmed pre-existing on origin/main as-is, unrelated to this diff.

Eval attempts. First run used the shared ~/.gaia/config.json, which on this machine is pinned to a cloud model (amd.GLM-5.2-FP8) that 404s — every scenario failed before turn 1 with a provider error, not an agent-behavior signal. Re-ran with an isolated GAIA_CONFIG_FILE pointed at the local Gemma-4-E4B-it-GGUF default (confirmed via /api/system/status) to avoid touching the shared config other concurrent tasks may depend on. That run got further (memory_clear succeeded) but then hit backend saturation from concurrent Claude Code sessions/eval runs on this shared box, per the trace's own root_cause field.

@github-actions

Copy link
Copy Markdown
Contributor

🟡 The Memory dashboard's "Upcoming" panel now hides the user's own private reminders. The privacy fix correctly keeps sensitive reminders out of the model's turn, but it also changed the dashboard endpoint to drop them by default, and the dashboard doesn't ask for them. A reminder the user marks private silently disappears from their own Upcoming list, while the stats header still counts it — so the count and the list disagree.

Suggested fix: have the dashboard request sensitive items on this call, the same way its knowledge list already does, and add a test for that endpoint's default.

🔍 Technical details
  • src/gaia/ui/routers/memory.py — upcoming_items now defaults include_sensitive=False.
  • src/gaia/apps/webui/src/services/memoryApi.ts:155 — getUpcomingItems calls /memory/upcoming?days=${days} with no include_sensitive, so the dashboard gets the filtered list.
  • MemoryDashboard.tsx:468 already passes include_sensitive: true for getKnowledge. The owner's dashboard is meant to show sensitive rows; only prompt assembly should exclude them.
  • The upcoming_count in get_stats (memory_store.py:~2332) doesn't filter on sensitive, so the header count and the panel now disagree.

Fix: append &include_sensitive=true in getUpcomingItems. The agent-side filter in get_memory_dynamic_context still applies because that path calls get_upcoming with the default False.

@itomek

itomek commented Sep 28, 2026

Copy link
Copy Markdown
Collaborator

Folded into #4406, which combines this with the other three memory PRs so they can be tested as one change.

This one is fully contained there — GitHub refuses to repoint the base at the combined branch precisely because there are no commits left between them. Closing this once #4406 merges; nothing here is dropped.

🔍 Why it was combined rather than merged on its own

All four memory PRs edit the same MemoryMixin, so every pair conflicted and none could be validated without the others. Two behaviours only survived because the fold was done deliberately rather than by taking one side: the turn's tool record and the extraction read scope both sat on lines that moved to the background worker, and a plain merge dropped them. Details are in #4406's description.

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Sep 28, 2026
Merged via the queue into amd:main with commit 41d3cb3 Sep 28, 2026
41 of 45 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the fix/memory-context-labels-visible branch September 28, 2026 17:24
kovtcharov-amd added a commit to kovtcharov/gaia that referenced this pull request Sep 28, 2026
…ge (amd#4061)

Memory held useful lessons that the model almost never saw. The memory
section of the system prompt is fixed at session start and picks facts
by confidence alone, whatever the user is asking. Everything else only
surfaced if the model called `recall`, and it did so 4 times in a
2,121-task benchmark sweep. Surfaced memories also had no dates, so a
lesson learned months ago under different permissions looked as current
as one confirmed yesterday.

Each turn now adds the three stored memories most relevant to the
request to the per-turn context, which is prepended to the user message.
The cached system prompt doesn't change. A memory has to clear a
similarity floor, so an unrelated nearest match isn't shown. It must
also be in this context or global and not sensitive, credentials are
masked, and anything the system prompt already shows is skipped. Every
memory the model sees without calling `recall` now carries a short
"(learned 2026-06-03, last confirmed 2026-09-20)". The dates are
absolute, so the fixed prompt stays stable, and the per-turn context
already carries the current time.

<details>
<summary>🔍 Technical details</summary>

- Uses a vector-only FAISS search with an absolute cosine floor
(`TURN_RECALL_MIN_SIMILARITY = 0.5`), not `_hybrid_search`. RRF gives no
absolute floor, and hybrid search bumps confidence on every hit, which
would inflate anything shown passively.
- About the floor: it is set from memory-to-memory similarity in the
sweep stores (nomic-embed-text-v2). Unrelated pairs have a median around
0.34 and same-topic pairs sit above 0.8. It hasn't been measured on
query-to-memory pairs, and the eval below is where it gets checked.
- Cost: one embedding call before each turn when the index isn't empty.
Extraction already embeds the same text after the turn, so that later
call now hits the embedding cache. If embedding fails, the turn still
gets its time and reminders, and a warning is logged.
- "Last confirmed" is `updated_at`, which moves when the same memory is
stored again or updated.
</details>

## Test plan
- [x] `pytest tests/unit/test_memory_turn_recall.py`: 13 new tests on a
real SQLite store and FAISS index. The 6 positive ones fail on main.
Covers the exact injected line with its age, the top-3 cap, dedup
against the stable prompt, no confidence or use-count bump, context
scope (a default session reads every context, the same rule as amd#4062; a
scoped one reads its own), excluded rows (sensitive, reminder, below
floor), credential masking, embedder failure, stable-prompt ages, and
that the memory arrives on the user message while the system prompt
stays byte-identical
- [x] `pytest tests/unit -k memory`: 1101 passed. Hub chat/gaia memory
tests: 22 passed
- [x] `python util/lint.py --black --isort`
- [ ] `gaia eval agent` on the memory categories vs the committed
baseline (memory prompt content changed)

---------

Co-authored-by: Kalin Ovtcharov <[email protected]>
Co-authored-by: Ovtcharov <[email protected]>
Co-authored-by: Kalin Ovtcharov <[email protected]>
itomek added a commit that referenced this pull request Sep 28, 2026
Three of the four consolidated PRs were merged to main directly while this
branch was under test, so most conflicts here are the same work arriving twice.
Took main's arrangement of the lesson constants and the session-lessons block,
and kept this branch's two things main does not have: #4034's background
extraction, and the lesson-scope fixes the hardware run found.
pull Bot pushed a commit to bhardwajRahul/gaia that referenced this pull request Sep 28, 2026
…n their workspace (amd#4406)

Memory extraction used to run *before* the answer reached the screen, so
every turn that stated a fact paid the model call twice over — once for
the answer, once to decide what to remember. This moves extraction to a
background worker: the answer lands, the turn returns, and the
extraction follows. On a Ryzen AI machine that was measured at 19
seconds of the user's time given back on a single turn.

It also carries four fixes found while testing this against the memory
work that landed on main (amd#4061, amd#4062, amd#4066) — two of which only exist
*because* those changes now run together.

Closes amd#4034. The other three memory PRs merged to main directly; this
branch has been merged with main and carries only what main lacks.

### What's fixed here that isn't on main

- **A closed memory store could segfault the process.**
`MemoryStore.close()` took no lock, so agent teardown freed the SQLite
connection while the extraction thread was mid-statement. A segfault
aborts the whole process, so this would have taken the Linux unit job
down rather than failing four tests. `close()` now holds the connection
lock and every DB method refuses a call that lost the race.
- **A workspace lesson could reach another project.** amd#4066 scopes
lessons to one workspace and frames them against injection because their
content is raw tool output; amd#4061's per-turn recall reads every context
in a default `global` session. A lesson from project A could surface in
project B, unframed. **This one is live on main today.**
- **The same leak, one call further in.** The background extraction job
builds its "existing memory" list from the same unfiltered scope, so
another workspace's lessons reached that prompt too. Observed on
hardware, then fixed.
- **An ordinary fact could be silenced forever.** The lesson filter
keyed on `domain`, which the *extraction model* picks — so a turn that
merely mentioned a lesson got its ordinary facts tagged
`domain='lesson'` and suppressed from recall permanently. It now keys on
`source`, which only the write path sets.

### Test plan

- [x] `pytest tests/unit/test_memory_mixin.py
tests/unit/test_memory_turn_recall.py
tests/unit/test_memory_heal_lessons.py
tests/unit/test_memory_context_visibility.py
tests/unit/test_cli_memory_drain_on_exit.py
tests/unit/test_memory_extraction_grounding.py` — **389 passed**
- [x] `pytest tests/unit/` — 17,198 passed, 33 failed, **all 33
reproduce identically on main** (verified in a separate main worktree,
not via `PYTHONPATH`, which cannot baseline in this repo)
- [x] Real-world run on AMD Ryzen AI MAX+ 395 (Radeon 8060S, Vulkan, all
three models on GPU)
- [ ] `gaia eval agent` — not run; see note below

### Evidence

Every fix has a test verified to fail without it — each was disabled in
turn and the test watched go red.

**Extraction is off the answer path.** Answer rendered at `13:20:15`;
extraction finished at `13:20:34`. 19 seconds returned to the user on
one turn.

```
13:20:15 PERF process_query session=a1997a20 took=5.084s
13:20:15 [MemoryMixin] extraction started (context=global, waited 0.0s)
13:20:34 [MemoryMixin] extraction finished in 19.0s
```

**A lesson does not leave its workspace.** A real `tool_lesson` row in
workspace A, then a turn from workspace B — absent from both the
user-visible chat prompt and the extraction job's internal prompt.
Before the fix it appeared in the latter; after, the "existing memory"
list carries nine items and the lesson's id is not among them.

**A fact the model mislabelled still surfaces.** A row with
`domain=lesson` but `source=llm_extract` now reaches the turn:

```
Stored memories that may bear on this message:
  - [note] Tool call list_files on /tmp/gaia-scratch-… reported 0 total files. (learned 2026-09-28)
```

<details>
<summary>🔍 Full evidence table and method</summary>

Driven through the Agent UI in a real browser on `t-nx-strx-halo`,
against a Lemonade already serving Gemma-4-E4B. Proof for prompt-content
claims is the literal prompt sent to the model (llama-server
`--log-prompts-dir`), not the answer text — an answer can be right for
the wrong reason, and absence claims cannot be proven from an answer at
all.

| Claim | Verdict | Artifact |
|---|---|---|
| Answer renders before extraction finishes | CONFIRMED | `backend.log`
timestamps above |
| A memory outside the stable prompt still surfaces per-turn, with its
age | CONFIRMED | One prompt dump showing both halves: the stable `Known
facts` list (5 highest-confidence decoys) and the dynamic `Stored
memories that may bear on this message:` block carrying the target fact
|
| A memory under a non-global context label is visible | CONFIRMED |
Dashboard row with `CONTEXT=work-project` |
| A same-operation fail→fix in one turn is stored as a workspace-scoped
lesson | CONFIRMED | `knowledge` row, `domain=lesson`,
`source=tool_lesson`, `context=workspace:/…` |
| That lesson is absent from another workspace's chat prompt AND
extraction prompt | CONFIRMED | Both prompt dumps, zero hits; extraction
half required this branch's fix |

Two findings worth knowing, neither a defect in this PR:

- **Per-turn recall is invisible on a small store.** The stable prompt
records every memory it renders and recall skips exactly those, so with
only a handful of memories recall correctly has nothing left to surface.
Proving it needs enough memories to overflow the 4000-char stable cap.
This cost two test rounds before the mechanism was understood.
- **Nothing in the product sets a non-global memory context except the
email sidecar.** `set_memory_context()` has no callers, and
`remember()`'s docstring advertises a `context` parameter its signature
lacks.

Two unrelated bugs found along the way are filed separately as amd#4409 and
amd#4410.

**On the eval:** this branch changes no prompt wording, no tool schema,
and no tool registration — it adds none. The dynamic-context sections it
touches came from amd#4061/amd#4066, which are already on main. A scorecard
run would measure main's behaviour, not this diff, and there is no
committed flagship baseline to compare against.
</details>

---------

Co-authored-by: Kalin Ovtcharov <[email protected]>
Co-authored-by: Kalin Ovtcharov <[email protected]>
Co-authored-by: Ovtcharov <[email protected]>
Co-authored-by: Kalin Ovtcharov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents documentation Documentation changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants