agent-orchestrator icon indicating copy to clipboard operation
agent-orchestrator copied to clipboard

Stop background tasks from the remaining chat harnesses

Open Annieeeee11 opened this issue 2 weeks ago • 0 comments

PR #7550 adds the background tasks tab above the chat composer. A running task gets a stop square only when its harness can stop it, and today that is Claude Code and Codex background terminals. Every other harness shows its tasks with no way to stop them from Orchestrator.

How it works for Claude Code

  • AO's packaged Claude runtime registers _ao/session/stop_background_task, which calls the Claude Agent SDK's stopTask(taskId). It only accepts a task that is in the live background set (frontend/scripts/build-acp-runtime-helpers.mjs).
  • claudeacp wires that call into the ACP driver's StopBackgroundTask hook. The runtime marks each live task stoppable, and the daemon passes that through.
  • POST /api/v1/sessions/{sessionId}/background-tasks/{taskId}/stop returns 204 on success and 409 BACKGROUND_TASK_NOT_STOPPABLE when the harness cannot stop the task.

How it works for Codex

  • codexappserver stops one background terminal with the app-server's experimental thread/backgroundTerminals/terminate ({threadId, processId} → {terminated}), which every supported Codex has (0.146.0 and later). Only terminals the latest thread/backgroundTerminals/list returned are marked stoppable; Codex subagents are not.
  • Codex reports a killed terminal through item/completed with a non-zero exit, so the driver remembers the terminals it asked to stop and settles them as stopped, not failed.

What's missing

  • Other ACP harnesses (OpenCode, Droid, Kimi, Pi, Cursor, Qwen, Copilot, Command Code, DeepSeek and the rest): their background tasks come from tool events, and ACP v1 has no request to stop one. Each one needs either a provider extension or ACP support.
  • Unreal Agent: it reports tasks and has no stop path.

Done when

  • Each harness that gains a stop control implements ports.ChatBackgroundTaskStopper on its conversation, and reports Stoppable: true only on tasks it can actually stop.
  • The composer tab needs no change: the stop square appears as soon as the harness reports a task as stoppable.
  • A harness that cannot stop a task keeps returning ErrBackgroundTaskNotStoppable, so the UI never shows a control that does nothing.

Related PRs

  • #8780 shows Codex subagents as a team: each launch, its child's steps, and its report. It adds no stop control, so Codex subagents still can't be stopped. That stays in scope here.
  • #8782 shows OpenCode 1 and 2 subagents the same way. It adds no stop control either, so stopping an OpenCode task or subagent stays in scope here.

Annieeeee11 avatar Nov 13 '26 12:11 Annieeeee11