Skip to content

fix(workers): attach global sessions to the owning agent - #139216

Merged
steipete merged 3 commits into
openclaw:mainfrom
ly85206559:codex/fix-worker-global-session-owner
Sep 6, 2026
Merged

steipete merged 3 commits into
openclaw:mainfrom
ly85206559:codex/fix-worker-global-session-owner

Conversation

@ly85206559

@ly85206559 ly85206559 commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where dispatching a non-default agent's global session to a worker failed with Attached session target is unavailable, even though the session worked locally. Other worker activity could likewise treat that existing session as unattached.

Why This Change Was Made

The combined session view already records the logical agent that owns each row. The worker resolver now carries that owner into the existing fresh canonical store lookup instead of trying to recover it from the reserved global key. The resolved type exposes its existing required owner, allowing inference to remove an unreachable default-agent fallback.

The same canonical store read, session-ID validation, and worker authority checks remain in place. Production changes total +11/−12 lines; regression coverage adds 60 lines. Thanks @ly85206559 for the original repair and regression.

User Impact

Worker attachment, inference, live events, transcript commits, and run lookup can retain the selected global session's owning agent. Worker output appears in that agent's history without entering another agent's conversation.

Evidence

  • Before: Hosted baseline 34024464897 reproduced the actual dispatch failure on parent 76fb700f1322bc5d8d03ec6f9a63d0d637668aa7. A real Gateway and paired node were ready, and the explicit-agent local control turn succeeded. Dispatch then failed with exactly Attached session target is unavailable; teardown reported zero failures. The focused real-committer regression also failed at its intended assertion.
  • After: Hosted candidate 34026610687 verified the reviewed source hashes before and after execution. The same setup reached active placement, launched one installed worker, completed its turn, and returned exactly one assistant marker in the owning agent's history with no marker in the other agent's history. Teardown reported zero failures. Both flows used synthetic loopback model and Git services on Node 24.20.0 with the pinned pnpm 12.3.4 toolchain.
  • The focused regression, real worker scenario, and 128 scoped tests passed, covering transcript commits, inference, live events, agent-scoped aborts, and combined-store ownership. The private-QA build and changed-file gates passed, including production/test typechecking, formatting, lint, and architectural guards. The regression independently reopens the owning SQLite transcript, verifies the original main transcript remains untouched, and checks publication ownership.
  • Full source autoreview, independent source/evidence review, and separate read-only review of exact published head cdbdb27da0c55580fa0dfeba69893127a4f974c0 found no actionable issues. The same three file hashes are preserved after merging protected main 0ebb320906da7e1727934b3cf816cedf98270357 to acquire fix(ci): preflight job outputs exceed 1 MiB on full-plan pull requests #140018's CI output-limit repair. Required upstream CI 34039432075 passed on that exact head, including preflight and every selected product job.

The minimal synthetic provider does not implement embeddings, and the explicit test fleet has no ambient dreaming-job owner; their nonfatal background diagnostics occurred in both runs. Neither diagnostic caused the attachment failure or prevented successful local and fixed-worker turns.

@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XS labels Sep 5, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 5, 2026
@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 6, 2026, 10:37 AM ET / 14:37 UTC.

ClawSweeper review

What this changes

Preserves the recorded agent owner when workers resolve global sessions, removes an unnecessary inference fallback, and adds transcript ownership regression coverage.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused fix: current main and the latest release retain the faulty lookup. No actionable introduced defect was found, and the captured runtime evidence supports the repair.

Likely related people: steipete (medium-confidence routing candidate).

Priority: P2
Reviewed head: cdbdb27da0c55580fa0dfeba69893127a4f974c0

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful persistence coverage and concrete before/after worker evidence.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The captured before/after evidence exercises dispatch through a real Gateway, paired node, and installed worker, reporting recovery from attachment failure and output only in the owning agent’s history. The changed files match the previously reviewed head; hosted logs could not be independently reopened in this environment.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The captured before/after evidence exercises dispatch through a real Gateway, paired node, and installed worker, reporting recovery from attachment failure and output only in the owning agent’s history. The changed files match the previously reviewed head; hosted logs could not be independently reopened in this environment.
Evidence reviewed 9 items Existing behavior contract: The session documentation explicitly says global sessions retain the selected agent and do not merge different agents’ conversations.
Repair uses the existing ownership producer: The combined-store producer records each selected row and its target together. The patch carries that recorded agent into the existing canonical lookup and retains the subsequent session-ID check; it does not introduce a second ownership store.
Current main still needs the fix: The fetched main resolver still passes only the selected key into the canonical store lookup, omitting the recorded agent owner.
Findings None None.
Security None None.

How this fits together

The Gateway attaches sessions to remote workers while retaining control of inference and conversation history. Its session resolver connects a worker’s session ID to the owning agent and canonical transcript store.

flowchart TD
  A[Worker session ID] --> B[Combined session view]
  B --> C[Select session and recorded owner]
  C --> D[Fresh canonical store lookup]
  D --> E{Session ID still matches?}
  E -->|Yes| F[Agent inference and transcript updates]
  E -->|No| G[Reject unavailable session]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -1, Tests +60. Total +59 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 11 12 -1
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 3 71 12 +59

Review metrics

None.

Technical review

Best possible solution:

Keep worker resolution on the existing canonical lookup while carrying the selected row’s agent owner through inference, transcript writes, and notifications.

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

Yes: current main drops the selected global row’s owner before canonical lookup, and the captured baseline records the corresponding dispatch failure. No code or tests were executed during this read-only review.

Is this the best way to solve the issue?

Yes: carrying the existing ownership fact into the shared resolver fixes its consumers without changing configuration, persistence formats, or worker authorization.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 37aaf073776c.

Labels

Label justifications:

  • P2: Repairs a bounded worker-attachment failure for non-default agents using global sessions.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The captured before/after evidence exercises dispatch through a real Gateway, paired node, and installed worker, reporting recovery from attachment failure and output only in the owning agent’s history. The changed files match the previously reviewed head; hosted logs could not be independently reopened in this environment.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured before/after evidence exercises dispatch through a real Gateway, paired node, and installed worker, reporting recovery from attachment failure and output only in the owning agent’s history. The changed files match the previously reviewed head; hosted logs could not be independently reopened in this environment.

Evidence

What I checked:

  • Existing behavior contract: The session documentation explicitly says global sessions retain the selected agent and do not merge different agents’ conversations. Public docs: docs/concepts/session.md. (docs/concepts/session.md:31, cdbdb27da0c5)
  • Repair uses the existing ownership producer: The combined-store producer records each selected row and its target together. The patch carries that recorded agent into the existing canonical lookup and retains the subsequent session-ID check; it does not introduce a second ownership store. (src/config/sessions/combined-store-gateway.ts:206, cdbdb27da0c5)
  • Current main still needs the fix: The fetched main resolver still passes only the selected key into the canonical store lookup, omitting the recorded agent owner. (src/gateway/worker-environments/session-target.ts:35, 37aaf073776c)
  • Latest-release check: The same owner-omitting lookup exists in the supplied latest release, v2026.9.2. No merged fixing PR is established by the supplied related context. (src/gateway/worker-environments/session-target.ts:35, 3928bad9badf)
  • Meaningful persistence regression: The added case invokes the real transcript committer, independently reopens the work-agent transcript, checks the original main transcript remains empty, and verifies the published update names work/global. The authority callback is a test stub, so this test is supplemental rather than standalone runtime or authorization proof. (src/gateway/worker-environments/transcript-commit.test.ts:401, cdbdb27da0c5)
  • Captured real worker evidence: The supplied PR body links baseline https://github.com/steipete/openclaw/actions/runs/34024464897 and candidate https://github.com/steipete/openclaw/actions/runs/34026610687. It records a real Gateway and paired node: baseline dispatch failed with the exact attachment error; candidate dispatch launched one installed worker, completed its turn, and produced exactly one assistant marker in the owning history and none in the other history. Both used synthetic loopback services and reported successful teardown. GitHub API and browser attempts could not reopen these runs in this review environment; this assessment preserves the captured evidence rather than claiming independent log verification.

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (5 earlier review cycles)
  • reviewed 2026-09-05T16:44:19.817Z sha 79c7de3dc1d97e234ee1603b71603f1c40dc9ea6 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-05T16:56:10.668Z sha 79c7de3dc1d97e234ee1603b71603f1c40dc9ea6 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-05T17:53:19.908Z sha 7f6d80d :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-06T05:47:46.915Z sha 7f6d80d :: blocked before merge. :: none
  • reviewed 2026-09-06T11:10:48.685Z sha 03cf824 :: needs maintainer review before merge. :: none

@ly85206559
ly85206559 force-pushed the codex/fix-worker-global-session-owner branch from 79c7de3 to 7f6d80d Compare September 5, 2026 17:11
@ly85206559

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The exact head now includes behavior-level proof through the real worker transcript committer: it selects the non-default agent's global session, commits through the production path, and verifies transcript persistence. The PR body records the exact passing Actions job and the unrelated flaky shard.

@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete steipete self-assigned this Sep 6, 2026
@ly85206559

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Added exact parent/head connected-runtime proof to the PR body. The clean fork Actions run uses the production worker WebSocket handler, a real WorkerConnection, persisted environment/placement stores, the real authority gate, and the transcript committer. Parent: worker ready, session-not-attached, 0 persisted entries. PR head: one admitted worker, one worker.transcript.commit frame accepted, one entry persisted to work/global.

@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 6, 2026
steipete and others added 2 commits September 6, 2026 03:58
Expose the resolved session target's existing agent owner guarantee and
remove inference's unreachable default-agent fallback. Verify global
session commits preserve the owning transcript and publication scope.

Co-authored-by: ben.li <li.yang6@xydigit.com>
@steipete
steipete merged commit 94ff32c into openclaw:main Sep 6, 2026
216 checks passed
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 7, 2026
…9216)

* fix(workers): retain global session ownership

* fix(workers): preserve canonical session owners

Expose the resolved session target's existing agent owner guarantee and
remove inference's unreachable default-agent fallback. Verify global
session commits preserve the owning transcript and publication scope.

Co-authored-by: ben.li <li.yang6@xydigit.com>

---------

Co-authored-by: Peter Steinberger <steipete@gmail.com>
Co-authored-by: ben.li <li.yang6@xydigit.com>
@ly85206559
ly85206559 deleted the codex/fix-worker-global-session-owner branch October 5, 2026 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. 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.

2 participants