Skip to content

fix(agents): preserve opaque session key casing - #127279

Merged
obviyus merged 1 commit into
mainfrom
fix/subagent-session-reconciliation-case
Aug 22, 2026
Merged

obviyus merged 1 commit into
mainfrom
fix/subagent-session-reconciliation-case

Conversation

@obviyus

@obviyus obviyus commented Aug 21, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Subagent reconciliation lowercased whole session keys when an exact key was absent. Matrix room IDs and Signal group IDs are opaque and case-sensitive, so a terminal case-distinct sibling could be mistaken for the child run and reported as a successful completion.

Root cause

loadSubagentSessionEntry reimplemented session-key comparison with an Object.entries() lowercase scan instead of using the session store's canonical key normalizer.

Fix

Keep the exact fast path, then perform one lookup with normalizeStoreSessionKey. This preserves structural casing normalization without folding opaque peer IDs, removes the O(N) fallback scan, and adds owner-boundary coverage for Matrix, Signal, and the structural control.

Supersedes #122142 and #122141. Based on the root-cause fix and regression coverage contributed by @Alix-007 in #122142; commit credit retained.

Proof

  • Pre-fix production SQLite probe: Matrix and Signal each returned completion/ok for an absent mixed-case child with only the lowercase sibling stored.
  • Regression test before fix: 2 opaque-collision failures; structural control passed.
  • node scripts/run-vitest.mjs src/agents/subagents/registry: 17 files, 534 tests passed.
  • Focused Oxfmt and Oxlint: passed.
  • pnpm tsgo: passed.
  • pnpm check:test-types: passed.
  • Post-fix production SQLite probe: Matrix missing; Signal missing; structural control completion.
  • Production LOC: +2/−15 (net −13). Tests: +60.

Telegram exact-head drive passed after the local model-review gate. A real QA user sent Please answer with OPENCLAW_E2E_OK only. in a DM (Bot API message 1750); the SUT emitted two typing events and replied OPENCLAW_E2E_OK (message 1751). In the same run, production SQLite reconciliation reported Matrix missing, Signal missing, and structural casing completion; all three scenario assertions passed. One mock-provider request was recorded. Side effects: one user message and one SUT reply; no edits, deletions, or reactions.

Maintainer decision

Proceed with the focused canonical lookup repair. A wider session audit is not required for this PR. This task explicitly stops before merge.

Use the canonical store-key normalizer when subagent reconciliation falls back from an exact lookup.

Co-authored-by: Alix-007 <[email protected]>
@clawsweeper

clawsweeper Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Aug 21, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P1 High-priority user-facing bug, regression, or broken workflow. labels Aug 21, 2026
@clawsweeper

clawsweeper Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 21, 2026, 1:49 PM ET / 17:49 UTC.

ClawSweeper review

What this changes

This PR makes subagent reconciliation use canonical session-key normalization instead of lowercasing whole keys, with Matrix, Signal, and structural-key regression coverage.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open. The patch replaces the unsafe fallback with the established session-key canonicalizer and preserves structural matching while rejecting case-distinct Matrix and Signal peers; current main still has the unsafe whole-key lowercase scan. The PR is correct, has meaningful after-fix evidence, and needs normal maintainer handling because it is behind main and labeled maintainer.

Priority: P1
Reviewed head: f0aee74aff6d319aaa4f078101f21a4e2bd0b65d

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, net-negative repair with relevant regression and after-fix behavior evidence; only the current-base refresh remains.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR body provides after-fix production SQLite outcomes for both collision cases and a structural control, plus a real transport drive; no additional contributor proof is needed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body provides after-fix production SQLite outcomes for both collision cases and a structural control, plus a real transport drive; no additional contributor proof is needed.
Evidence reviewed 6 items Current-main defect: Current main falls back to comparing every persisted key after toLowerCase(), which can treat a case-distinct opaque peer as the requested child session.
Canonical contract: The established normalizer lowercases structural segments while preserving Matrix room tails and Signal group segments; its tests define those opaque identifiers as case-sensitive.
Patch aligns with owner: The PR retains the exact lookup and then indexes the cached canonical rows using normalizeStoreSessionKey; its added tests reject Matrix and Signal case collisions while retaining a structural-case control.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw --help

Result: PASS (completed)

pnpm openclaw --help
runner@runnervm76f27:/tmp/clawsweeper-live-proof-127279-DxRv1u/target$ pnpm openclaw --help
$ node scripts/run-node.mjs --help
pnpm openclaw --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 104.84 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.7s
node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

[tsdown-build] invocation 2/2 finished in 13.4s
[plugin-control-plane-loads] verified 35 built modules with native require and checked doctor closures
runtime-postbuild: 11 phases completed in 4060ms (slowest: built plugin control-plane loads 3337ms)

OpenClaw 2026.8.1 (f0aee74) — All your chats, one OpenClaw.

Usage: openclaw [options] [command]

Options:
  --container ‹name›   Run the CLI inside a running Podman/Docker container named ‹name› (default: env OPENCLAW_CONTAINER)
  --dev                Dev profile: isolate state under ~/.openclaw-dev, default gateway port 19001, and shift derived ports (browser/canvas)
  -h, --help           Display help for command
  --log-level ‹level›  Global log level override for file + console
… output truncated …

Assertions:

  • PASS expect_output: Usage: openclaw

How this fits together

Subagent reconciliation reads persisted session records when registry state arrives late and turns a terminal child session into a parent-run outcome. The lookup must normalize structural key segments without collapsing opaque channel peer identifiers.

flowchart LR
A[Child session key] --> B[Subagent reconciliation]
B --> C[Exact session-store lookup]
C --> D[Canonical key lookup]
D --> E{Matching persisted session}
E --> F[Terminal child outcome]
E --> G[Missing child session]
F --> H[Parent run reporting]
G --> H
Loading

Before merge

  • Resolve merge risk (P1) - The branch is behind current main; refresh the clean merge result and retain the focused persisted-session collision coverage before landing.
  • Resolve merge risk (P1) - This lookup participates in terminal child-run attribution, so a merge must preserve both opaque-peer separation and structural-case reconciliation.
  • Complete next step (P2) - No mechanical repair is needed; the protected maintainer label and behind-main state require normal maintainer merge handling.
Agent review details

Security

None.

PR surface

Source -13, Tests +60. Total +47 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 2 15 -13
Tests 1 60 0 +60
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 62 15 +47

Review metrics

Metric Value Why it matters
Production versus regression-test LOC production +2/-15 (net -13); tests +60 The repair removes the broad fallback and adds focused owner-boundary collision coverage without growing production behavior.

Root-cause cluster

Relationship: canonical
Canonical: #127279
Summary: This PR explicitly supersedes two open attempts at the same case-colliding subagent-session completion defect.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Refresh and retain the session-key regression proof (recommended)
    Update the branch to the current merge result and rerun the focused reconciliation coverage before merging the persisted-session lookup change.

Technical review

Best possible solution:

Land the focused canonical lookup after refreshing it against current main, keeping the Matrix, Signal, and structural-key owner-boundary tests.

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

Yes. Current main's whole-key lowercase loop can match a terminal lowercased sibling for a mixed-case Matrix or Signal child; the PR supplies the corresponding focused cache-backed reproduction, though this review did not execute it.

Is this the best way to solve the issue?

Yes. Reusing the session store's canonical normalizer at the reconciliation owner preserves its established opaque-peer contract and removes the duplicate O(N) comparison policy.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 43c54af3ea90.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides after-fix production SQLite outcomes for both collision cases and a structural control, plus a real transport drive; no additional contributor proof is needed.

Label justifications:

  • P1: A case-colliding persisted session can falsely terminalize a child run and misreport subagent completion.
  • merge-risk: 🚨 session-state: The patch changes persisted session-key resolution used for child-run terminal attribution.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body provides after-fix production SQLite outcomes for both collision cases and a structural control, plus a real transport drive; no additional contributor proof is needed.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides after-fix production SQLite outcomes for both collision cases and a structural control, plus a real transport drive; no additional contributor proof is needed.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Blame attributes the current whole-key lowercase fallback and the related session-store resolver to commit e66d7c5. (role: introduced current lookup behavior and recent session-area contributor; confidence: high; commits: e66d7c5cac65; files: src/agents/subagents/registry/subagent-session-reconciliation.ts, src/config/sessions/store-entry.ts)

Rank-up moves

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

  • Refresh the clean merge result against current main and rerun the focused reconciliation coverage.

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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-08-21T16:48:05.135Z sha f0aee74 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-21T17:12:03.592Z sha f0aee74 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. proof: sufficient ClawSweeper judged the real behavior proof convincing. labels Aug 21, 2026
@obviyus

obviyus commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator Author

Rank-up move disposition: skip the optional current-main refresh. The PR is mergeable without conflicts, exact-head openclaw/ci-gate is green, and the OpenClaw fast lane treats BEHIND drift as advisory unless the branch conflicts.

@obviyus
obviyus merged commit fcc0bb7 into main Aug 22, 2026
264 checks passed
@obviyus
obviyus deleted the fix/subagent-session-reconciliation-case branch August 22, 2026 02:41
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 22, 2026
Use canonical session-key normalization during subagent reconciliation so case-distinct Matrix and Signal peers cannot be reported as completed. Preserve structural casing reconciliation and remove the O(N) fallback scan.

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

Labels

agents Agent runtime and tooling 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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant