Deliver spawned-task settle outcomes back to the launching run#348
Open
daniel-lxs wants to merge 2 commits into
Open
Deliver spawned-task settle outcomes back to the launching run#348daniel-lxs wants to merge 2 commits into
daniel-lxs wants to merge 2 commits into
Conversation
The environment-setup workflow's spawned verification task is the end-to- end test of the product pipeline (fresh provisioning, platform-executed setup commands, an agent working in the environment), but consuming its outcome depended on the setup agent's polling discipline: an idle parent never woke when the verification task settled, so the verdict was lost. Make the wait deterministic: - manage_tasks launch gains notifyOnSettle. On run-token standard launches it stamps sourceRunId with the launching run and persists notifySourceRunOnSettle on the spawned task payload. - finishRun now calls notifySourceRunOnSettle: when an opted-in run settles (completed / failed / canceled / idle), the platform injects a "Spawned task update" prompt into the launching run's sandbox — waking it if idle — with the settle status, environmentSetupState, and error. Delivery is at-most-once (guarded via the run result JSON), skips same-task resume chains and exited parents, uses a deployment-service- principal token so the parent's acting user is untouched, and never throws; delivery and failures are recorded as run lifecycle events. - The environment-setup skill launches verification with notifyOnSettle, treats the settle message as the primary completion signal with get_summary polling as fallback, and its verification prompt reads .roomote/setup-status.json before judging. - Re-lands the #340 ground truth reverted in #346: environmentSetupState in the task summary API and the Environment Setup line in get_summary. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
|
No code issues found. See task
Reviewed 7b6d35c |
- Persist sourceRunId on the fresh task_runs row: enqueueFreshLaunch dropped the task-level pointer, so every spawned run had a null sourceRunId and the settle notification could never fire. - Splice the finalized error into the run passed to the notifier; the pre-transaction row still carried the previous error. - Claim delivery atomically (conditional JSONB update on the marker) before sending, so concurrent finalizations cannot both notify. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The environment-setup workflow launches a verification task against the persisted environment — the end-to-end test of the product pipeline: Roomote provisioning a fresh workspace from the config, executing the setup commands the way the platform executes them, and an agent working inside the result. That test stays (rework of the reverted #340, per the Slack discussion).
What was broken is how its outcome got consumed: the setup agent waited by polling
get_summary, and that wait is purely agent-dependent. If the setup task went idle while the verification task ran, nothing woke it when the child settled — the verification ran, but its verdict was lost and the environment could be handed over on local evidence alone.Changes
Deterministic feedback (platform-side, no agent diligence required)
manage_taskslaunchgainsnotifyOnSettle. On run-token standard launches it stampssourceRunIdwith the launching run and persistsnotifySourceRunOnSettleon the spawned task's payload. User-token launches ignore the flag (no run to notify).finishRunnow calls a newnotifySourceRunOnSettle: when an opted-in run settles (completed / failed / canceled / idle), the platform injects aSpawned task updateprompt into the launching run's sandbox via the existing sandbox RPC — waking the parent if it went idle — carrying the settle status,environmentSetupState, and any error, plus a pointer toget_summary/get_messagesfor the full outcome. Same inject-on-settle pattern Make environment setup completion observable to the task and platform #333 established for background setup, one level up.resultJSON, so an idle-then-completed run doesn't notify twice), same-task resume chains excluded (sourceRunIdis shared with resume lineage), exited/sandbox-less parents skipped, deployment-service-principal token so the parent's acting user is untouched, and the whole path never throws out offinishRun. Delivery and failures are recorded as run lifecycle events.Skill (prompt-first)
notifyOnSettle: true; a new step tells the setup agent the settle message is the primary completion signal — it can safely go idle between checks — withget_summarypolling as the fallback. The fix loop relaunches with the flag and waits for the new notification..roomote/setup-status.jsonfirst, waits for a terminal state before judging, and reports failing command names/exit codes/log excerpts.Re-lands the ground truth from #340 (reverted in #346)
environmentSetupStatein the task summary API and theEnvironment Setup:line inget_summary, so both the settle notification and the fallback polling carry deterministic setup evidence.Not included (deliberately): the in-workspace proof-runner verification loop from #340 — orthogonal to this fix and can be discussed separately.
Testing
notifySourceRunOnSettletests (delivery + prompt contents, failed-run evidence, opt-in/pointer/idempotence/resume-chain/exited-parent guards, never-throws) and the finish-run suite passes with the notifier mocked (50).launchTasktests (run-token stamping, user-token ignore, no-flag default) plus the re-landed summary assertion (14 total).get_summaryrendering tests (10).types,sdk,api,worker,cloud-agents,web; changed files pass Prettier.🤖 Generated with Claude Code