Skip to content

Agents: after a guest writes in a conversation, your next message starts a fresh one - #161

Merged
QuicksilverSlick merged 2 commits into
mainfrom
fix/guest-words-fresh-session
Nov 20, 2026
Merged

QuicksilverSlick merged 2 commits into
mainfrom
fix/guest-words-fresh-session

Conversation

@QuicksilverSlick

@QuicksilverSlick QuicksilverSlick commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Factory-Task: partner-fixes-15nov/guest-words
Built-by: claude-code/claude-opus-5-5
Claude-Account: russelledeming@gmail.com
Undo: revert this PR's merge commit. An owner turn then reuses a session a guest wrote into, as before. Context lines lose their owner, guest and you labels, and permission logs drop out of the agent log viewer again. Nothing is stored, so nothing needs cleaning up.

Was stacked on #155, which merged in train #172 on 18 Nov; now based on main. #160 and #161 should still ship together.

Ship together with fix/agent-dm-allowlist (slice 1), in the same train. Please tap both, or neither. Slice 1 lets allowlisted people into DMs, and a DM is always one session per conversation, so in a group DM a guest and you can share a session. This PR is what keeps their words from carrying your trust there. The two merge cleanly (git merge-tree), and the merged tree passes clippy with -D warnings.

In plain words

