Skip to content

[ENG-19421] feat(agents): channel-owned subagent completion replies and sequential sessions_yield - #205

Merged
orswn merged 11 commits into
boonfrom
okka/completion-owner
Sep 7, 2026
Merged

orswn merged 11 commits into
boonfrom
okka/completion-owner

Conversation

@orswn

@orswn orswn commented Sep 7, 2026 •

Copy link
Copy Markdown
Collaborator

Related: ENG-19421

What Problem This Solves

Fixes two issues on Boon web chat when a turn delegates work to a sub-agent.

  1. The sub-agent completion arrived as a plain text row without suggested replies, thought details, or verification, and in some runs as a duplicate row or not at all. The completion announcement runs in the automatic source-reply mode for threaded direct chats, so a channel that renders its final reply from the message tool never sees that payload and the NO_REPLY rewrite produces a plain row instead.
  2. When the model called message and sessions_yield in the same assistant turn, the message send failed with Operation aborted and the channel showed a "couldn't complete one of the steps" row instead of the intended text.

Why This Change Was Made

Adds an opt-in completion owner registry. A channel plugin registers one owner per channel through PluginRuntime.subagent.registerCompletionOwner. When the announce flow has an owner for the requester channel and the owner accepts the route, the assembled completion event is handed to the owner instead of the legacy delivery. Every non-match (no owner, other channel, requester is a sub-agent, expectsCompletionMessage false, not_handled) falls through to the unchanged legacy path. A resumed announce record claimed by an owner that is no longer registered fails retryably instead of falling back, so a restart cannot produce a second visible row. Adds activeRunPolicy: "wait" to the reply run options for owner-driven replies.

Marks the sessions_yield tool as sequential. The agent loop already runs a batch in order when any tool in it is sequential, so tool calls emitted before the yield complete before the abort fires. Batches without a yield are unchanged. This differs from upstream, which keeps cancelling sibling tools on yield.

Also carries two upstream fixes for reply session initialization conflicted on resumed sub-agent turns (openclaw#97657, openclaw#98835), which the owner path depends on.

User Impact

  • Boon web chat: a sub-agent completion renders as one regular assistant reply with suggested replies, thought and verification details. No duplicate row, no NO_REPLY text.
  • All channels: a message send issued in the same turn as sessions_yield is delivered instead of failing.
  • Channels without a registered owner: no change.

Evidence

  • Announce suite: 46 tests including owner routing, fall-through, unavailable-owner retry, and persisted owner channel.
  • packages/agent-core/src/agent-loop.test.ts: a parallel yield batch aborts the sibling send (reproduces the defect); a sequential yield lets the sibling send finish.
  • sessions-yield-tool.test.ts pins executionMode: "sequential".
  • Focused shards: 36 files / 548 tests (owner), 3 files / 27 tests (yield). oxfmt, oxlint, git diff --check, pnpm build green.
  • Local end-to-end run with the companion plugin change (getboon/anychat-boon-web): one completion row with suggested replies and verification, two mid-run message sends delivered while the sub-agent ran, no failed-step row.

Live Slack and Teams checks were not run; those channels have no owner and use the unchanged path.

Local smoke run

Boon web chat on a local fork build with both changes (#205 and getboon/anychat-boon-web#124). Prompt: spawn a sub-agent that prints a random number every second for 60 seconds, then send BOOYAH {last} with a joke; ask for the current number mid-run.

  • Two mid-run questions answered from the running sub-agent via message sends in the same turn as sessions_yield. No failed-step row.
  • The completion arrived as one regular assistant reply: model-authored suggested replies, thought and verification details. No duplicate, no NO_REPLY text.
  • boon-core row carries suggested_replies, audit_trace, and the completion turn_id; the callback returned 200.

thread-17-smoke.png

joshavant and others added 4 commits September 7, 2026 22:53
… identity fields (openclaw#98835)

* fix(config/sessions): narrow reply-session initialization revision to identity fields

The initialization guard compared the full persisted session entry, so
background touches to updatedAt, heartbeat timestamps, context-budget
metadata, etc. produced false-positive stale-snapshot conflicts and the
"reply session initialization conflicted" error.

Only sessionId and sessionFile matter for detecting a session rotation.
Narrow the revision to those identity fields and add a regression test.

Fixes openclaw#98672

* fix(config/sessions): merge current metadata when reply-init identity guard passes

* fix(config/sessions): preserve only snapshot-drifted metadata in reply-init commit

* fix: preserve cleared reply-session metadata

* fix: allow same-session reply initialization drift

---------

Co-authored-by: moguangyu5-design <[email protected]>
Co-authored-by: Josh Lehman <[email protected]>
(cherry picked from commit 826c84e)
Subagent completion announcements into a threaded direct chat run in the
automatic source-reply mode. A channel that renders its final reply from
the message tool (suggested replies, audit trace) never sees that
payload, and the NO_REPLY rewrite produces a plain duplicate row instead.

Add an opt-in completion owner registry. A plugin registers one owner per
channel through PluginRuntime.subagent.registerCompletionOwner. When the
announce flow has a registered owner for the requester channel and the
owner accepts the route, the assembled completion event is handed to the
owner instead of the legacy delivery. Every non-match (no owner, other
channel, requester is a subagent, expectsCompletionMessage false,
not_handled) falls through to the unchanged legacy path.

Persist the owner channel on the announce record. A resumed record that
was claimed by an owner which is no longer registered fails retryably
instead of falling back to legacy delivery, so a restart cannot produce a
second visible row.

Add activeRunPolicy "wait" to the reply run options so an owner-driven
reply waits for the active run instead of steering or queueing a
follow-up.
…nish

The sessions_yield tool aborts the run from its execute callback. In a
parallel tool batch the abort signal also rejects every sibling tool call
still running, so a message send issued in the same assistant turn fails
with "Operation aborted" and the channel reports a failed step.

Mark the tool as sequential. The agent loop already executes a batch in
order when any tool in it is sequential, so tool calls emitted before the
yield complete before the abort fires. Batches without a yield are
unchanged.
@orswn
orswn requested a review from a team September 7, 2026 20:20
@claude

claude Bot commented Sep 7, 2026 •

Copy link
Copy Markdown

Claude encountered an error —— View job


I'll analyze this and get back to you.

…rt cycle

The completion owner registry imported the message channel barrel and the
announce output module for one normalizer and one type. Both paths reach
the channel registry and gateway plugins, which import the registry back,
so the architecture check reported a new import cycle.

Import the leaf normalizer and declare the outcome shape locally.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed against the latest diff

Tip: instead of fixing issues one by one fix them all with cubic

Re-trigger cubic

Comment thread src/auto-reply/reply/get-reply-run.ts Resolved
Comment thread src/agents/subagent-announce.ts Resolved
Comment thread src/agents/tools/sessions-yield-tool.ts Resolved
Comment thread src/plugins/runtime/index.test.ts Resolved
Comment thread src/config/sessions/session-accessor.ts Resolved
…nce events

The owner request read the event back out of a one-element array with a non-null assertion that the type-aware lint rejects as unnecessary.
The parent polls for the ready file with fs.access and then parses it.
The child wrote it in place, so a poll landing between create and write
read an empty file and failed with "Unexpected end of JSON input".

Write to a temp path and rename it into place.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 1 file (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Fix all with cubic | Re-trigger cubic

…rrel

The plugin SDK surface budget caps public exports on the root entrypoint.
The four completion owner types pushed it over the limit and the plugin
reads them through the PluginRuntime type, so the root re-export is not
needed.
…failure

The owner path reported terminal failures but the deferred-cleanup
decision only consulted the no-output drop reason, so a non-retryable
owner result still re-ran the owner up to the retry limit. Record an
owner_terminal drop reason and give up on it.

Also tell the model to call sessions_yield last, and dispose the test
owner registration in a finally block.
@claude

claude Bot commented Sep 7, 2026

Copy link
Copy Markdown

Claude Code is working…

I'll analyze this and get back to you.

View job run

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 9 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Fix all with cubic | Re-trigger cubic

…esume

Without persisting, a gateway restart between the attempt and the
deferred-cleanup decision lost the marker and re-ran the owner. Resume
now gives up on owner_terminal the same way it does on subagent_no_output.
@orswn
orswn merged commit c8bff8a into boon Sep 7, 2026
146 checks passed
@orswn
orswn deleted the okka/completion-owner branch September 7, 2026 22:35
holywend added a commit that referenced this pull request Sep 8, 2026
`boon` moved while this release PR was open: #205 (channel-owned sub-agent
completion replies, sequential sessions_yield) merged after the branch point.

That commit ships in this release whether or not the branch merges it — the tag
is cut from `boon` after this PR lands, so `boon` will contain both #205 and the
version bump. Leaving the release notes as they were would have shipped a
CHANGELOG that silently omitted a 39-file behaviour change.

So: merged base, added #205 to the notes, and re-ran `pnpm release:prep`.
`release:generated:check` had gone red on "Plugin SDK API baseline drift" —
#205 touches `PluginRuntime`, `SubagentRunParams` and `SubagentRunResult` on the
`core`, `index` and `runtime-store` entrypoints. Regenerating clears it. No new
entrypoints, so the surface budget is untouched and needs no bump.

Version propagation re-verified after the merge: root plus @openclaw/slack,
@openclaw/msteams and @openclaw/diagnostics-prometheus all read
2026.6.11-boon.38.
orswn added a commit that referenced this pull request Sep 8, 2026
…206)

## Release 2026.6.11-boon.38

Ships channel-owned sub-agent completion replies for Boon web chat.

### Contents (merged onto `boon` since boon.37)
- **#205 (ENG-19421)** — a plugin can register a completion owner for its channel; the announce flow hands the sub-agent completion to the owner and falls back to the existing delivery path when none is registered, so other channels are unchanged. `sessions_yield` runs its tool batch sequentially so a `message` send in the same turn is no longer aborted. Carries upstream openclaw#97657 and openclaw#98835 (`reply session initialization conflicted`). Smoke-tested on a local stack; evidence in #205.
- **#202** — plugin-sdk read of the gateway live run count.
- **#201** — internal identifiers removed from the public tree.

### Release prep
- Root version boon.37 → boon.38; `pnpm release:prep` regenerated the lockstep set (211 files) → `[release-preflight] OK`.
- `CHANGELOG.md` `## 2026.6.11-boon.38` section added; `scripts/package-changelog.mjs` extractor returns 2496 packaged bytes.

### After merge
Tag `v2026.6.11-boon.38` → `boon-release.yml`. The fleet is pinned to `boon.36`, so the roll also picks up boon.37 (#189, #194–#198). Gateway roll first (gated `fleet-roll`), then the anychat-boon-web release that pins this tarball.
william-antoline-boon added a commit that referenced this pull request Sep 9, 2026
…211)

## Release 2026.6.11-boon.39

Surfaces a swallowed before_tool_call hook failure to Sentry + the durable
audit trace so the ENG-19492 incident class is diagnosable after the fact.

### Contents (merged onto `boon` since boon.38)
- **#209 (ENG-19492)** — emit a `before_tool_call_hook_failed` observability
  hook (genuine handler exception only, never a policy veto), paged by
  sentry-monitor, and thread the real error text into boon-core's audit_trace
  as an optional `detail` field. Requires boon-core companion getboon/boon#14629
  (merged + live) which accepts the new field. Non-hook pipeline failures are
  classified separately.
- **#208** — derive legacy tool counts from surfaced failures.

### Release prep
- Root version boon.38 -> boon.39; lockstep regenerated (211 files:
  135 plugin package.json + 70 npm-shrinkwrap.json + SDK/config baselines).
  All release-preflight --check steps pass.
- CHANGELOG.md `## 2026.6.11-boon.39` section added.

### After merge
Tag `v2026.6.11-boon.39` -> `boon-release.yml`. Fleet is pinned to boon.36, so
a roll also picks up boon.37 (#194-#198) and boon.38 (#201, #202, #205).


Claude-Session: https://claude.ai/code/session_01AMjtZJAWLVBwa5Dtc4oNog

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
convyusboy added a commit that referenced this pull request Sep 18, 2026
…onflicts)

Merges 45 commits from origin/boon (boon.34 through boon.45, tag bump
06c4eff) into the 6.34 integration branch. 213 initial conflicts,
~206 were mechanical version-string conflicts (package.json /
npm-shrinkwrap.json across root + bundled plugins, resolved to ours
since this branch's purpose is advancing past the 2026.6.11-boon.N
train). Non-trivial resolutions:

- src/agents/embedded-agent-runner/run/failover-policy.ts: kept our
  side's non-exclusion of "model_not_found" in
  shouldEscalateRetryLimit (upstream openclaw#97571, already tested on this
  branch since the original 6.34 sync) while adopting boon's new
  "edge_blocked" exclusion. Blindly taking boon's side here would have
  silently reverted the upstream fix; caught via
  failover-policy.test.ts failing 1/44 before the correction.

- src/config/sessions/session-accessor.ts: adopted boon's
  projectSessionEntryForPersistenceRevision call in
  createReplySessionInitializationRevision, replacing our own
  identity-field comparison workaround. Boon's own recent PR #205
  reintroduced real use of this projection, so the workaround is no
  longer needed.

- src/config/sessions/session-accessor.reply-init-concurrency.test.ts:
  kept our PID-suffixed temp-file naming in the child test script
  (avoids same-directory temp-path collisions across concurrent
  children); took boon's minor whitespace cleanup elsewhere.

- extensions/matrix/CHANGELOG.md: kept our 3 newest entries on top,
  followed by boon's full chain.

- scripts/plugin-sdk-surface-report.mjs: bumped publicExports budget
  10406 -> 10410 and publicFunctionExports 5216 -> 5217 to match
  actual measured surface after the merge (publicEntrypoints already
  324, unchanged).

- docs/.generated/*.sha256: regenerated via `pnpm run
  plugin-sdk:api:gen` and `pnpm run config:docs:gen` against the
  merged tree. Also had to `git rm --cached` 6 underlying .json/.jsonl
  data files that origin/boon tracks but our .gitignore (unchanged by
  this merge) explicitly excludes (docs/.generated/*.json,
  docs/.generated/*.jsonl) -- git's merge machinery adds a file from
  either parent on a clean non-conflicting add regardless of the
  other side's gitignore rules.

- pnpm-lock.yaml: merged clean with no conflict markers, but the
  auto-merge misplaced extensions/diagnostics-otel's @opentelemetry/*
  dependency block under the root "." importer instead of the
  extensions/diagnostics-otel importer. `pnpm install` (run as a
  side-effect of plugin-sdk:api:gen) correctly relocated it; confirmed
  root package.json has never declared these deps (neither current
  nor pre-merge HEAD) and extensions/diagnostics-otel/package.json
  declares exactly this set. Diff is a pure 33-line removal of the
  misplaced duplicate, kept.

Verified: tsgo:core:test and tsgo:extensions:test clean; broad
node scripts/run-vitest.mjs sweeps across all touched feature surfaces
(embedded-agent-runner, config/sessions, cron, plugin-sdk,
sentry-monitor, pdf-tool, media, subagents) all green.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants