Repository navigation
feat(agent): wake the Bot when a worker it created finishes - #6540
Conversation
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]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Astro-Han
left a comment
There was a problem hiding this comment.
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.
…er-wake Co-Authored-By: Claude Opus 5.5 <[email protected]>
…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]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Astro-Han
left a comment
There was a problem hiding this comment.
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.
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.
prepare_notification/admit_notificationpath, as a new message originbot_worker { sessionId }.Notes for reviewers
MessageOrigin::BotWorkervariant, so the generatedpackages/plugin-sdkcontracts changed.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 idlemaka-agent-nativeandmaka-agent-factstests,cargo clippy --no-deps --all-targets,cargo fmt,cargo check --workspace --tests, ACP projection tests🤖 Generated with Claude Code