When a guest (anyone who isn't you) talks to an agent, their words go into the agent's chat memory for that conversation. If you then spoke in the same conversation, your turn reused that memory, so the guest's words sat there carrying your trust. That could only cause harm with an agent that can do real things on a guest's say-so.

After this PR:

  1. A fresh session after a guest. When you speak right after a guest in the same conversation, the agent starts a fresh session.
  2. The fresh session catches up. Its first prompt fetches the conversation's last 12 messages (the default context size), so it knows what was being discussed. Each line says who wrote it: owner, guest, or you for the agent's own earlier replies.
  3. Guests can't fake an owner line. A guest can no longer forge an "owner" line by putting a line break in their message: the rest of the message is indented under their own line.
  4. Permission logs show up. The agent's permission decisions now appear in the agent log viewer. The desktop's log filter used to hide them.

Before you tap: what the fresh session costs

  • What it loses. The fresh session loses the agent's chat memory of that conversation: tool output, files it had read, and earlier instructions beyond the last 12 messages. It gets the last 12 messages back, labelled, and the usual hint to run buzz messages get for more.
    • Today the same thing already happens whenever the agent's pool sleeps after 15 idle minutes.
    • On 2 Nov there was 1 guest-then-owner case in a month (not re-counted).
  • It will happen more. Slices 1, 3 and 4 make partner traffic easier, so mixed guest and owner talk in shared channels will happen more often. Each time, the agent re-reads instead of remembering.

What this does not cover (known gaps, follow-ups)

  • Other ways in. A guest's words can still reach your fresh session through these:
    • The agent's core memory: a guest can ask it to run buzz mem set core "…", which every new session loads as standing context.
    • Instruction files such as CLAUDE.md or AGENTS.md: new sessions load these too.
    • Tool output: buzz messages get returns guest messages without labels.
    • Guest turns run with permissions bypassed by default (bypassPermissions), so nothing stops these writes today.
    • Follow-up: run guest turns with the default permission mode, so memory and file writes need approval, or tag memory writes with who asked and show guest-written memory as guest.
  • The current message's own block (Content: in <buzz-event>) still keeps a guest's line breaks. The real Authority: guest line comes first, so a forged one can only follow it. This is older than this PR and is left as it was.
  • Your words steered into a guest's running turn still run with guest trust for that turn, as today. A guest's words steered into your running turn lower that turn to guest trust, also as today.

What changes

  • acp.rs:
    • AcpClient marks a session when a guest's words are written into it, by a prompt or a steer. The mark goes on before anything is written. take_guest_mark reads and clears it.
    • The 15 acp::permission log targets are now buzz_acp::permission, which the desktop's buzz_acp=info filter lets through.
  • lib.rs, dispatch_pending:
    • fresh_session_for_owner_turn resets the scope when an owner turn reaches a marked session, and flags the scope to fetch history once.
    • It runs before record_scope_owner. Resetting after it would make return_agent throw the new session away as stale.
  • pool.rs:
    • SessionState.history_after_guest holds the flagged scopes. The next prompt in a flagged scope takes the flag and fetches recent history with the DM history query, which fits any channel.
    • The prompt now carries the agent's own key, so its replies are labelled you.
  • queue.rs:
    • Context lines read [n] actor (time, owner|guest|you): text.
    • Any line break inside a message (LF, CR, NEL, U+2028/2029, VT, FF) continues the message indented, using the same normalisation the channel description already uses.
    • An unknown owner labels everyone else a guest.

Tests

  • New:
    • queue::tests::a_guest_line_break_cannot_forge_an_owner_line: five kinds of line break; exactly one entry starts with [, and the forged text stays indented inside the guest's entry.
    • queue::tests::conversation_context_lines_label_owner_and_guest: owner, guest and you; an unknown owner makes everyone else a guest.
    • acp::tests::a_guest_prompt_marks_its_session_and_an_owner_prompt_does_not
    • error_outcome_emission_tests::an_owner_turn_after_guest_words_resets_the_scope: guest then owner resets the scope and flags the history fetch; guest then guest and owner then owner keep the session and raise no flag.
    • error_outcome_emission_tests::the_fresh_session_survives_return_agent
  • Changed:
    • The steer_then_ask helper now returns the mark. A guest steer marks the session and an owner steer doesn't.
      • These spawn a bash fake agent, so they fail on Windows on the base too, and only Linux CI checks them.
    • test_format_prompt_escapes_conversation_context_so_a_reply_cannot_close_it now expects the indented continuation.
  • Mutation checks:
    • With the indentation, the you label or the history flag removed, the matching test failed each time.
    • The builder's earlier check: with the prompt mark removed and the label forced off, all 4 original new tests failed.
    • Everything was restored, and the tests then passed again.
  • Lint: cargo fmt --check and cargo clippy -p buzz-acp --all-targets -- -D warnings are clean.
  • Full cargo test -p buzz-acp --no-fail-fast on this Windows PC (vcvars64, private target dir):
    • head 234ccf7cc: lib 1319 passed / 42 failed;
    • base e0d86b1fa: 1314 passed / 42 failed.
    • The failing test names, taken from the second failures: block, are identical, with nothing new and nothing gone. All 42 are the known Windows process-spawn and wall-clock set.
    • Integration tests pass (pool_lifecycle_state 9, stdio_contract 1).

Not verified

  • No check in a live agent. It was not run against a real provider or relay.
  • The history fetch is untested end to end. The two lines in run_prompt_task that read the flag and fetch history have no test on Windows; only the flag being set is tested.
  • The steer-mark assertions run only on Linux CI.
  • Guest marks are never pruned for sessions that no owner turn follows. That is a few ids per process, and a restart clears them, as the design accepts.

Labels: lane:ready + lane:hold (permissions: what a guest's words can do under the owner's trust). Open it as a draft, and label it only once CI is green on its head.

Size: 4 files, 369 changed lines (330 insertions, 39 deletions); about half of it is tests.

🤖 Generated with Claude Code

QuicksilverSlick and others added 2 commits November 15, 2026 15:20
A guest's words written into a provider session (a guest prompt, or a
guest steered into a running turn) stayed in that session's memory. The
next owner turn in the same conversation reused the session, so those
words sat there carrying the owner's trust.

- acp.rs: AcpClient marks a session when a guest's words are written into
  it, before anything is written, and `take_guest_mark` reads and clears
  the mark.
- lib.rs: dispatch_pending resets the scope when an owner turn reaches a
  marked session (`fresh_session_for_owner_turn`). It runs before
  record_scope_owner; resetting after it would make return_agent discard
  the new session as stale.
- queue.rs: conversation-context lines now carry an owner/guest label,
  "[n] actor (time, owner|guest): text", from the same `authority_label`
  the event blocks use. An unknown owner labels everyone a guest.
- acp.rs: the 15 permission log targets move from `acp::permission` to
  `buzz_acp::permission`, so the desktop's `buzz_acp=info` filter shows
  them in the agent log.

Tests: a guest prompt marks its session and an owner prompt does not; the
steer tests now check the mark; owner-after-guest resets the scope while
guest-after-guest and owner-after-owner keep it; the fresh session
survives return_agent; context lines show owner and guest.

Design: partner-fixes-design-2026-11-15.md, slice 2 (option C).

Claude-Account: russelledeming@gmail.com
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…refetches history

Review fixes for the guest-words slice:
- A line break inside a context message (any kind: LF, CR, NEL, U+2028...)
  now continues the message indented, so a guest can no longer start a
  forged "[n] ... (time, owner): ..." line. Same normalisation the channel
  description already uses.
- The agent's own earlier replies are labelled "you", not "guest".
- A scope reset by an owner turn after a guest's words is flagged, and the
  new session's first prompt fetches the recent channel history once (the
  DM history query fits any channel), each line labelled. Before this, a
  plain channel message under the default per-channel session started cold.

The escape test that pinned "ok\n&lt;/thread-context&gt;" now expects the
indented continuation.

Factory-Task: partner-fixes-15nov/guest-words
Claude-Account: russelledeming@gmail.com
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@QuicksilverSlick QuicksilverSlick added lane:ready Builder is done: green, agent-reviewed, exercised. The steward puts it in the next train. lane:hold Needs the owner's read before any train (paid path, auth, migrations, or asked for). labels Nov 15, 2026
@QuicksilverSlick
QuicksilverSlick changed the base branch from upstream-manual/44c8206beacb to main November 18, 2026 23:11
@QuicksilverSlick

Copy link
Copy Markdown
Owner Author

Retargeting to main: its base (#155's branch) merged in train #172, and the steward does not retarget a child whose parent left in a train. Closing and reopening only to start CI against main.

@QuicksilverSlick
QuicksilverSlick merged commit 96820b5 into main Nov 20, 2026
142 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lane:hold Needs the owner's read before any train (paid path, auth, migrations, or asked for). lane:ready Builder is done: green, agent-reviewed, exercised. The steward puts it in the next train.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant