Skip to content

fix: keep main session aware of isolated groups - #125667

Merged
steipete merged 1 commit into
mainfrom
steipete/relaxed-gauss-fa04fa
Aug 18, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/relaxed-gauss-fa04fa

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where deployments using isolated DMs (session.dmScope: "per-channel-peer") together with per-group sessions could leave the main session with zero ambient group visibility. Operators then had to serialize group conversations into main to keep the primary agent aware of room activity.

Why This Change Was Made

Routed group topology and session.groupScope own whether a group is a distinct watch target; session.dmScope is orthogonal. A distinct group key is now registered as an ambient target, while a groupScope: "main" route already equals the main watcher and needs no cursor. The obsolete DM-scope revocation path was removed, explicit watches remain promoted and preserved, and no new configuration or migration is introduced.

User Impact

Multi-user front doors can isolate DMs and groups while the main session still receives compact group notices and the Watched Sessions prompt section. Existing provenance rows keep their meaning, and missing ambient rows seed on future human group turns.

Evidence

  • Pre-fix regression reproduced an empty ambient watch target set for dmScope: "per-channel-peer" plus groupScope: "per-group"; the repaired initSessionState boundary registers the isolated group.
  • node scripts/run-vitest.mjs src/auto-reply/reply/session.test.ts src/sessions/session-state-events.test.ts src/agents/watched-sessions-prompt.test.ts src/config/schema.help.quality.test.ts — 225 passed.
  • pnpm docs:check-mdx — passed for 776 files.
  • Targeted oxfmt --check, git diff --check, and the actual node scripts/check-changed.mjs selected gate passed; dry-run lanes were core, coreTests, and docs.
  • Fresh Codex autoreview on the final patch reported no accepted/actionable findings (overall 0.96).
  • LOC: production +5/-27 (net -22); tests +41/-58 (net -17); docs +11/-9 (net +2); total +57/-94 (net -37).
  • No live provider or channel run was used. This is not live proof: the deterministic SQLite cursor owner, initSessionState routing boundary, and prompt projection are covered directly.

AI-assisted with Codex. I understand and reviewed the resulting code and behavior.

Keep ambient main-session group notices working when direct messages use an isolated dmScope, while preserving explicit session watches and routed group topology.
@clawsweeper

clawsweeper Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 18, 2026 06:41
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Aug 18, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 18, 2026
@clawsweeper

clawsweeper Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 18, 2026, 2:48 AM ET / 06:48 UTC.

ClawSweeper review

What this changes

The PR makes ambient watches for per-group sessions independent of direct-message scope, updates cursor tests, and documents the corrected session-scope behavior.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open: removing the direct-message-scope gate fixes the default route, but a configured session.mainKey still receives an ambient cursor that no prompt surface recognizes, leaving the main agent unaware of its isolated groups.

Priority: P1
Reviewed head: f1cd367f0ad7a7e7331b20cf95ae8dd731515669

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch identifies and removes the correct current-main gate, but it misses the supported custom-main-key path needed to make its user-facing claim complete.
Proof confidence 🌊 off-meta tidepool Not applicable: Repository-state metadata identifies this as a maintainer PR, so the external-contributor proof gate does not apply; the supplied validation is focused test and check evidence only.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Repository-state metadata identifies this as a maintainer PR, so the external-contributor proof gate does not apply; the supplied validation is focused test and check evidence only.
Evidence reviewed 8 items Current-main defect: Current main suppresses and removes an ambient group cursor whenever dmScope is not main, which is the direct cause the PR removes.
Correct owner direction: The PR registers the cursor from the routed group key and preserves the configured main key, so groupScope rather than dmScope determines whether the target is distinct.
Remaining configured-main-key gap: The prompt accepts only the default agent:<id>:main key before reading ambient cursors, while the registration path can write to agent:<id>:<session.mainKey>; a configured main session therefore returns no Watched Sessions section.
Findings 1 actionable finding [P1] Honor session.mainKey when rendering watched sessions
Security None None.

How this fits together

Inbound group messages route either to the agent’s main session or to a separate group session. Separate group sessions seed an ambient cursor so later main-session prompts can name their activity and let the agent inspect it.

flowchart LR
A[Incoming group message] --> B[Session routing]
B --> C{Group scope}
C -->|main| D[Configured main session]
C -->|per-group| E[Isolated group session]
E --> F[Ambient watch cursor]
F --> G[Watched Sessions prompt]
D --> G
Loading

Before merge

  • Honor session.mainKey when rendering watched sessions (P1) - This registration correctly writes a custom main watcher such as agent:main:work, but prompt preparation only recognizes the default agent:main:main key. As a result, the new isolated-DM path remains invisible for every documented non-default session.mainKey; derive prompt eligibility from config and cover that route-to-prompt flow.
  • Resolve merge risk (P1) - Merging now leaves deployments with session.mainKey other than main with durable ambient cursors but no Watched Sessions prompt, so the stated awareness fix remains incomplete for a documented configuration.
  • Complete next step (P2) - The maintainer-labeled PR has a concrete mechanical completion, but protected-label handling keeps it out of automatic repair dispatch.

Findings

  • [P1] Honor session.mainKey when rendering watched sessions — src/sessions/session-state-events.ts:920-921
Agent review details

Security

None.

PR surface

Source -22, Tests -17, Docs +2. Total -37 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 4 5 27 -22
Tests 3 41 58 -17
Docs 2 11 9 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 57 94 -37

Review metrics

Metric Value Why it matters
Production versus test LOC production -22; tests -17; docs +2 The repair removes obsolete scope-revocation behavior while adding focused owner-boundary coverage.
Existing scope interaction 0 config keys added; 1 existing dmScope/groupScope interaction changed Existing isolated-DM deployments will begin creating ambient group-watch state, so configured-main-key behavior must match routing.

Stored data model

Persistent data-model change detected: serialized state: src/auto-reply/reply/session.test.ts, serialized state: src/auto-reply/reply/session.ts, serialized state: src/sessions/session-state-events.test.ts, serialized state: src/sessions/session-state-events.ts, unknown-data-model-change: src/sessions/session-state-events.test.ts, unknown-data-model-change: src/sessions/session-state-events.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Complete configured-main-key support (recommended)
    Use session.mainKey when recognizing the main watcher in every watched-session prompt path and add focused regression coverage before merge.

Technical review

Best possible solution:

Make watched-session prompt eligibility derive the same configured main key as routing and cursor registration, then cover a custom-main-key isolated-group turn through prompt rendering.

Do we have a high-confidence way to reproduce the issue?

Yes—source reproducible: configure session.mainKey: "work", route a human group turn to per-group, and the cursor is written to agent:main:work while prompt preparation rejects that key.

Is this the best way to solve the issue?

No—the producer-side removal of the dmScope gate is the right fix layer, but prompt eligibility must use the configured main key before this solves the documented behavior for all supported configurations.

Full review comments:

  • [P1] Honor session.mainKey when rendering watched sessions — src/sessions/session-state-events.ts:920-921
    This registration correctly writes a custom main watcher such as agent:main:work, but prompt preparation only recognizes the default agent:main:main key. As a result, the new isolated-DM path remains invisible for every documented non-default session.mainKey; derive prompt eligibility from config and cover that route-to-prompt flow.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 1cf7ec90d081.

Labels

Label justifications:

  • P1: The patch targets a broken main-agent awareness workflow for deployments that isolate direct messages while using per-group sessions.
  • merge-risk: 🚨 session-state: The PR changes durable ambient-watch registration and prompt-visible session associations for existing scope configurations.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: Repository-state metadata identifies this as a maintainer PR, so the external-contributor proof gate does not apply; the supplied validation is focused test and check evidence only.

Evidence

What I checked:

Likely related people:

  • steipete: Repository state identifies the author as a MEMBER and they authored this focused repair; deeper line-history attribution was unavailable from the partial clone. (role: current session-maintenance contributor; confidence: medium; commits: f1cd367f0ad7; files: src/sessions/session-state-events.ts, src/auto-reply/reply/session.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Make prompt eligibility use session.mainKey and add a route-to-prompt regression covering agent:main:work.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact head f1cd367f0ad7a7e7331b20cf95ae8dd731515669:

  • Pre-fix regression: isolated DMs plus groupScope: "per-group" produced an empty ambient watch target set.
  • node scripts/run-vitest.mjs src/auto-reply/reply/session.test.ts src/sessions/session-state-events.test.ts src/agents/watched-sessions-prompt.test.ts src/config/schema.help.quality.test.ts — 225 passed.
  • pnpm docs:check-mdx — 776 files passed.
  • Targeted oxfmt --check, git diff --check, and the actual node scripts/check-changed.mjs selected gate passed; dry-run lanes: core, coreTests, docs.
  • Fresh final-patch Codex autoreview — clean, no accepted/actionable findings (overall 0.96).
  • Exact-head CI run 32107997473 — success. Native OPENCLAW_TESTBOX=1 scripts/pr prepare-run 125667 passed in hosted_exact_or_recent_parent mode; it reused hosted exact-head evidence, so no separate remote Testbox provider, lease, or run URL was allocated.
  • LOC: production +5/-27 (net -22); tests +41/-58 (net -17); docs +11/-9; total +57/-94 (net -37).

ClawSweeper move reviewed and skipped with runtime evidence: materializeRuntimeConfig() calls applySessionDefaults(), which normalizes any configured session.mainKey to "main" and warns that the option is ignored. A direct load-mode probe with mainKey: "work" returned runtime mainKey=main; there is no reachable custom-main-key prompt branch in this repair. The stale schema/help/docs claim that custom anchoring works is a pre-existing inconsistency to reconcile separately.

Proof gap: no live provider or channel run was used. The deterministic SQLite cursor owner, initSessionState routing boundary, and Watched Sessions prompt projection are covered directly; this is not live proof.

@steipete
steipete merged commit 6afaf82 into main Aug 18, 2026
277 of 282 checks passed
@steipete
steipete deleted the steipete/relaxed-gauss-fa04fa branch August 18, 2026 06:57
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 20, 2026
Keep ambient main-session group notices working when direct messages use an isolated dmScope, while preserving explicit session watches and routed group topology.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation maintainer Maintainer-authored PR merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant