Skip to content

feat(agent): wake the Bot when a worker it created finishes - #6540

Merged
liugddx merged 8 commits into
rust-previewfrom
feat/bot-worker-wake
Nov 2, 2026
Merged

liugddx merged 8 commits into
rust-previewfrom
feat/bot-worker-wake

Conversation

@liugddx

@liugddx liugddx commented Nov 1, 2026

Copy link
Copy Markdown
Member

Summary

Second delegation step from #6076 (after #6538): when a worker the Bot created finishes a run, the Bot is woken. Until now a Bot that delegated and went to sleep would never hear back.

  • The Bot records a durable watch (in its own storage) whenever it creates a conversation or sends to one. The watch keeps the Bot's model and workspace route, taken from the Bot's running call exactly as WorkHub notifications do.
  • A background pass reports each finished run of a watched worker to the Bot once, through the existing prepare_notification / admit_notification path, as a new message origin bot_worker { sessionId }.
  • The message is a pointer, not the result: it names the worker, its title and the invocation, and tells the Bot to read the actual outcome with the conversation read tools before telling the user or handing out more work. The Bot's standing instructions now say the same.
  • A busy Bot keeps the report pending and gets it when idle. The report identity is derived from worker and invocation, so retries and restarts never repeat it, and the "already reported" marker is stored with the watch.
  • Only completed, failed and cancelled runs are reported; a handoff pause or a context compaction is not a result. Watches of archived workers, or of conversations the Bot no longer parents, are dropped.
  • Each wake is a normal Bot Turn. No step or round limits are added.

Notes for reviewers

  • A worker parked on an approval is not reported (it has not finished); the approval is visible in the worker's own conversation.
  • Watch writes after create/send are best effort: the effect already happened and the next send refreshes the watch. Failures are logged.
  • New MessageOrigin::BotWorker variant, so the generated packages/plugin-sdk contracts changed.
  • Not covered here: the Chat view of these wake messages, WorkHub folding, and real-model verification.

Test plan

  • bot_tests (22): the Bot is woken once when its worker finishes and not again; a worker that finishes while the Bot is running is reported after the Bot goes idle
  • full maka-agent-native and maka-agent-facts tests, cargo clippy --no-deps --all-targets, cargo fmt, cargo check --workspace --tests, ACP projection tests
  • Not verified with a real model yet

🤖 Generated with Claude Code

liugddx and others added 5 commits November 1, 2026 21:15
The Bot keeps a durable watch for each conversation it creates or sends to. A
background pass reports every finished run of a watched worker to the Bot once,
as a new origin-tagged message through the existing notification admission, so
a Bot that went to sleep after delegating is woken by the result. The message
is a pointer, not the result: it tells the Bot to read the worker's actual
outcome before telling the user.

A busy Bot keeps the report pending until it is idle. The report identity comes
from the worker and invocation, so a retry or restart never repeats it. Pauses
and context compactions are not results. Archived or foreign watches are
dropped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A model selection carries the connection's revision, which the Bot has no way
to know, so every SessionSend from a real Bot was refused as an unavailable
model and surfaced only as an unconfirmed result. A worker now runs on the
model the Bot itself is running on, resolved against the current connection
revision; the selection the Bot supplies is replaced. The Bot's instructions
say so.

The delegation test now serves the wake Turn the finished worker causes, which
otherwise raced with its idle check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A worker finishing wakes the Bot with a message the Host wrote, but Chat showed
it as a bubble the user had apparently typed, with copy and edit controls and
an internal instruction in it. History rows now keep the message origin; the
Bot's Chat hides origin-tagged user messages, and Trajectory shows them so the
wake stays inspectable.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@Astro-Han Astro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated review notice: This comment was posted by an automated review agent. It is not an independent human review and does not replace one.

I reviewed all 13 changed files at becb4a3156ea95eb1c51126dc265f7b6d671fbab, including the durable watch, notification admission, model selection, origin contracts and Chat/history projection. I found no newly confirmed P0–P2 runtime defect in this review.

owner/bot/wake.rs records a return route after successful creation/send, keeps the last reported invocation under a storage revision, checks the worker's stored parent and archived state, and derives the notification identity from worker plus invocation. The reused prepare_notification / admit_notification path checks the Bot's busy/parked state, workspace binding and original admission identity. The message points to the worker's actual result rather than embedding an assumed outcome. Model selection uses the calling Bot's accepted route and the current connection revision when resolvable; otherwise the supplied selection still goes through normal validation.

The history metadata now carries origin, ProcessRow includes it, and the Bot Chat predicate distinguishes a Host-authored notification from a user-authored message. All six original history tests passed locally, including the new origin case. Running those tests against the old production history module gives five passes and the origin case failing. Four controlled checks of the actual Chat filter also passed; these do not render a native UI.

The older 6e0 CI has two distinct failures: the known #6539 todo_tests.rs:169 assertion, and this PR's TS2339 errors because ProcessRow omitted origin. The latest commit adds that property to the Pick<Row, ...> type, addressing the reported source mismatch. I have not run the complete generated native-UI TypeScript build locally, and there are currently no hosted checks attached to this newer head. In the older run's actual logs I confirmed passes for the_bot_is_woken_once_when_its_worker_finishes and the existing delegation test; the Rust implementation is unchanged between 6e0 and this head.

There is a delivery limit to keep explicit: the pass reads latest_turn_boundary and stores a single last-reported invocation, rather than enumerating every unreported completion. I have not established the stronger claim that every intermediate run is reported when a worker completes multiple runs while the Bot is busy. The added tests cover one completion at a time. Watch writes are best effort as documented; restart, admission-uncertainty and concurrent storage-conflict recovery were not executed locally.

An actual merge against Rust 810305ca fails in three files: contracts.ts, generated runtime.ts and plugins/agent/facts/src/message.rs, where the new origin variants meet later upstream changes. Those need resolving and current-head validation before integration.

P3 — AI attribution: all five material commits lack the required Generated-by: trailer, although the PR identifies Claude Code and the commits declare Claude co-authorship. Add the required attribution and preserve it in the final squash.

No local Rust/Host, real-model, durable restart or native application acceptance is claimed. The broader execution claims in the PR description remain the author's results.


Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.

liugddx and others added 3 commits November 2, 2026 07:45
…r sends

#6539 removed the duplicate persistent warning after an unknown tool result and
leaves the unknown outcome to the tool result itself, but this test still
required the removed system message. rust-preview CI has failed on it since.
The assertion that the tool result says outcome_unknown stays.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@liugddx
liugddx merged commit 7ac5f2b into rust-preview Nov 2, 2026
17 checks passed
@liugddx
liugddx deleted the feat/bot-worker-wake branch November 2, 2026 01:19

@Astro-Han Astro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated review notice: This comment was posted by an automated review agent. It is not an independent human review and does not replace one.

Follow-up review at final head fe435fdb5ef8be99399dbeb5af7c464f96144d8d, now merged as 7ac5f2bf. I read all submitted hunks in the current 13 changed files and compared them with my earlier review. git range-diff retains all five original feature commits unchanged; the later integration brings in newer upstream code and the #6548 todo-test assertion removal. I found no newly confirmed P0–P2 defect in this follow-up.

The previous integration/check limitations are resolved for this head. Final-head run 41368354632 completed successfully, including all four root-test slices, tooling, Clippy, variants, product and native platform builds. I read its actual logs and independently located PASS entries for both worker-wake tests, Bot delegation/ownership, and the previously failing unknown-tool-outcome regression. The older f91e3745 run failed at todo_tests.rs:169; the final patch removes that obsolete system-note assertion while retaining the tool's outcome_unknown and original user-message assertions. The earlier conflict/no-check observations at becb4a31 no longer describe the final integrated change.

Locally, all six repository history tests passed again, including preservation of Host message origins. Four controlled checks of the actual Chat filter passed again: Host-generated user messages are excluded from Bot Chat, typed user messages remain, Bot assistant-process rows stay internal, and ordinary conversations retain the Host-origin row. These checks execute the final-head modules/predicate; they do not render a native UI or exercise Rust notification admission.

The source recheck covered durable watches and revision comparisons; worker parent/archive checks; model selection from the calling Bot's route; notification identities derived from worker and invocation; and the original admission path. owner/bot/wake.rs is byte-identical at this final PR head, its merge, and the observed current rust-preview 4d8e0c93. Other integration files have subsequent upstream changes, so this is not acceptance of every later branch change.

The delivery limit from my earlier review remains explicit: owner/bot/wake.rs:225–230 reads latest_turn_boundary and the watch stores one last-reported invocation. I have not established delivery of every intermediate completion when a worker runs multiple times before the Bot can accept a wake. The added hosted tests exercise one completion at a time, including a busy Bot. Best-effort watch writes, real-model behavior, durable restart/admission uncertainty, and concurrent storage-conflict recovery were not independently exercised locally.

P3 — AI attribution remains: the PR declares Claude Code and Claude co-authorship, but the original material commits and final squash 7ac5f2bf lack the required Generated-by: trailer. This is an attribution/process issue, not a demonstrated runtime failure.

I did not run local Rust, the complete native UI build, a native application, or a real model. The hosted evidence above is separate from the author's broader test claims. No approval or merge was performed by this review.


Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.

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.

2 participants