Skip to content

Keep CLI harness sessions in progress while background work is pending - #16367

Merged
harryalbert merged 4 commits into
masterfrom
factory/debounce-cli-success
Oct 8, 2026
Merged

harryalbert merged 4 commits into
masterfrom
factory/debounce-cli-success

Conversation

@warp-agent-staging

@warp-agent-staging warp-agent-staging Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Description

Third-party harness runs (Claude Code) reported SUCCEEDED on every assistant turn and IN_PROGRESS on the next one, because the warp plugin's Stop hook was mapped 1:1 to task success. Claude Code starts turns on its own whenever background work completes (run_in_background Bash, Monitor watches, subagents, session crons), so a run babysitting a build flapped between the two states on every wake — each SUCCEEDED fanning out to GitHub/Slack/Linear notifiers ("Warp has completed this task." per heartbeat), the lifecycle notifier, usage charging, and the idle-exit timer. The idle timer side also meant a run waiting on a long subagent could be /exited at --idle-on-complete while the subagent was still running.

Claude Code's Stop hook input includes background_tasks and session_crons, which exist precisely to distinguish "session is done" from "session is paused waiting for background work to wake it back up". The warp plugin (2.4.0, warpdotdev/claude-code-warp#92) now forwards both counts on the stop event. On the client, a Stop that carries pending work updates the session's context but leaves its status untouched: no StatusChanged is emitted, so LocalAgentTaskSyncModel reports nothing and the driver does not arm the idle timer, until a Stop with nothing pending arrives. finish-task, the /exit path, and the exit-time SUCCEEDED fallback in AgentDriver::flush_task_status_before_exit are unchanged.

MINIMUM_PLUGIN_VERSION for Claude moves to 2.4.0 per the plugin repo's versioning policy, so the driver updates older installs. The plugin PR must land first; until the marketplace serves 2.4.0, the (non-fatal) notification-plugin update step logs a failure on each run.

This replaces the earlier debounce approach on this branch, which is fully reverted.

Known tradeoff: a background task that never finishes (or whose completion notification Claude Code drops) now keeps the run IN_PROGRESS with no idle timer until the sandbox deadline, instead of exiting at idle-on-complete.

Linked Issue

Ad hoc intake; no tracked issue.

  • The linked issue is labeled ready-to-spec or ready-to-implement. — No tracked issue.
  • Where appropriate, screenshots or a short video of the implementation are included below. — Not applicable: no UI changes.

Testing

  • cargo nextest run -p warp cli_agent_sessions — 180 passed. Two new tests: a stop with background_task_count: 1 leaves the session InProgress while still recording the response; a stop with zero counts still yields Success.

  • cargo nextest run -p warp local_agent_task_sync_model plugin_manager — 135 passed (sync model is back to master).

  • cargo clippy -p warp_core -p warp --all-targets --tests -- -D warnings — clean; ./script/format run last.

  • Confirmed Claude Code 2.1.252 populates background_tasks for an in-flight background shell task (Stop Search history by more than just command #1) and reports it empty on the post-notification turn (Stop Real-time collaboration #2).

  • End-to-end on the local Oz stack (script/oz-local, direct backend, this branch's bundle, local plugin checkout): a Claude run that starts sleep 60; echo finished in the background, replies, and is woken by the task-notification now produces exactly one agent_started and one oz_run_done (at the final turn), versus two pairs before this change.

  • I have manually tested my changes locally with ./script/run

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

CHANGELOG-BUG-FIX: Claude Code harness runs no longer report completion and re-open on every assistant turn while background tasks, subagents, or scheduled wakeups are still running; completion is reported once the session is actually idle, or immediately on finish-task.

@warp-agent-staging

Copy link
Copy Markdown
Contributor Author

This PR was generated with Warp.

Comment @warp-staging-factory on this PR to send it follow-up work.

View run View conversation

Comment thread app/src/ai/blocklist/local_agent_task_sync_model.rs Outdated
warp-agent-staging Bot and others added 2 commits October 8, 2026 20:47
Claude Code fires Stop at the end of every assistant turn, including turns that end while
background tasks or session crons will wake the agent again. Treating each of those as task
success made third-party harness runs flap between SUCCEEDED and IN_PROGRESS on every wake,
notifying integrations and arming the idle-exit timer each time.

The warp plugin (2.4.0) now reports pending background work on the stop event. A Stop that
carries any is a pause rather than a completion: the session keeps its status, so no task
state is reported and the idle timer is not armed, until a Stop with nothing pending arrives.
finish-task and the exit-time fallback are unchanged.

Replaces the debounce approach and requires warp plugin 2.4.0.

Co-Authored-By: Warp <agent@warp.dev>
@warp-factories

warp-factories Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

@harryalbert, your Warp account is not a member of any team with access to this repository.

@warp-local-for-testing-only

Copy link
Copy Markdown

@harryalbert, your GitHub account is not connected to Warp. Connect your GitHub account.

@harryalbert harryalbert changed the title Debounce third-party CLI turn success reports Keep CLI harness sessions in progress while background work is pending Oct 8, 2026
@harryalbert
harryalbert marked this pull request as ready for review October 8, 2026 21:55
@harryalbert
harryalbert enabled auto-merge (squash) October 8, 2026 22:05
@harryalbert
harryalbert merged commit 42e2a7d into master Oct 8, 2026
53 of 56 checks passed
@harryalbert
harryalbert deleted the factory/debounce-cli-success branch October 8, 2026 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant