Repository navigation
fix(agents): protect private memory in shared chats - #119198
Conversation
|
Codex review: found issues before merge. Reviewed August 4, 2026, 10:26 AM ET / 14:26 UTC. ClawSweeper reviewWhat this changesThis PR keeps workspace-root Merge readinessKeep open: the exact head still has the prior P2 where opaque shared CLI runs lose their shared-chat prompt guidance. The root-memory filter is otherwise coherently placed at the bootstrap owner boundary, but this maintainer PR also needs the required direct Codex contract check before merge. Priority: P1 Review scores
Verification
How this fits togetherWorkspace bootstrap files become model context before an agent run. Chat classification determines whether private root memory is eligible, and the prepared context then flows through embedded, CLI, Codex, and Copilot runtimes. flowchart LR
A[Workspace bootstrap files] --> B[Safe file loader]
C[Session chat classification] --> D[Bootstrap privacy policy]
B --> D
E[Bootstrap hooks] --> D
D --> F[Prepared agent context]
F --> G[CLI or embedded runtime]
G --> H[Model prompt and response]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +156, Tests +512, Generated 0. Total +668 across 23 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Use Do we have a high-confidence way to reproduce the issue? Yes, from source: invoke a CLI or embedded-to-CLI run with an opaque session key, Is this the best way to solve the issue? No: final bootstrap filtering is the right owner-boundary repair, but the same authoritative chat type must also reach CLI prompt construction before this is the best complete fix. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 52954a1fa8f4. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (7 earlier review cycles)
|
8c142ce to
5966efb
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
5966efb to
7e356dc
Compare
7e356dc to
ce9a663
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
40b88a0 to
79031ea
Compare
|
Maintainer landing note: every durable ClawSweeper move from reviewed head |
|
Merged via squash.
|
* origin/main: fix(agents): protect private memory in shared chats (#119198) perf(cli): skip absent gateway workspace dotenv (#119227) fix(agents): observe native provider prompt egress (#119219) fix(feishu): report bot identity retry failures (#102185) fix(memory): load configured providers for CLI search (#119186) fix(discord): count retained speech bytes test(discord): isolate exact speech overflow test(discord): cover exact speech overflow fix(discord): bound realtime exact speech
* origin/main: fix(agents): protect private memory in shared chats (#119198) perf(cli): skip absent gateway workspace dotenv (#119227) fix(agents): observe native provider prompt egress (#119219) fix(feishu): report bot identity retry failures (#102185) fix(memory): load configured providers for CLI search (#119186) fix(discord): count retained speech bytes test(discord): isolate exact speech overflow test(discord): cover exact speech overflow fix(discord): bound realtime exact speech
…licy-config-20260804 * origin/main: fix(agents): protect private memory in shared chats (#119198) fix(discord): count retained speech bytes test(discord): isolate exact speech overflow test(discord): cover exact speech overflow fix(discord): bound realtime exact speech
* fix(agents): protect private memory in shared chats Fixes openclaw#84466 Co-authored-by: Peter Steinberger <[email protected]> * fix(agents): propagate shared chat type across runtimes * fix(agents): enforce bootstrap privacy after hooks * test(agents): cover final bootstrap filtering * fix(agents): filter private memory before allowlists * fix(agents): preserve bootstrap source identity * refactor(agents): simplify bootstrap source identity * fix(agents): keep bootstrap source identity private * fix(agents): unify CLI runtime chat type --------- Co-authored-by: Peter Steinberger <[email protected]>
* origin/main: fix(agents): protect private memory in shared chats (openclaw#119198) perf(cli): skip absent gateway workspace dotenv (openclaw#119227) fix(agents): observe native provider prompt egress (openclaw#119219) fix(feishu): report bot identity retry failures (openclaw#102185) fix(memory): load configured providers for CLI search (openclaw#119186) fix(discord): count retained speech bytes test(discord): isolate exact speech overflow test(discord): cover exact speech overflow fix(discord): bound realtime exact speech
What Problem This Solves
Fixes an issue where shared group and channel sessions automatically loaded the workspace-root
MEMORY.md, exposing private long-term context contrary to the documented behavior that this file is only loaded for the main private session.Fixes #84466
Why This Change Was Made
The repair is applied at the bootstrap owner boundary. Bootstrap resolution uses an authoritative
chatTypewhen supplied, falls back to deriving the type from the session key, and re-filters the complete bootstrap list after allagent:bootstraphook mutation so shared-chat, subagent, and cron policy cannot be bypassed by file relabeling or aliases.Before initial session filtering, the resolver captures the root
MEMORY.mdsource identity already returned by the pinned workspace open. Standard and extra-file loaders carry its canonical opened path plus stat identity in a module-privateWeakMapkeyed by the exact loaded file object; extra-file conversion transfers that identity explicitly to the returned bootstrap record. The session snapshot cache only reuses arrays when the exact opened identity still matches. The final resolver first reapplies existing lexical/session/allowlist policy, then removes remaining files that share the root-memory canonical path orsameFileIdentityresult. This adds no request-timestatorrealpathpolling and does not change public bootstrap-file types or JSON.The bundled
bootstrap-extra-fileshook appends loader results by reference; the final resolver owns policy once, with the authoritative chat type and complete post-hook list.Threat model: trusted hooks can inject arbitrary bytes, so this is not a sandbox for hook code. It prevents OpenClaw-owned loaders and supported in-place relabeling from accidentally carrying the private root-memory source into non-private bootstrap context. Arbitrary cloning by trusted hook code is outside this contract. Missing, generated, or custom records without loader identity continue through the existing lexical fallback and do not throw.
Direct sessions continue to receive root
MEMORY.md; genuine nested memory and unrelated symlinks remain available. Existing subagent and cron restricted allowlists remain unchanged.The authoritative value is propagated through the affected embedded, primary attempt, CLI fallback, embedded-to-CLI, compaction, command-prompt, Codex, Copilot, and bundled bootstrap-hook bridges.
CLI preparation resolves one canonical
runtimeChatTypeas current-turnchatTypefirst, then storedsessionEntry.chatTypeas fallback, and passes that same prepared fact to both bootstrap resolution and system-prompt construction.This credits Peter Steinberger (@steipete) and extracts the narrow bootstrap privacy boundary from #99225 without importing that conflicted 273-file context-engine and session-policy expansion.
User Impact
Operators can use group and channel chats without private root memory being silently injected into shared model context, including after bootstrap hooks load a symlink alias or relabel a valid loader-produced record in place. Hooks also cannot relabel root private memory as an allowlisted subagent or cron bootstrap file. Direct/private sessions retain the existing memory behavior.
Compatibility ownership: optional
chatTypepropagation is additive. An undefined value preserves the existing session-key derivation fallback, all affected bundled and internal bridges carry the authoritative value when available, and this requires no config migration or operator action. The source-identity metadata is module-private and does not expand the Plugin SDK surface.Evidence
1aedd8f37e0bd40e2a71f50824896e24f24b21d4.79031eac36f760243d440ae96dcb4916a2f6a45e.+193/-36(net+157).+643/-53.+1/-1, reflecting the additive optional runtime parameter; this CI repair did not modify it.+122/-28(net+94); focused tests+221/-63.+5/-9(net-4); focused tests and relocation+138/-109.+3/-2; focused tests+78/-0.src/agents/bootstrap-files.test.ts: 46src/agents/workspace.bootstrap-privacy.test.ts: 9src/agents/workspace.load-extra-bootstrap-files.test.ts: 10src/agents/bootstrap-cache.test.ts: 8src/hooks/bundled/bootstrap-extra-files/handler.test.ts: 3src/agents/system-prompt-stability.test.ts: 4src/infra/fs-safe-import-boundary.test.ts: 2src/agents/cli-runner/prepare.test.tsandsrc/auto-reply/reply/agent-runner-execution-runtime.test.ts. Regressions cover opaque group/channel session keys with explicit current-turn metadata, bundled message-tool-only etiquette, current-turn precedence over stale stored direct metadata, and stored-session fallback.git diff --check: passed.oxfmtandrun-oxlintchecks for all five changed files: passed.oxfmtandrun-oxlint: passed.node scripts/check-changed.mjs -- <changed files>: remote routing had no ready provider. Trusted-source local fallback passed conflict-marker, environment, max-lines, formatting, SDK API baseline, deprecated-API, plugin-boundary, package-patch, deadcode, and temp-directory gates before stopping on unrelated shared-install type errors inpackages/terminal-core/src/ansi.tsand a missing generated@openclaw/session-url-contract/parse; no changed-file type error was reported.0.98); CLI P2 autoreview: clean (0.99), with no actionable findings.{ directInitialRequestCount: 1, sharedInitialRequestCount: 1, directRootMemoryPresent: true, sharedRootMemoryPresent: false }..artifacts/qa-e2e/privacy-bootstrap-7e356dc/and are not committed.@openclaw/fs-safecontract inspection:dist/root-file.jsresolves the canonical path before the pinned open and returns that opened path.dist/file-identity.jssuppliessameFileIdentity, including number/bigint and Windowsdev=0handling.openai/codexcommit1669c2403f793d0230065397dfc25f52b844244e:codex-rs/core/src/session/turn.rs:149-220andcodex-rs/core/src/session/turn.rs:293-352codex-rs/core/src/session/turn_context.rs:107-153