Prompt a finished `clai2` web worker on its own instead of asking the parent agent to resume it
No linked issue: requested directly by @mpfaffenberger.
Why we make these changes
A finished worker's view in the clai2 web UI had a Resume button. All it did was queue a message asking the parent agent to resume the task. Now a finished, resumable worker takes prompts itself. Its saved history continues with the same sub-agent, tools, model and workspace, and the replies stream into the worker's own view. The parent conversation's history, queue and transcript are left alone.
It reuses the delegation path instead of rebuilding a sub-agent. Session.prompt_task runs the session's agent with message_history=[] and a scripted TaskPrompt capability (via SkipModelRequest, as /monty cells do). That capability calls the SubAgents delegate tool once with resume=TASK_ID, and the harness DelegationTasks saves the extended history. The delegation runs in the foreground of that scripted run, so the report never reaches the conversation. The run is marked with TASK_PROMPT metadata, so the web Observer skips it. Code mode keeps the delegate tool native only in that run.
New public surface
TaskCatalog.prompt(task_id, text)and its implementation,Tasks.prompt.TaskInfo.backgroundableand the webTaskEntry.backgroundable, both defaulting toFalse.POST /api/tasks/{id}/prompt. The bundled page no longer callsPOST /api/tasks/{id}/resume, which still asks the parent agent to resume the task, as/tasks resumedoes.
User-visible behavior
- Before: a finished worker's view had a Resume button that queued a message asking the parent agent to resume the task.
- After: a finished, resumable worker's view has a prompt box (Enter sends). Replies stream into the worker's own view, and the parent conversation doesn't change.
Edge cases:
- Running worker: keeps the steer box.
- One-shot
Explore/Planworkers: show a note instead. - Prompted tasks can't be backgrounded: no run waits for them. The Background button now shows only when
backgroundable, and the/tasksinspector goes through the same guard. - Refusals: a second prompt sent while the task is still starting is refused (HTTP 400).
Verification
tests/clai2/test_task_catalog.py:test_prompt_runs_a_finished_task_on_its_owntest_prompt_refuses_what_it_cannot_runtest_a_task_starting_from_a_prompt_takes_no_second_onetest_a_run_prompted_again_is_not_forgotten_by_the_one_beforetest_a_session_that_delegates_nothing_prompts_no_task
tests/clai2/test_web_workers.py:test_workers_stream_steer_and_control: the prompt endpoint end to end (400 and 404 refusals), andPOST /api/tasks/{id}/resumestill asking the parent agent (204, and a turn whose prompt isresume_prompt(record)).test_a_prompted_task_runs_beside_a_turn_with_code_mode_ontest_a_task_takes_no_prompt_once_its_agent_delegates_no_more
tests/clai2/test_tasks.py:test_open_tasks_does_not_background_a_prompted_task- Browser check: headless Chromium against a scripted
clai2 --web.- The worker finishes and its prompt box appears; there is no Resume button.
- The reply streams in.
- Two follow-ups both land in the worker transcript.
- None of it appears in the parent session view.
What changes for existing users
Only web UI users see a change: a finished worker's view shows a prompt box instead of the Resume button. HTTP callers of POST /api/tasks/{id}/resume see no change.
Checklist
- No breaking changes in accordance with the version policy.
- Any permitted compatibility impact has a label, warning, migration, release note, and exact API-check waiver.
- PR title is fit for the release changelog.