Skip to content

feat(memory): Drop preference extraction for multi-actor runs - #788

Merged
dcramer merged 2 commits into
mainfrom
feat/memory-multi-actor-preference-gate
Jul 8, 2026
Merged

dcramer merged 2 commits into
mainfrom
feat/memory-multi-actor-preference-gate

Conversation

@dcramer

@dcramer dcramer commented Jul 8, 2026 •

Copy link
Copy Markdown
Member

Passive memory extraction no longer stores personal preference memories from runs with more than one run actor, even when every evidence citation points at a run-actor instruction. Multi-actor turns interleave first-person statements from different people, so a model mis-cite there is exactly where a cross-actor personal write is most costly; a genuine preference can wait for a single-actor run to restate it. Single-actor passive extraction, explicit memory tools, and supersession are unchanged.

The memory gate has two layers:

  • routeExtractedMemory receives run identity (run.actor + run.actors) and routes to the personal target only for a run with exactly one run actor whose citations are all run-actor instructions. Anything else — including an empty actor set on system runs — fails closed to drop, never a downgrade to conversation scope.
  • The extraction agent derives its allowed kind set from run.actors: on multi-actor runs the prompt omits the preference kind and rules entirely and adds an explicit block forbidding the laundering of first-person statements into knowledge/procedure. The deterministic gate stays anyway because extraction output is cached in task state for 7 days and retries can replay proposals cached before the gate existed.

The branch also fixes the chat runtime bug that made this gate unreachable in its motivating scenario. A pending message batched into another actor's fresh turn was committed to the session log as unattributed context: the reply executor resolved each queued explicit mention with its author's instruction provenance, then dropped that provenance when merging the bare Pi messages into prompt history, so the fresh-turn checkpoint stamped only the live actor's prompt and the batched author never joined run.actors. The fix makes the drain the commit point, per the specs/multi-actor-runs.md Membership Rule: the fresh-turn path durably appends each batched message to the session log with its own author's instruction provenance before the run starts — through the same lock-and-dedupe helper the parked-resume path already uses — then merges the same messages into the transcript, where the fresh-prompt checkpoint matches them as an already-committed prefix. piMessages stays the single transcript channel into a run (no new run-input fields), the dedupe also stops redeliveries from duplicating batched messages in the log, and a busy session-log lock defers the turn back to the mailbox instead of running with the batch uncommitted.

Review order: the runtime fix is contained to chat/runtime/reply-executor.ts; then the memory gate (junior-memory), then the eval. The new eval case is the acceptance test for the pair: the run actor's own well-cited preference stated in a batched multi-actor turn must not be stored under any memory kind — it fails on the gate alone without the runtime fix. The other multi-actor provenance cases guard against over-tightening (non-actor operational knowledge still stores as conversation memory), and integration tests cover the committed per-author provenance, the lock-busy deferral, and redelivery dedupe at the durable log boundary.

Known flake: the pre-existing batched-mention case's rubric can conflate the two users in reply phrasing because the eval harness renders every profile as the same display name; its DB assertions are stable. Harness display identity is worth a follow-up.

Fixes #776

Passive memory extraction must never store a personal preference from a run
that has more than one run actor. Multi-actor turns interleave first-person
statements from different people, so a mis-cited preference is where cross-actor
personal writes are most costly; a personal preference can wait for a
single-actor run.

Gate this in two layers. The deterministic routing gate now takes run identity
(run.actor plus run.actors) and allows the personal target only for a run with
exactly one run actor whose citations are all run-actor instructions; an empty
actor set (system runs) fails closed to drop. The extraction agent derives its
allowed kind set from run.actors and, on multi-actor runs, omits the preference
kind and preference rules from the prompt while adding an explicit no-personal
block. The routing gate is kept alongside the prompt gate because cached
extraction output can replay preference proposals cached before this gate
existed.

Refs GH-776
Co-Authored-By: Claude Fable 5 <[email protected]>
@vercel

vercel Bot commented Jul 8, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
junior-docs Ready Ready Preview, Comment Jul 8, 2026 6:24am

Request Review

@cursor cursor 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit fcc7d3d. Configure here.

Comment thread packages/junior/src/chat/agent/index.ts Resolved
…enance

A pending message batched into another actor's fresh turn was committed to
the session log as unattributed context: the reply executor resolved each
queued explicit mention with its author's instruction provenance, then merged
only the bare Pi messages into prompt history and dropped the provenance. The
fresh-turn checkpoint stamped only the live actor's prompt, so the batched
author never joined run.actors and multi-actor consumers (such as the memory
plugin's preference gate) saw a single-actor run.

Make the drain the commit point, per the specs/multi-actor-runs.md Membership
Rule: the fresh-turn path now durably appends each batched message to the
session log with its own author's instruction provenance before the run
starts, through the same lock-and-dedupe helper the parked-resume path uses,
then merges the same messages into the transcript. The fresh-prompt checkpoint
matches them as an already-committed prefix and reuses that provenance.
piMessages stays the single transcript channel into a run, and the dedupe also
stops redeliveries from duplicating batched messages in the log. When a live
resume holds the session-log lock, the turn defers so the mailbox redelivers
it rather than running with the batch uncommitted.

Add the eval acceptance case: the run actor's own well-cited preference stated
in a batched multi-actor turn must not be stored as any memory kind.

Refs GH-776
Co-Authored-By: Claude Fable 5 <[email protected]>
@dcramer
dcramer force-pushed the feat/memory-multi-actor-preference-gate branch from fcc7d3d to 54f4ee9 Compare July 8, 2026 06:22
@dcramer
dcramer merged commit bab6df6 into main Jul 8, 2026
19 checks passed
@dcramer
dcramer deleted the feat/memory-multi-actor-preference-gate branch July 8, 2026 06:37

This branch was successfully deployed

1 active deployment
Preview – junior-docs — 54f4ee96 Deployed Jul 8, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium trigger-evals Run evals on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

memory: drop personal preference extraction for multi-actor runs

1 participant