Files
cokaremote/docs/superpowers/specs/2026-09-17-managed-task-tools-design.md
T

1.9 KiB

Managed Task Tools Design

Goal

Make long-running Coka MCP work resilient to ChatGPT response-stream interruption while reducing tool-call count and response payload size.

Design

Keep the existing ProcessManager and all low-level process tools intact. Add a ManagedTaskManager facade that owns stable task keys, writes the complete process output to a log file, returns bounded summaries, and maps task keys back to process session IDs.

A managed task is identified by a caller-supplied taskKey. Calling start again with the same key and same command/cwd reuses the retained task instead of executing it twice. A completed task may be explicitly restarted. Reusing a key for a different command/cwd is rejected unless the prior task has completed and an explicit restart is requested.

MCP tools

  • start_managed_task: start or safely reuse a non-interactive long-running shell command. Wait only for a small initial interval, then return compact state.
  • read_managed_task: optionally long-poll a task and return compact state, important lines, and a bounded log tail.
  • list_managed_tasks: list recoverable running/recent tasks by stable task key.
  • cancel_managed_task: terminate a running managed task using the existing process-tree termination semantics.

Log behavior

Full stdout and stderr are appended to a per-task log beneath the configured managed-task log directory. The MCP result never returns the full log by default. It returns a bounded tail plus selected important lines captured across the full output stream (errors, failures, warnings, successful/failed build markers, and common test summaries), so early failures are not lost when later output pushes them outside the tail.

Compatibility

Existing exec_command, run_script, read_process, write_stdin, terminate_process, and list_processes behavior remains unchanged. Managed-task functionality is additive.