Repository navigation
program: keep run shimmer alive past owning-session idle (clear on settle / terminal / inactivity) - #569
Merged
Conversation
The daemon cleared a program run's entire shimmer the moment the owning session returned to AwaitingInput after being seen running. For a run that delegates work to subagents (or drives it with a /loop or background monitor), the owning turn ends as soon as the hand-off is done while the work is still in flight, so every pending-block shimmer was wiped early — the opposite of the pending-vs-settled contract (specs 0048/0051). Re-base the authoritative stop off the owning *turn* and onto the *run*: - clear when the pending set empties (declarations settle every block); - clear on a terminal owning-session state (done/errored) after seen-running, since the agent is gone and can never settle the rest; - clear via an inactivity backstop (the existing 10-min cap, now refreshed by in-run program declarations/edits) once the run goes silent; - AwaitingInput is no longer a stop signal for a run the agent is actively managing. Any in-run declaration/edit sets a new agent_managed flag on ProgramRunProgress; an unmanaged optimistic run on a non-declaring harness still clears on idle, exactly as before. Update specs 0042 (stop-signal decision + consequences) and 0048 (the turn-end clause). Adds two daemon lifecycle tests.
edwin-zvs
added a commit
that referenced
this pull request
Jun 29, 2026
…053, break pending_block_signatures compat main advanced with #569 (keep run shimmer alive past owning-session idle), which reworked the same shimmer lifecycle and added agent_managed to ProgramRunProgress, plus #563/#568 (specs 0051 custom-templates, 0052 session-removal-cascades). Reconcile: - protocol: keep pending_block_ids rename + the declared-shimmer types alongside #569's agent_managed field; DROP the pending_block_signatures serde alias (clean break, per request) and remove the legacy-compat test. - daemon: fold #569's agent_managed + inactivity-backstop refresh into the declaration-based narrow_program_run and set_program_run_pending so a complete/partial declaration also marks the run agent-managed; #569's AwaitingInput/terminal stop-signal split is preserved. Adapt #569's two lifecycle tests to the id-based API. - specs 0042/0048: combine #569's stop-signal model with the declared per-block-id model; my new spec collides with main's 0051/0052, renumbered to specs/0053-program-shimmer-block-addressing and all references updated. cargo test --workspace green.
This was referenced Jun 29, 2026
edwin-zvs
added a commit
that referenced
this pull request
Jun 29, 2026
…g (0053) (#576) Diagnosed from the 'construct improvements' session: after the planning pass declared the task pending, dispatching a subagent moved the task into the "In progress" section and appended a @{session} clip — which changes the block's text and therefore its id. The old id dropped from the pending set before the new id was declared, so the set transiently emptied; the daemon reaped the whole run on that empty, and the agent's follow-up re-declaration of the new id hit a removed run and was a silent no-op. All shimmer vanished. The agent's own narration: "the system won't re-light a settled/new block". Fix #1 — survive transient empty. narrow_program_run / set_program_run_pending no longer remove a run when its pending set empties; program_run_snapshot reports no active run on empty but KEEPS the record so a later declaration revives it. An empty run is reaped only on a terminal owning-session state, the owning session going idle with nothing pending, or the inactivity backstop (note_session_state handles the idle case). Fix #2 — atomic keep_pending. Re-introduce a per-edit ProgramEdit.keep_pending flag: an edit that changes a still-pending block re-adds the resulting block's new id in the SAME narrowing call (anchored on the edit's new_string), so a move/annotate never transiently empties the set and the agent needn't know the post-edit id. The call-level shimmer id-list still handles declaring arbitrary existing blocks (planning pass). Specs 0042 (stop lifecycle: transient empty is not a stop), 0048 (contract: use keep_pending when editing an in-flight block), 0053 (both mechanisms + transient-empty survival). Three new daemon tests; #567/#569 tests unaffected.
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.
Why
A live program run cleared all shimmer the instant the owning session went idle. Investigating the "canvas template" session: the agent did everything right — planning pass, kept `shimmer: true` on the one block it delegated, handed it to a subagent — then ended its own turn (
AwaitingInput). The daemon's authoritative stop signal fired on that idle transition and reaped the entire run, wiping the still-pending shimmer ~11 minutes before the subagent (stillrunning, 145 events) will finish.Root cause: the stop signal is bound to the owning turn (
note_session_state_for_program_runclears onAwaitingInput|Done|Erroredafter seen-running). But a self-scheduling agent — delegated subagents, a/loop, a background monitor — returns to idle as soon as it finishes dispatching, not when the work completes. There is no real turn boundary, so "owning session idle" ≠ "run done." This directly contradicts the pending-vs-settled contract (0048/0051): a block delegated to a subagent must keep shimmering until it settles.What
Re-base the authoritative stop off the owning turn and onto the run itself. A run now clears when, in priority order:
done/errored) after being seen running — the agent is gone and can never settle the rest;AwaitingInputis no longer a stop signal for a run the agent is managing. Any in-run program declaration/edit (program_editorprogram_update, both vianarrow_program_run) sets a newagent_managedflag onProgramRunProgress. An unmanaged optimistic run — one no declaration ever narrowed, e.g. on a non-declaring PTY harness — still clears on the idle transition, exactly as before, so dumb-harness shimmer remains turn-duration.Changes
crates/protocol: new#[serde(default)] agent_managed: boolonProgramRunProgress.crates/daemon:narrow_program_runmarks the run managed + refreshes the backstop;note_session_state_for_program_runsplitsAwaitingInput(clear only if unmanaged) fromDone/Errored(always clear after seen-running). Two new lifecycle tests.specs/0042: Stop-signal decision + consequences rewritten for the liveness model.specs/0048: the one "clears at turn end" clause corrected.Client needs no change — it mirrors the daemon-published run state (
on_program_state) and reaps on its local (now-refreshed) deadline.Tests
program_run_managed_survives_idle_and_clears_on_settle— managed run survivesAwaitingInput(incl. repeated wake/idle cycles), clears when the pending set empties.program_run_managed_clears_on_terminal_state— terminal state clears even a managed run with pending blocks.test_program_run_lifecycle_daemon(unmanaged → clears on idle) unchanged and passing.agentd+agentd-cliprogram/shimmer suites green (incl. the orchestrator + spinner tests).Coordination
0042's stop signal as-is). Both editspecs/0042/0048but on different lines; expect a trivial merge. No dependency either way.construct(the daemon runs asconstruct daemon run); the logic lives incrates/daemon+ thecrates/protocolfield.A before/after TUI recording would need a live delegation run that goes idle while a subagent works — happy to capture one if useful, but the surface is daemon lifecycle, so I left it out by default.