Skip to content

feat(tools): TaskCreate family + Monitor (background tasks)#135

Merged
oratis merged 1 commit into
mainfrom
feat/task-create-family
May 31, 2026
Merged

feat(tools): TaskCreate family + Monitor (background tasks)#135
oratis merged 1 commit into
mainfrom
feat/task-create-family

Conversation

@oratis
Copy link
Copy Markdown
Owner

@oratis oratis commented May 31, 2026

Summary

Implements §0.1's "TaskCreate 全系" — async background tasks that run a sub-agent concurrently with the main turn (cron covers recurring jobs; this covers background ones). Previously entirely missing (the audit's biggest P0 gap).

Design

  • tasks/manager.tsTaskManager (runner-agnostic): create() starts a task without blocking the caller, pipes streamed output into the task buffer (onChunk), and flips status on settle; get / list / output / update / stop / wait. A task is { id, description, status, output, createdAt, finishedAt }.
  • tools/task-manage.tsTaskCreate / TaskList / TaskGet / TaskOutput / TaskUpdate / TaskStop / Monitor, driving ctx.tasks. Monitor blocks until the task completes/fails/stops. All no-op gracefully when ctx.tasks is absent.
  • agent loop: at depth 0 only, wires ctx.tasks = TaskManager whose runner backs each task with runSubAgent + a per-task AbortController (so TaskStop cancels just that task). runSubAgent gained an optional signal. The 7 tools are in SUBAGENT_TOOL_DENYLIST (a sub-agent can't spawn tasks) and MCP_SERVE_EXCLUDE. Registered in BUILTIN_TOOLS (now 26).

Tests

+10: TaskManager (create→wait→completed, failed runner, stop+abort+no-op-second-stop, streaming onChunk kept over final text, list/get/update/unknown-id) and the tools (TaskCreate+Monitor round-trip, TaskList/TaskOutput, TaskStop, no-manager guard, unknown ids). Core suite 618 green; full repo green via pre-commit.

Note

v1 surfaces the task's final output on completion; per-chunk streaming from a live sub-agent is a follow-up (the manager already supports onChunk, so it's additive — runSubAgent just needs to forward events).

🤖 Generated with Claude Code

Implements §0.1's "TaskCreate 全系" — async background tasks that run a
sub-agent concurrently with the main turn (cron covers *recurring*; this covers
*background*). Previously entirely missing.

core (tasks/manager.ts): TaskManager — runner-agnostic. create() starts a task
without blocking, pipes streamed output into the task buffer (onChunk) and flips
status on settle; get/list/output/update/stop/wait. Each task is
{id,description,status,output,createdAt,finishedAt}.

tools (tools/task-manage.ts): TaskCreate / TaskList / TaskGet / TaskOutput /
TaskUpdate / TaskStop / Monitor, driving ctx.tasks. Monitor awaits completion.
All no-op gracefully when ctx.tasks is absent.

agent loop: at depth 0 (top-level only), wires ctx.tasks = TaskManager whose
runner backs each task with runSubAgent + a per-task AbortController (so TaskStop
cancels just that task). runSubAgent gained an optional `signal`. The 7 tools are
in SUBAGENT_TOOL_DENYLIST (a sub-agent can't spawn tasks) and MCP_SERVE_EXCLUDE.
Registered in BUILTIN_TOOLS (now 26).

Tests: +10 — TaskManager (create/wait/fail/stop/streaming/list/update) and the
tools (create+Monitor round-trip, list/output, stop, no-manager guard, unknown
ids). Core 618 green.

Note: v1 surfaces final output on completion; per-chunk streaming from a live
sub-agent is a follow-up (the manager already supports onChunk).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@oratis oratis merged commit 4adfc03 into main May 31, 2026
3 checks passed
@oratis oratis deleted the feat/task-create-family branch May 31, 2026 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant