Skip to content

fix: keep background work scoped to its selected agent - #123257

Merged
steipete merged 4 commits into
mainfrom
steipete/ecstatic-ramanujan-bfd2e3
Aug 13, 2026
Merged

steipete merged 4 commits into
mainfrom
steipete/ecstatic-ramanujan-bfd2e3

Conversation

@steipete

@steipete steipete commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Closes #123256

What Problem This Solves

Fixes an issue where explicit multi-agent installations could repeatedly fail background and lifecycle operations when those operations crossed hooks, cron, process-exit, binding, global delivery, or media-cleanup boundaries. Production logs recorded 2,542 AgentSelectionRequiredError entries in under 12 hours even though many producers already had an authoritative agent owner.

Why This Change Was Made

This repair establishes one canonical owner-propagation flow: scoped route, session, and job owners are consumed before legacy compatibility; required owner fields cross async boundaries; and raw global delivery receives sideband ownership. Legacy raw-global aliases keep optional compatibility metadata, while unbound or genuinely ownerless work still fails closed with actionable selection errors.

Non-goals are the excluded Slack thread-context freshness path and three separately tracked follow-ups: owner-aware Slack/Discord global system events, early external-hook failure ownership, and targetless system lifecycle events.

User Impact

Operators with explicit multi-agent rosters no longer need to configure or revive a global default for work that already belongs to a selected agent. Cron alerts, session hooks and memory, process completion notices, bindings, global WebSocket delivery, provider abort, managed media, Talk, ClickClack, Matrix, Feishu, and Discord binding ownership remain scoped. Genuinely ownerless operations continue returning actionable selection or configuration errors.

Evidence

  • Production evidence: 2,542 AgentSelectionRequiredError entries from 00:10Z to 12:01Z on 2026-08-13, including diagnostic 655, hooks 509, heartbeat 314, Slack 117, Discord 22, and gateway/health/ws plus unclassified paths. Host identity is redacted.
  • Regression-first owner-boundary tests failed before the repair for the intended selection and isolation reasons, then passed after it.
  • Focused suite: 19 files / 593 tests passed. Affected exec notify, shutdown tracker/drain, and cron identity suites were rerun after gate fixes and passed.
  • Full trusted-source local changed-surface gate passed with env OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 OPENCLAW_CHANGED_LANES_RAW_SYNC=1 CI=1 PNPM_CONFIG_VERIFY_DEPS_BEFORE_RUN=false corepack pnpm check:changed. It covered formatting, dead exports, core/core-test/extensions/extension-test tsgo, core/extension lint, import cycles, plugin boundaries, storage/database guards, and architecture guards.
  • Remote proof was attempted first. Blacksmith readiness failed at its doctor step. Daytona run run_01bd9183bf48 / lease cbx_cd64eebc73e9 passed the early guards but lacked workspace modules for the dead-export scan. Later Blacksmith, Daytona, Azure, and AWS readiness checks found no ready provider, so the trusted-source local fallback was used per policy. The changed gate was not remote-green.
  • Final owner-repair autoreview was clean with no accepted or actionable findings (overall 0.96). Each bounded CI repair received a fresh clean autoreview (overall 0.99).
  • Exact-head hosted CI exposed an unrelated Control UI E2E cleanup hang on current main: a failed-module scenario passed its behavior assertions but timed out for 120 seconds while context cleanup closed the intentionally broken page. The failed job and its single rerun reproduced the same hang. The test now closes that page in finally; the focused file passes 9/9 in 18 seconds.
  • Canonical exact-head CI exposed stale Matrix test contracts after the ownership migration and the recent preview-retention fix: three multi-agent thread-route fixtures lacked an account owner, while a delivery trace and test names still expected redaction before replacement delivery. The fixtures now declare their account owner, and the trace documents the intentional replacement-first ordering that preserves a visible draft if final delivery fails. The focused Matrix set passes 3 files / 183 tests.
  • Final exact-head CI run 31728940686 passed openclaw/ci-gate: 105 successful checks, 35 scoped skips, 1 neutral, no pending checks or failures.
  • git diff --check was clean, and the eager-fallback production scan found no matches: rg -n -U 'resolveAgentIdFromSessionKey\([\s\S]{0,180}?resolveDefaultAgentId\(' src extensions --glob '*.{ts,tsx}' --glob '!**/*.test.ts'.
  • Production LOC is +211/-180 (net +31). The growth is the explicit owner identity carried across process, session, hook, and global lifecycle boundaries. Tests, test support, and trace contracts are +312/-90 (net +222), including the new Talk regression and bounded CI test-contract repairs.
  • AI-assisted: yes.

@clawsweeper

clawsweeper Bot commented Aug 13, 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 13, 2026 16:21
@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord channel: matrix Channel integration: matrix gateway Gateway runtime commands Command implementations agents Agent runtime and tooling channel: feishu Channel integration: feishu extensions: clickclack size: L maintainer Maintainer-authored PR labels Aug 13, 2026
Scoped route, session, and job owners now survive hooks, cron, process exits, global delivery, bindings, and media cleanup. Truly ownerless operations remain explicit errors.
@steipete
steipete force-pushed the steipete/ecstatic-ramanujan-bfd2e3 branch from ff5e222 to a4f7c6c Compare August 13, 2026 17:04
@openclaw-barnacle openclaw-barnacle Bot added the app: web-ui App: web-ui label Aug 13, 2026
@steipete
steipete merged commit 249a38d into main Aug 13, 2026
147 checks passed
@steipete
steipete deleted the steipete/ecstatic-ramanujan-bfd2e3 branch August 13, 2026 18:29
@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 14, 2026
* fix: preserve explicit agent ownership

Scoped route, session, and job owners now survive hooks, cron, process exits, global delivery, bindings, and media cleanup. Truly ownerless operations remain explicit errors.

* test: provide session memory hook owner

* test(ui): close failed-module page explicitly

* test(matrix): align ownership and replacement proof
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui channel: discord Channel integration: discord channel: feishu Channel integration: feishu channel: matrix Channel integration: matrix commands Command implementations extensions: clickclack gateway Gateway runtime maintainer Maintainer-authored PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Explicit multi-agent background work loses its owner

1 participant