feat: add task autopilot mode and MCP profiles (#2445)
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
# ADR-2026-08-08-autopilot-mcp-question-capabilities: Use One Question Capability Per Task Session
|
||||
|
||||
**Status:** accepted
|
||||
**Date:** 2026-08-08
|
||||
**Area:** backend, agentctl, protocol
|
||||
**Related ADR:** [ADR-2026-08-08-task-autopilot-contract](2026-08-08-task-autopilot-contract.md)
|
||||
**Related spec:** [Task Autopilot Mode](../specs/tasks/autopilot-mode.md)
|
||||
|
||||
## Context
|
||||
|
||||
Task-mode MCP currently uses one `disableAskQuestion` switch. It can hide the
|
||||
operator question tool, but it cannot express why the tool is hidden or select a
|
||||
different question owner. Adding `ask_parent_question_kandev` beside the existing
|
||||
tool would make both tools visible unless every registration path applies the same
|
||||
condition.
|
||||
|
||||
Both question tools expose overlapping schemas and instructions. Showing both
|
||||
consumes model context and lets an autopilot agent choose the wrong owner. A
|
||||
top-level autopilot task also has no parent to ask.
|
||||
|
||||
## Decision
|
||||
|
||||
1. The backend derives one question capability for each task session and transports
|
||||
it as one enum-like value. It must not transport independent booleans that can
|
||||
expose both tools.
|
||||
2. The capability matrix is:
|
||||
|
||||
| Task | Direct parent | MCP question capability |
|
||||
|---|---|---|
|
||||
| Normal | Any | `ask_user_question_kandev` |
|
||||
| Autopilot | Present | `ask_parent_question_kandev` |
|
||||
| Autopilot | Absent | None |
|
||||
|
||||
3. The MCP server registers exactly the tool selected by the capability. It never
|
||||
registers both question tools for one session.
|
||||
4. An autopilot root task receives no question tool. Its system prompt tells it to
|
||||
continue with best judgment. A stale client call to the parent-question handler
|
||||
fails closed and creates no pending state.
|
||||
5. Other task-mode tools remain governed by the existing mode and provider
|
||||
allowlists. “Minimum necessary” means that the session has no duplicate or
|
||||
unusable question capability; it does not remove tools required for task work,
|
||||
delegation, workflow control, or configured provider actions.
|
||||
6. The capability is resolved when the session MCP server is built. If a task is
|
||||
reparented while its session is active, the next session start or resume rebuilds
|
||||
the capability. The backend never silently changes the active tool list.
|
||||
|
||||
## Consequences
|
||||
|
||||
- Autopilot agents cannot call the operator question tool by discovery or normal
|
||||
schema use.
|
||||
- Root autopilot agents save the most context because they receive no question tool.
|
||||
- One capability value prevents invalid states such as both tools being registered.
|
||||
- A parent change may require a session restart or resume before the new question
|
||||
capability appears.
|
||||
- Existing task and provider tools remain available, so this decision does not
|
||||
change task execution or provider automation semantics.
|
||||
|
||||
## Alternatives Considered
|
||||
|
||||
### Register both tools and rely on the system prompt
|
||||
|
||||
Rejected. The model still receives both schemas and can select the operator tool.
|
||||
|
||||
### Add a second `enableParentQuestion` boolean
|
||||
|
||||
Rejected. Two booleans allow an invalid state where both question tools are visible.
|
||||
|
||||
### Remove every task-mode MCP tool for autopilot
|
||||
|
||||
Rejected for this change. Autopilot agents still need task execution, delegation,
|
||||
workflow, and provider tools. A complete per-task allowlist is a separate design.
|
||||
@@ -0,0 +1,99 @@
|
||||
# ADR-2026-08-08-mcp-tool-profiles: Compose MCP Tool Profiles From Typed Context
|
||||
|
||||
**Status:** accepted
|
||||
**Date:** 2026-08-08
|
||||
**Area:** backend, agentctl, protocol, workflow
|
||||
**Related ADR:** [ADR-2026-08-08-autopilot-mcp-question-capabilities](2026-08-08-autopilot-mcp-question-capabilities.md)
|
||||
**Related spec:** [Task Autopilot Mode](../specs/tasks/autopilot-mode.md)
|
||||
|
||||
## Context
|
||||
|
||||
Kandev already has MCP modes, but the implementation is a large switch in
|
||||
`internal/mcp/server/server.go`. It registers tool groups for `task`,
|
||||
`task-title-pending`, `config`, `office`, and `external`. A separate
|
||||
`disableAskQuestion` boolean removes the user-question tool, and a provider list
|
||||
adds GitHub or GitLab automation tools.
|
||||
|
||||
This works for the current cases, but each new context needs another branch,
|
||||
another tool-count adjustment, and another transport field. It also makes it easy
|
||||
to expose a tool that does not belong to the current task. Autopilot needs a parent
|
||||
question tool, title ownership needs a title tool, and Office tasks need a smaller
|
||||
surface without Kanban task creation.
|
||||
|
||||
## Decision
|
||||
|
||||
1. Model the MCP surface as a typed profile context. The context has:
|
||||
- a base surface;
|
||||
- additive, named capability groups; and
|
||||
- provider capabilities.
|
||||
2. The initial base surfaces are:
|
||||
|
||||
| Surface | Core tool groups |
|
||||
|---|---|
|
||||
| `kanban-task` | Kanban task operations, planning, walkthrough, review, related tasks, workspace/branch actions, step completion, and diagnostics |
|
||||
| `office-task` | Interaction, planning, related tasks, and task documents; no Kanban task creation tools |
|
||||
| `configuration` | Workflow, agent, MCP, executor, and configuration-task tools |
|
||||
| `external` | Configuration tools plus `create_task_kandev`; no live-session tools |
|
||||
|
||||
3. The initial additive capability groups are:
|
||||
- `user-question`;
|
||||
- `parent-question`;
|
||||
- `task-title`;
|
||||
- provider groups such as GitHub PR and GitLab MR automation.
|
||||
4. The backend resolves the profile context from session purpose and task state:
|
||||
base surface, autopilot value, direct-parent presence, title ownership, and
|
||||
attached providers. Agentctl receives the resolved typed profile context. The
|
||||
agent cannot request arbitrary tool names or capabilities.
|
||||
5. The MCP server owns one declarative registry of tool groups. Each group has one
|
||||
registration function and one enablement rule. Profile assembly loops over the
|
||||
registry and atomically replaces the MCP tool set. New context-specific tools
|
||||
are added by adding a capability group and a resolver rule, not by copying a
|
||||
complete mode branch or editing a manual count.
|
||||
6. Question capabilities use the existing mutually exclusive rule:
|
||||
- normal task → `user-question`;
|
||||
- autopilot child → `parent-question`;
|
||||
- autopilot root → neither question group.
|
||||
7. Existing `McpMode` values remain accepted as compatibility aliases and map to
|
||||
base surfaces. `task-title-pending` maps to `kanban-task` plus `task-title`.
|
||||
`SetMcpMode` and `SetMcpProviders` continue to work during migration; a typed
|
||||
profile update becomes the backend-owned path for additive capability changes.
|
||||
8. Profiles are runtime state. Only the task's `autopilot` value is durable. The
|
||||
profile is rebuilt on launch, resume, and an authorized live profile update.
|
||||
Every replacement sends one `tools/list_changed` notification.
|
||||
|
||||
## Consequences
|
||||
|
||||
- Tool discovery is smaller and matches the session context.
|
||||
- Office agents cannot discover Kanban task creation tools and continue to use the
|
||||
Office skill/CLI path.
|
||||
- Autopilot can remove the user-question group and add the parent-question group
|
||||
without changing the base Kanban profile.
|
||||
- Title tools, provider automation, and future context features become additive
|
||||
capabilities instead of new mode branches.
|
||||
- The backend and agentctl gain a typed profile transport and registry tests.
|
||||
- Profile changes require atomic rebuild and client notification. A stale client
|
||||
may still call an old tool, so handlers must keep their existing authorization and
|
||||
context checks.
|
||||
|
||||
## Alternatives Considered
|
||||
|
||||
### Keep adding branches to `registerTools`
|
||||
|
||||
Rejected. The branch and count logic grows with every context and can expose tools
|
||||
that are not valid for the session.
|
||||
|
||||
### Create one enum for every final tool combination
|
||||
|
||||
Rejected. Autopilot, title ownership, providers, and future features would create a
|
||||
large cross-product of enum values.
|
||||
|
||||
### Let the agent send an arbitrary tool allowlist
|
||||
|
||||
Rejected. Tool discovery is a backend capability boundary. An agent must not grant
|
||||
itself configuration, task mutation, or provider tools.
|
||||
|
||||
### Keep `McpMode` as the only extension point
|
||||
|
||||
Rejected. Base surfaces and optional capabilities have different lifecycles. A
|
||||
single mode string cannot represent provider additions or title ownership without
|
||||
repeating full profiles.
|
||||
@@ -0,0 +1,111 @@
|
||||
# ADR-2026-08-08-task-autopilot-contract: Make Task Autopilot a Creation-Time Runtime Contract
|
||||
|
||||
**Status:** accepted
|
||||
**Date:** 2026-08-08
|
||||
**Area:** backend, agentctl, frontend, protocol, workflow
|
||||
**Related issue:** [#2425](https://github.com/kdlbs/kandev/issues/2425)
|
||||
**Related spec:** [Task Autopilot Mode](../specs/tasks/autopilot-mode.md)
|
||||
|
||||
## Context
|
||||
|
||||
Kandev task agents currently receive a task-mode system prompt and an MCP tool
|
||||
inventory when their runtime session is launched. An agent can ask the operator a
|
||||
clarification through `ask_user_question_kandev`, but that call waits for the
|
||||
operator's answer. This is unsuitable for delegated autonomous work: a child can
|
||||
block while its parent is busy, the question can time out, and the operator can be
|
||||
shown a question that the parent agent could have answered.
|
||||
|
||||
Autopilot changes both behavioral guidance and the capabilities an agent should
|
||||
discover. Allowing the setting to change during a running task would require an
|
||||
atomic prompt and tool-inventory replacement across active, waiting, resumed, and
|
||||
restarted sessions. A partially applied change would create a split-brain session
|
||||
whose prompt and available tools disagree.
|
||||
|
||||
## Decision
|
||||
|
||||
1. Autopilot is an immutable, persisted property of a task in its first release.
|
||||
It is selected at creation, defaults to `false`, and is exposed in task DTOs.
|
||||
Editing an existing task cannot change it.
|
||||
2. Creation APIs, including `create_task_kandev`, accept an explicit `autopilot`
|
||||
boolean. The value does not implicitly inherit from the parent when omitted.
|
||||
An autopilot agent that wants autonomous delegation must create its child with
|
||||
`autopilot: true` deliberately.
|
||||
3. The backend derives the session's behavioral prompt and MCP capability set from
|
||||
the persisted task property. Agentctl enforces the supplied capability set; it
|
||||
does not infer autopilot from prompts or parentage.
|
||||
4. An autopilot child with a direct parent does not discover
|
||||
`ask_user_question_kandev`. It instead discovers `ask_parent_question_kandev`,
|
||||
which records a structured question and sends it to the task's current direct
|
||||
parent without waiting for an answer. The parent target is resolved by the
|
||||
backend and is never caller supplied. An autopilot root receives no question
|
||||
tool.
|
||||
5. `ask_parent_question_kandev` is a terminal action for the current logical turn.
|
||||
The tool response tells the agent to end its turn, and the autopilot system
|
||||
prompt requires the tool to be its last action. At turn completion the child
|
||||
remains waiting on the recorded parent question rather than completing its
|
||||
workflow transition or draining unrelated queued prompts.
|
||||
6. A parent answers through `message_task_kandev` with a correlated
|
||||
`reply_to_question_id`. The backend accepts the answer only from the recorded
|
||||
direct parent and routes it to the recorded child session. Duplicate replies
|
||||
are idempotent.
|
||||
7. Pending parent questions use durable message metadata as their source of truth.
|
||||
They survive restart, project to the existing clarification pending-action
|
||||
category, and therefore reuse the sidebar question indicator without exposing
|
||||
an operator clarification card. They leave the pending state when answered,
|
||||
superseded by explicit new child input, or made stale by terminal task/session
|
||||
state.
|
||||
8. A top-level autopilot task has no human-question escape hatch. It proceeds with
|
||||
best judgment; calling the parent-question tool fails closed with a clear
|
||||
no-parent result. Nested autopilot hierarchies may relay an essential question
|
||||
one direct-parent hop at a time.
|
||||
9. Autopilot is initially supported only for persistent task-mode sessions whose
|
||||
configured agent runtime supports Kandev MCP injection. Creation with an
|
||||
incompatible profile is rejected instead of silently providing weaker
|
||||
semantics. Quick chat, Office-owned sessions, config sessions, and utility
|
||||
sessions are outside this contract.
|
||||
|
||||
## Consequences
|
||||
|
||||
- Creation-time immutability makes every launch and resume deterministic, at the
|
||||
cost of requiring a new task to change modes.
|
||||
- The backend gains a typed parent-question lifecycle and a correlated extension to
|
||||
peer messaging, but no request blocks on another agent or on the operator.
|
||||
- Existing non-autopilot tasks and root clarification behavior remain compatible.
|
||||
- The UI can show autopilot as task identity and pending questions as transient task
|
||||
state using existing shared desktop/mobile task rows.
|
||||
- Supporting live toggles later requires a separate decision covering versioned
|
||||
runtime configuration and in-flight question migration.
|
||||
|
||||
## Alternatives Considered
|
||||
|
||||
### Allow the setting to change while a task is running
|
||||
|
||||
Deferred because prompt guidance is injected at turn/session boundaries while MCP
|
||||
discovery has its own runtime update path. A correct mutable design needs a
|
||||
versioned configuration snapshot, atomic capability replacement, and explicit
|
||||
semantics for an already-pending operator or parent question. The first release
|
||||
avoids that split-brain state.
|
||||
|
||||
### Keep `ask_user_question_kandev` and rely only on prompt wording
|
||||
|
||||
Rejected because prompts are advisory. The blocking tool would remain callable and
|
||||
could still time out or route a delegated question directly to the operator.
|
||||
|
||||
### Implement parent questions by calling `message_task_kandev` directly
|
||||
|
||||
Rejected because a free-form peer message has no correlation ID or durable waiting
|
||||
state. A dedicated request tool is needed to enforce direct-parent routing,
|
||||
idempotent answers, restart recovery, and the sidebar pending indicator.
|
||||
|
||||
### Route every question directly to the root task
|
||||
|
||||
Rejected for the initial contract because the immediate parent owns the delegated
|
||||
work and may already know the answer. Direct-parent hops also preserve the existing
|
||||
authorization boundary for parent-to-child control. An autopilot parent can relay a
|
||||
question upward if it genuinely cannot decide.
|
||||
|
||||
### Add a separate parent-question table
|
||||
|
||||
Rejected because task messages already provide durable, ordered, restart-safe
|
||||
records and pending-action projection. A typed hidden message plus metadata adds the
|
||||
needed state without establishing a second conversation store.
|
||||
@@ -133,6 +133,9 @@ Read individual ADRs for full context. Create new ones via `/record decision` or
|
||||
| 2026-08-05-homebrew-remote-helper-audit | [Preserve Remote Helpers in Homebrew Installs](2026-08-05-homebrew-remote-helper-audit.md) | accepted | infra, workflow | 2026-08-05 |
|
||||
| 2026-08-07-model-aware-provider-capability-resolution | [Model-aware provider capability resolution](2026-08-07-model-aware-provider-capability-resolution.md) | accepted | backend, frontend, protocol | 2026-08-07 |
|
||||
| 2026-08-07-claude-allowlist-label-bridge | [Use the Claude Allowlist as a Trusted Preview Gate](2026-08-07-claude-allowlist-label-bridge.md) | accepted | infra, workflow, security | 2026-08-07 |
|
||||
| 2026-08-08-task-autopilot-contract | [Make Task Autopilot a Creation-Time Runtime Contract](2026-08-08-task-autopilot-contract.md) | accepted | backend, agentctl, frontend, protocol, workflow | 2026-08-08 |
|
||||
| 2026-08-08-autopilot-mcp-question-capabilities | [Use One Question Capability Per Task Session](2026-08-08-autopilot-mcp-question-capabilities.md) | accepted | backend, agentctl, protocol | 2026-08-08 |
|
||||
| 2026-08-08-mcp-tool-profiles | [Compose MCP Tool Profiles From Typed Context](2026-08-08-mcp-tool-profiles.md) | accepted | backend, agentctl, protocol, workflow | 2026-08-08 |
|
||||
| 2026-08-08-agentctl-crash-containment | [Publish Immutable Agent Events and Explicit Runtime Failure State](2026-08-08-agentctl-crash-containment.md) | proposed | backend, frontend, protocol, operations | 2026-08-08 |
|
||||
| 2026-08-08-workspace-scoped-task-create-workflow-memory | [Remember Task-Create Workflows Per Workspace](2026-08-08-workspace-scoped-task-create-workflow-memory.md) | accepted | backend, frontend | 2026-08-08 |
|
||||
| 2026-08-08-owned-temp-artifact-cleanup | [Clean only registered Kandev temporary artifacts](2026-08-08-owned-temp-artifact-cleanup.md) | accepted | backend, frontend, infra, security | 2026-08-08 |
|
||||
|
||||
@@ -0,0 +1,319 @@
|
||||
---
|
||||
spec: docs/specs/tasks/autopilot-mode.md
|
||||
created: 2026-08-08
|
||||
status: implemented
|
||||
---
|
||||
|
||||
# Implementation Plan: Task Autopilot Mode
|
||||
|
||||
## Overview
|
||||
|
||||
Persist autopilot as an immutable task-creation choice, derive a matching prompt
|
||||
and task-mode MCP tool inventory, and add a durable non-blocking parent-question
|
||||
lifecycle. Surface the identity and waiting state through shared desktop/mobile
|
||||
task components, then cover the complete create → ask → answer → resume path with
|
||||
backend, frontend, restart, and Playwright tests.
|
||||
|
||||
Issue: [#2425](https://github.com/kdlbs/kandev/issues/2425)
|
||||
|
||||
MCP profile decision: [ADR-2026-08-08-mcp-tool-profiles](../../decisions/2026-08-08-mcp-tool-profiles.md)
|
||||
|
||||
## Design constraints
|
||||
|
||||
- `autopilot` defaults to false, never implicitly inherits, and cannot be edited
|
||||
after creation.
|
||||
- The persisted task is the source of truth. Prompts, tool discovery, APIs, boot
|
||||
payloads, and UI projection must not derive the value independently.
|
||||
- Autopilot replaces the blocking operator-question capability with a structured,
|
||||
immediate-return parent-question capability.
|
||||
- Question capabilities are mutually exclusive: normal tasks get the user-question
|
||||
tool, autopilot children get the parent-question tool, and autopilot roots get no
|
||||
question tool.
|
||||
- Questions route to the current direct parent. A parent may relay upward through a
|
||||
separate question; top-level autopilot agents proceed without asking the user.
|
||||
- A pending question gates workflow completion and normal queue draining until a
|
||||
correlated parent answer, explicit superseding input, or terminal transition.
|
||||
- Existing non-autopilot clarification and peer-message behavior must remain
|
||||
unchanged.
|
||||
- The first release rejects incompatible non-task/Office/passthrough runtime modes
|
||||
rather than silently providing partial autopilot semantics.
|
||||
- MCP discovery uses a backend-owned profile registry. A base surface selects the
|
||||
task, Office, configuration, or external tool groups. Typed capability groups add
|
||||
or remove context-specific tools without copying a complete mode branch.
|
||||
|
||||
## Backend
|
||||
|
||||
### Persist and publish the task property
|
||||
|
||||
Likely files:
|
||||
|
||||
- `apps/backend/internal/task/models/models.go`
|
||||
- `apps/backend/internal/task/dto/dto.go`
|
||||
- `apps/backend/internal/task/dto/requests.go`
|
||||
- `apps/backend/internal/task/repository/sqlite/base_schema.go`
|
||||
- `apps/backend/internal/task/repository/sqlite/base_migrations.go`
|
||||
- `apps/backend/internal/task/repository/sqlite/task.go`
|
||||
- `apps/backend/internal/task/handlers/task_http_handlers.go`
|
||||
- `apps/backend/internal/mcp/server/server.go`
|
||||
- `apps/backend/internal/mcp/handlers/handlers.go`
|
||||
|
||||
Add a non-null `autopilot_enabled` task column with a false default, carry it
|
||||
through scan/insert/update/read DTO paths, and accept `autopilot` in HTTP and MCP
|
||||
creation requests. Keep it out of mutation DTOs. Validate the resolved agent
|
||||
profile/runtime mode before committing an autopilot task. Extend server schemas,
|
||||
argument validation, handler forwarding, and API contract tests together so MCP
|
||||
discovery and execution cannot drift.
|
||||
|
||||
### Derive the runtime prompt and tools
|
||||
|
||||
Likely files:
|
||||
|
||||
- `apps/backend/config/prompts/kandev-context.md`
|
||||
- `apps/backend/internal/sysprompt/sysprompt.go`
|
||||
- `apps/backend/internal/sysprompt/sysprompt_test.go`
|
||||
- `apps/backend/internal/orchestrator/task_operations.go`
|
||||
- `apps/backend/internal/orchestrator/event_handlers_workflow.go`
|
||||
- `apps/backend/internal/task/handlers/message_handlers.go`
|
||||
- `apps/backend/internal/agent/runtime/agentctl/control.go`
|
||||
- `apps/backend/internal/agent/runtime/lifecycle/container.go`
|
||||
- `apps/backend/internal/agent/runtime/lifecycle/executor_docker.go`
|
||||
- `apps/backend/internal/agent/runtime/lifecycle/executor_standalone.go`
|
||||
- `apps/backend/internal/agent/runtime/lifecycle/manager_launch.go`
|
||||
- `apps/backend/internal/agentctl/server/config/config.go`
|
||||
- `apps/backend/internal/agentctl/server/instance/instance.go`
|
||||
- `apps/backend/internal/agentctl/server/instance/manager.go`
|
||||
- `apps/backend/internal/agentctl/server/api/server.go`
|
||||
- `apps/backend/internal/mcp/server/server.go`
|
||||
- `apps/backend/internal/mcp/server/tool_profiles.go`
|
||||
- `apps/backend/internal/mcp/server/tool_profiles_test.go`
|
||||
|
||||
Carry the resolved profile context in explicit launch/runtime configuration to
|
||||
agentctl. Build the autopilot prompt section at prompt-construction time, including
|
||||
autonomy, last-action, direct-parent, and top-level behavior. Replace the current
|
||||
mode/boolean registration branch with a declarative profile registry:
|
||||
|
||||
- `kanban-task` keeps the current Kanban task, plan, review, workspace, and
|
||||
diagnostics groups;
|
||||
- `office-task` keeps the slimmer Office/skill/CLI surface and no Kanban task
|
||||
creation tools;
|
||||
- `configuration` keeps configuration groups;
|
||||
- `external` keeps configuration plus task creation and no live-session tools;
|
||||
- additive groups handle `user-question`, `parent-question`, `task-title`, and
|
||||
provider automation.
|
||||
|
||||
Question groups remain mutually exclusive: parent question for an autopilot child,
|
||||
no question group for an autopilot root, and user question for a normal task. Use
|
||||
one typed profile context instead of independent enable/disable booleans or an
|
||||
agent-supplied arbitrary allowlist. Keep `SetMcpMode` and `SetMcpProviders` as
|
||||
compatibility paths while adding the backend-owned profile update path. Tests must
|
||||
cover first launch, resume/restart, reparenting, live list replacement, and every
|
||||
executor transport used by task sessions.
|
||||
|
||||
### Add the parent-question lifecycle
|
||||
|
||||
Likely files:
|
||||
|
||||
- `apps/backend/internal/mcp/server/server.go`
|
||||
- `apps/backend/internal/mcp/server/handlers.go`
|
||||
- `apps/backend/internal/mcp/handlers/handlers.go`
|
||||
- `apps/backend/internal/task/models/models.go`
|
||||
- `apps/backend/internal/task/repository/sqlite/message.go`
|
||||
- `apps/backend/internal/task/statussummary/model.go`
|
||||
- `apps/backend/internal/task/statussummary/projector.go`
|
||||
- `apps/backend/internal/task/statussummary/rebuild.go`
|
||||
- `apps/backend/internal/task/handlers/message_handlers.go`
|
||||
- `apps/backend/internal/orchestrator/event_handlers_clarification.go`
|
||||
- `apps/backend/internal/orchestrator/clarification_guard.go`
|
||||
- `apps/backend/internal/clarification/types.go`
|
||||
- `apps/backend/internal/clarification/store.go`
|
||||
- `apps/backend/internal/clarification/canceller.go`
|
||||
|
||||
Register and validate the structured ask-parent tool. Persist a hidden typed message
|
||||
with correlation and lifecycle metadata before sending an attributed peer prompt to
|
||||
the resolved parent. Extend `message_task_kandev` with
|
||||
`reply_to_question_id`; authorize the recorded parent and atomically resolve and
|
||||
resume the child. Use the per-session serialization boundary for answer,
|
||||
superseding prompt, terminal transition, workflow completion, and queue-drain races.
|
||||
|
||||
Project a pending parent question to the existing clarification pending-action
|
||||
category while suppressing the operator clarification overlay. Extend status-summary
|
||||
rebuild and restart recovery. Test duplicate asks/replies, unavailable or reparented
|
||||
parents, full queues, crash boundaries, stale answers, and the rule that no second
|
||||
child turn or parent prompt is created.
|
||||
|
||||
## Frontend
|
||||
|
||||
Likely files:
|
||||
|
||||
- `apps/web/lib/types/http.ts`
|
||||
- `apps/web/lib/api/domains/kanban-api.ts`
|
||||
- `apps/web/lib/kanban/map-task.ts`
|
||||
- `apps/web/components/task-create-dialog-types.ts`
|
||||
- `apps/web/components/task-create-dialog-state.ts`
|
||||
- `apps/web/components/task-create-dialog-form-body.tsx`
|
||||
- `apps/web/components/task-create-dialog-prop-builders.ts`
|
||||
- `apps/web/components/task-create-dialog-submit.tsx`
|
||||
- `apps/web/components/task/new-subtask-dialog.tsx`
|
||||
- `apps/web/components/task/new-subtask-form-state.ts`
|
||||
- `apps/web/components/task/new-subtask-form-parts.tsx`
|
||||
- `apps/web/components/task/use-subtask-submit.ts`
|
||||
- `apps/web/components/task/task-session-sidebar-item.ts`
|
||||
- `apps/web/components/task/task-switcher-types.ts`
|
||||
- `apps/web/components/task/task-item.tsx`
|
||||
- `apps/web/components/task/chat/chat-input-area.tsx`
|
||||
- `apps/web/src/locales/en/task.json`
|
||||
- `apps/web/src/locales/pt-pt/task.json`
|
||||
- `apps/web/src/locales/pseudo/task.json`
|
||||
- `apps/web/src/locales/zh-cn/task.json`
|
||||
|
||||
Add `autopilot` to the shared task type and mapping. Keep top-level task creation
|
||||
UI free of an Autopilot control for now; expose an off-by-default compact switch
|
||||
only in the subtask creation dialog and include it in the creation request. Give
|
||||
the switch a localized hover/focus help control. In the shared chat status row,
|
||||
render a yellow localized badge for autopilot tasks. In the shared task item, keep
|
||||
the existing primary status icon (including the question indicator) and add a
|
||||
secondary autopilot icon with localized hover/focus tooltip and accessible name.
|
||||
|
||||
All new copy goes through `t()`. The pseudo-locale and i18n checks must cover the
|
||||
chip, subtask switch label/help, and tooltip. Existing tasks whose payload omits the
|
||||
field map to false during rolling compatibility.
|
||||
|
||||
## Mobile design contract
|
||||
|
||||
- **Desktop outcome:** creation dialog switch, status-row chip, and sidebar identity
|
||||
icon; a pending parent question uses the current primary question icon.
|
||||
- **Mobile entry point:** the existing responsive task creation dialog and the task
|
||||
switcher sheet; no new route or desktop-only hover action.
|
||||
- **Nearest exemplars:** `task-create-dialog-form-body.tsx` and
|
||||
`new-subtask-form-parts.tsx` for create-only fields, and the existing shared
|
||||
`task-item.tsx` status/question rendering used by the mobile task switcher.
|
||||
- **Presentation:** keep the switch inline because it is one reversible creation
|
||||
choice; do not add a nested drawer. The informational sidebar icon has no action,
|
||||
so touch users receive its accessible/visible identity without a tooltip-only
|
||||
dependency.
|
||||
- **Hierarchy and scrolling:** the primary task-state icon keeps precedence;
|
||||
autopilot is a secondary identity mark. The composer chip participates in the
|
||||
existing wrapping status row, and neither the dialog nor switcher introduces a
|
||||
horizontal scroll container.
|
||||
- **Touch target:** the switch row remains at least 44 px high and the whole labeled
|
||||
row toggles the control. Disabled/incompatible profiles explain why before submit.
|
||||
- **Shared state:** desktop and mobile read the same mapped task boolean and pending
|
||||
action; no viewport-specific autopilot store exists.
|
||||
|
||||
## Tests
|
||||
|
||||
- Repository/model tests cover migration defaults, round trips, and immutability.
|
||||
- HTTP and MCP tests cover omitted/false/true creation, nested task creation,
|
||||
incompatible profiles, the exact short autopilot description, and schema/handler
|
||||
synchronization.
|
||||
- System-prompt and MCP inventory tests prove normal and autopilot sessions expose
|
||||
the correct mutually exclusive question capability on launch and resume, including
|
||||
no question tool for an autopilot root.
|
||||
- Profile registry tests prove the Kanban, Office, configuration, and external
|
||||
surfaces, additive title/provider groups, atomic replacement, and one
|
||||
`tools/list_changed` notification per effective profile change.
|
||||
- Parent-question service/orchestrator tests cover direct-parent routing, turn-end
|
||||
gating, answer correlation, idempotency, races, stale/superseded state, and
|
||||
restart reconstruction.
|
||||
- Frontend tests cover request serialization, DTO mapping, create-only switch
|
||||
visibility, badge styling/copy, both sidebar icons, tooltip/focus semantics, and
|
||||
missing-field compatibility.
|
||||
|
||||
## E2E
|
||||
|
||||
Add a deterministic mock-agent scenario that creates an autopilot child, invokes
|
||||
the parent-question tool, ends its turn, receives a correlated parent answer, and
|
||||
resumes once. A desktop Playwright spec verifies creation and the full lifecycle. A
|
||||
mobile spec verifies the creation control, chat chip, autopilot identity icon,
|
||||
pending question icon, answer clearing, and no horizontal overflow. Include a
|
||||
backend restart while pending if the existing fixture can restart without weakening
|
||||
isolation; otherwise keep restart proof in Go integration tests.
|
||||
|
||||
## Public documentation
|
||||
|
||||
Update:
|
||||
|
||||
- `docs/public/automation-and-mcp.md`
|
||||
- `docs/public/agent-communication.md`
|
||||
- `docs/public/coordination.md`
|
||||
|
||||
Document the creation parameter, immutable first-release semantics, profile
|
||||
surfaces, context-specific capability groups, ask-parent payload, correlated reply,
|
||||
direct-parent ownership, top-level behavior, and visible waiting state. Examples
|
||||
must not imply that an autopilot child can call the operator clarification tool or
|
||||
that an Office task can create Kanban tasks through MCP.
|
||||
|
||||
## Waves
|
||||
|
||||
Wave 1:
|
||||
|
||||
- [x] [task-01-persist-task-contract](task-01-persist-task-contract.md)
|
||||
|
||||
Wave 2:
|
||||
|
||||
- [x] [task-02-derive-runtime-contract](task-02-derive-runtime-contract.md)
|
||||
- [x] [task-04-build-autopilot-ui](task-04-build-autopilot-ui.md)
|
||||
|
||||
Wave 3:
|
||||
|
||||
- [x] [task-03-build-parent-question-lifecycle](task-03-build-parent-question-lifecycle.md)
|
||||
- [x] [task-06-document-autopilot](task-06-document-autopilot.md)
|
||||
|
||||
Wave 4:
|
||||
|
||||
- [x] [task-05-prove-autopilot-e2e](task-05-prove-autopilot-e2e.md)
|
||||
|
||||
## Verification
|
||||
|
||||
Targeted backend:
|
||||
|
||||
```bash
|
||||
(cd apps/backend && go test ./internal/task/... ./internal/mcp/server/... ./internal/mcp/handlers/... ./internal/sysprompt/... ./internal/orchestrator/... ./internal/clarification/...)
|
||||
```
|
||||
|
||||
Targeted frontend:
|
||||
|
||||
```bash
|
||||
(cd apps && pnpm install --frozen-lockfile)
|
||||
(cd apps && pnpm --filter @kandev/web test -- --run components/task-create-dialog-defaults.test.ts components/task-create-dialog-form-body.test.tsx components/task/new-subtask-form-parts.test.tsx components/task/new-subtask-form-state.test.ts components/task/use-subtask-submit.test.ts components/task/task-item.test.tsx components/task/chat/chat-input-area.test.tsx lib/kanban/map-task.test.ts)
|
||||
(cd apps/web && pnpm run typecheck)
|
||||
(cd apps/web && pnpm run lint)
|
||||
(cd apps/web && pnpm run i18n:check)
|
||||
(cd apps/web && pnpm run i18n:ratchet)
|
||||
```
|
||||
|
||||
E2E:
|
||||
|
||||
```bash
|
||||
cd apps/web && pnpm e2e:run --project chromium tests/task/autopilot-mode.spec.ts
|
||||
cd apps/web && pnpm e2e:run --project mobile-chrome tests/task/mobile-autopilot-mode.spec.ts
|
||||
```
|
||||
|
||||
Public docs:
|
||||
|
||||
```bash
|
||||
node --test scripts/validate-public-docs.test.mjs
|
||||
node scripts/validate-public-docs.mjs
|
||||
```
|
||||
|
||||
## Verification results
|
||||
|
||||
Implemented. Verification passed: 2,263 Go tests across 9 focused packages; 156
|
||||
focused web tests; web typecheck and lint; i18n checks/ratchet; public docs
|
||||
validation (58 tests, 41 pages); and desktop/mobile Playwright autopilot scenarios.
|
||||
The fixup adds profile-capability selection tests, parent-question ownership and
|
||||
claim/restore coverage, omitted-field preservation tests, and the autopilot hook
|
||||
fallback test.
|
||||
|
||||
## Risks
|
||||
|
||||
- Tool discovery and prompt composition travel through several launch transports;
|
||||
missing one executor path would create a split contract after resume.
|
||||
- Parent questions compose with clarification cancellation, queue admission, and
|
||||
workflow turn completion. The pending gate must share existing per-session
|
||||
serialization rather than introducing a parallel lock.
|
||||
- Durable delivery and answer idempotency need stable identities; retrying after a
|
||||
crash must never generate a second parent request or child answer turn.
|
||||
- Reparenting while a question is pending must fail closed. The implementation must
|
||||
either keep the recorded parent authoritative for that question or mark it stale
|
||||
before accepting a new parent; it must never silently accept both.
|
||||
@@ -0,0 +1,72 @@
|
||||
---
|
||||
id: "01-persist-task-contract"
|
||||
title: "Persist the autopilot task contract"
|
||||
status: done
|
||||
wave: 1
|
||||
depends_on: []
|
||||
plan: "plan.md"
|
||||
spec: "../../specs/tasks/autopilot-mode.md"
|
||||
---
|
||||
|
||||
# Task 01: Persist the Autopilot Task Contract
|
||||
|
||||
## Acceptance
|
||||
|
||||
- Existing and newly created tasks round-trip a non-null `autopilot` boolean, with
|
||||
omission and migrated rows resolving to false.
|
||||
- HTTP and `create_task_kandev` creation accept the same optional field, do not
|
||||
inherit it from a parent, and reject incompatible agent runtime profiles before
|
||||
persistence.
|
||||
- The MCP schema uses the exact short description: "Start this task in autopilot
|
||||
mode. Default: false. The value is fixed at creation and is not inherited by
|
||||
subtasks. The agent does not ask the user directly; it asks its direct parent only
|
||||
for critical decisions." At runtime, a root autopilot task has no question
|
||||
capability, while an autopilot child has only the direct-parent question tool.
|
||||
- Update/edit APIs cannot mutate the property, and task read/list/boot payloads
|
||||
expose it consistently to clients.
|
||||
|
||||
## Verification
|
||||
|
||||
```bash
|
||||
cd apps/backend && go test ./internal/task/models ./internal/task/dto ./internal/task/repository/sqlite ./internal/task/handlers ./internal/mcp/server ./internal/mcp/handlers
|
||||
```
|
||||
|
||||
## Files likely touched
|
||||
|
||||
- `apps/backend/internal/task/models/models.go`
|
||||
- `apps/backend/internal/task/dto/dto.go`
|
||||
- `apps/backend/internal/task/dto/requests.go`
|
||||
- `apps/backend/internal/task/repository/sqlite/base_schema.go`
|
||||
- `apps/backend/internal/task/repository/sqlite/base_migrations.go`
|
||||
- `apps/backend/internal/task/repository/sqlite/task.go`
|
||||
- `apps/backend/internal/task/handlers/task_http_handlers.go`
|
||||
- `apps/backend/internal/mcp/server/server.go`
|
||||
- `apps/backend/internal/mcp/handlers/handlers.go`
|
||||
- Related model, repository, handler, and tool-schema tests
|
||||
|
||||
## Dependencies
|
||||
|
||||
None.
|
||||
|
||||
## Parallelism
|
||||
|
||||
This establishes the shared persisted/API contract. Runtime and UI work start only
|
||||
after its field name, default, and compatibility behavior are fixed.
|
||||
|
||||
## Inputs
|
||||
|
||||
- Spec sections `Creation API`, `Persistence and restart`, and `Permissions and boundaries`.
|
||||
- Existing task schema migrations, `TaskDTO` conversion, HTTP create handler, and
|
||||
MCP `registerCreateTaskTool`/`handleCreateTask` paths.
|
||||
|
||||
## Output contract
|
||||
|
||||
Report the migration number and SQL, Go/JSON field names, compatibility default,
|
||||
profile-validation boundary, exact creation/read paths changed, tests run, and any
|
||||
runtime profile type that remains unsupported.
|
||||
|
||||
## Results
|
||||
|
||||
Done. Added the immutable SQLite-backed field with migration/default, HTTP and MCP
|
||||
create propagation, DTO/WS/boot read paths, exact MCP parameter text, and tests for
|
||||
round trips, omitted values, nested creation, and update immutability.
|
||||
@@ -0,0 +1,87 @@
|
||||
---
|
||||
id: "02-derive-runtime-contract"
|
||||
title: "Derive the autopilot runtime contract"
|
||||
status: done
|
||||
wave: 2
|
||||
depends_on:
|
||||
- "01-persist-task-contract"
|
||||
plan: "plan.md"
|
||||
spec: "../../specs/tasks/autopilot-mode.md"
|
||||
---
|
||||
|
||||
# Task 02: Derive the Autopilot Runtime Contract
|
||||
|
||||
## Acceptance
|
||||
|
||||
- Every task launch/resume transport carries the persisted autopilot value into
|
||||
system-prompt construction and agentctl task MCP configuration.
|
||||
- Autopilot sessions receive the autonomy/last-action guidance and discover
|
||||
`ask_parent_question_kandev` only when a direct parent exists; autopilot root
|
||||
sessions receive no question tool; normal task sessions keep only
|
||||
`ask_user_question_kandev`.
|
||||
- No session receives both question tools, and the remaining task/provider tools
|
||||
follow the existing mode allowlists.
|
||||
- The profile registry composes base surfaces (`kanban-task`, `office-task`,
|
||||
`configuration`, `external`) with additive title, question, and provider groups.
|
||||
It replaces duplicated mode branches and manual tool counts.
|
||||
- Top-level, nested, restart, and unsupported-mode behavior is deterministic and
|
||||
covered by prompt/tool inventory tests.
|
||||
|
||||
## Verification
|
||||
|
||||
```bash
|
||||
cd apps/backend && go test ./internal/sysprompt ./internal/mcp/server ./internal/agent/runtime/lifecycle/... ./internal/agentctl/server/... ./internal/orchestrator/...
|
||||
```
|
||||
|
||||
## Files likely touched
|
||||
|
||||
- `apps/backend/config/prompts/kandev-context.md`
|
||||
- `apps/backend/internal/sysprompt/sysprompt.go`
|
||||
- `apps/backend/internal/sysprompt/sysprompt_test.go`
|
||||
- `apps/backend/internal/orchestrator/task_operations.go`
|
||||
- `apps/backend/internal/orchestrator/event_handlers_workflow.go`
|
||||
- `apps/backend/internal/task/handlers/message_handlers.go`
|
||||
- `apps/backend/internal/agent/runtime/agentctl/control.go`
|
||||
- `apps/backend/internal/agent/runtime/lifecycle/container.go`
|
||||
- `apps/backend/internal/agent/runtime/lifecycle/executor_docker.go`
|
||||
- `apps/backend/internal/agent/runtime/lifecycle/executor_standalone.go`
|
||||
- `apps/backend/internal/agent/runtime/lifecycle/manager_launch.go`
|
||||
- `apps/backend/internal/agentctl/server/config/config.go`
|
||||
- `apps/backend/internal/agentctl/server/instance/instance.go`
|
||||
- `apps/backend/internal/agentctl/server/instance/manager.go`
|
||||
- `apps/backend/internal/agentctl/server/api/server.go`
|
||||
- `apps/backend/internal/mcp/server/server.go`
|
||||
- `apps/backend/internal/mcp/server/tool_profiles.go`
|
||||
- `apps/backend/internal/mcp/server/tool_profiles_test.go`
|
||||
- `apps/backend/internal/agent/runtime/lifecycle/executor_docker_test.go`
|
||||
- `apps/backend/internal/agentctl/server/session_config_test.go`
|
||||
- `apps/backend/internal/mcp/server/server_test.go`
|
||||
|
||||
## Dependencies
|
||||
|
||||
- Task 01 provides the persisted property and compatible-profile validation.
|
||||
|
||||
## Parallelism
|
||||
|
||||
Can run in parallel with Task 04 after Task 01. It owns backend launch, prompt, and
|
||||
tool-inventory transport; Task 04 owns frontend files.
|
||||
|
||||
## Inputs
|
||||
|
||||
- Spec sections `Autonomous behavior`, `Parent question protocol`, and `Permissions and boundaries`.
|
||||
- ADR `2026-08-03-provider-scoped-task-mcp-tools.md` for backend-owned capability transport.
|
||||
- Existing `KandevContextOptions`, task launch wrapping, lifecycle configuration,
|
||||
`disableAskQuestion` behavior, and task parent lookup.
|
||||
|
||||
## Output contract
|
||||
|
||||
Report the launch configuration shape, each transport updated, exact prompt text
|
||||
source, MCP registration predicate, tool-list behavior across resume, tests run,
|
||||
and any client that cannot receive a changed inventory.
|
||||
|
||||
## Results
|
||||
|
||||
Done. Added typed backend-owned MCP surfaces and additive capability groups, carried
|
||||
the resolved profile through launch/resume/interaction transports, and derived the
|
||||
autopilot prompt plus mutually exclusive question tools for normal, child, and root
|
||||
tasks. Focused prompt, profile, server, and orchestrator tests pass.
|
||||
@@ -0,0 +1,82 @@
|
||||
---
|
||||
id: "03-build-parent-question-lifecycle"
|
||||
title: "Build the parent question lifecycle"
|
||||
status: done
|
||||
wave: 3
|
||||
depends_on:
|
||||
- "01-persist-task-contract"
|
||||
- "02-derive-runtime-contract"
|
||||
plan: "plan.md"
|
||||
spec: "../../specs/tasks/autopilot-mode.md"
|
||||
---
|
||||
|
||||
# Task 03: Build the Parent Question Lifecycle
|
||||
|
||||
## Acceptance
|
||||
|
||||
- `ask_parent_question_kandev` validates and durably records one structured pending
|
||||
request, routes it to the resolved direct parent, returns immediately, and never
|
||||
creates an operator clarification.
|
||||
- A correlated direct-parent reply resolves and resumes the recorded child exactly
|
||||
once; duplicate, unauthorized, mismatched, superseded, and stale replies have no
|
||||
delivery side effect.
|
||||
- Pending questions gate turn completion/queue draining, project to the existing
|
||||
sidebar clarification state, survive restart, and clear on every specified exit.
|
||||
|
||||
## Verification
|
||||
|
||||
```bash
|
||||
cd apps/backend && go test ./internal/mcp/server ./internal/mcp/handlers ./internal/task/repository/sqlite ./internal/task/statussummary ./internal/task/handlers ./internal/orchestrator/... ./internal/clarification/...
|
||||
```
|
||||
|
||||
## Files likely touched
|
||||
|
||||
- `apps/backend/internal/mcp/server/server.go`
|
||||
- `apps/backend/internal/mcp/server/handlers.go`
|
||||
- `apps/backend/internal/mcp/handlers/handlers.go`
|
||||
- `apps/backend/internal/task/models/models.go`
|
||||
- `apps/backend/internal/task/repository/sqlite/message.go`
|
||||
- `apps/backend/internal/task/statussummary/model.go`
|
||||
- `apps/backend/internal/task/statussummary/projector.go`
|
||||
- `apps/backend/internal/task/statussummary/rebuild.go`
|
||||
- `apps/backend/internal/task/handlers/message_handlers.go`
|
||||
- `apps/backend/internal/orchestrator/event_handlers_clarification.go`
|
||||
- `apps/backend/internal/orchestrator/clarification_guard.go`
|
||||
- `apps/backend/internal/clarification/types.go`
|
||||
- `apps/backend/internal/clarification/store.go`
|
||||
- `apps/backend/internal/clarification/canceller.go`
|
||||
- `apps/backend/internal/mcp/handlers/message_task_test.go`
|
||||
- `apps/backend/internal/task/statussummary/projector_test.go`
|
||||
- `apps/backend/internal/task/statussummary/rebuild_test.go`
|
||||
- `apps/backend/internal/orchestrator/event_handlers_clarification_test.go`
|
||||
|
||||
## Dependencies
|
||||
|
||||
- Task 01 supplies task identity and persistence.
|
||||
- Task 02 supplies the discoverable tool and autopilot prompt contract.
|
||||
|
||||
## Parallelism
|
||||
|
||||
Backend lifecycle work is serialized after Task 02 because it implements the tool
|
||||
whose inventory Task 02 defines. Documentation may proceed in parallel once the
|
||||
public payload names are fixed.
|
||||
|
||||
## Inputs
|
||||
|
||||
- Spec sections `Parent question protocol`, `State model`, `Persistence and restart`, and `Failure behavior`.
|
||||
- Existing `message_task_kandev` queue/interrupt service, clarification pending
|
||||
actions, status-summary rebuild, prompt-generation guard, and turn-completion flow.
|
||||
|
||||
## Output contract
|
||||
|
||||
Report the hidden message type and metadata schema, question/reply API payloads,
|
||||
transaction and serialization boundaries, state transitions, restart behavior,
|
||||
idempotency key, exact error codes, tests run, and results for answer/supersede/
|
||||
terminal races.
|
||||
|
||||
## Results
|
||||
|
||||
Done. Added durable parent-question messages, direct-parent authorization,
|
||||
`reply_to_question_id` correlation, idempotent answer handling, child waiting and
|
||||
resume behavior, task pending-action projection, and the parent-question MCP profile
|
||||
registration. Handler/server/orchestrator tests cover the lifecycle and event order.
|
||||
@@ -0,0 +1,94 @@
|
||||
---
|
||||
id: "04-build-autopilot-ui"
|
||||
title: "Build the autopilot task UI"
|
||||
status: done
|
||||
wave: 2
|
||||
depends_on:
|
||||
- "01-persist-task-contract"
|
||||
plan: "plan.md"
|
||||
spec: "../../specs/tasks/autopilot-mode.md"
|
||||
---
|
||||
|
||||
# Task 04: Build the Autopilot Task UI
|
||||
|
||||
## Acceptance
|
||||
|
||||
- Task and subtask creation modes offer an off-by-default, accessible autopilot
|
||||
switch and serialize it; edit and new-session modes do not imply mutability.
|
||||
- Autopilot tasks render a yellow localized chip above the composer and a secondary
|
||||
localized sidebar icon while preserving the primary pending-question icon.
|
||||
- Shared desktop/mobile components consume one mapped task property, remain usable
|
||||
at narrow viewports, and pass unit, type, i18n, and accessibility checks.
|
||||
|
||||
## Verification
|
||||
|
||||
```bash
|
||||
(cd apps && pnpm install --frozen-lockfile)
|
||||
(cd apps && pnpm --filter @kandev/web test -- --run components/task-create-dialog-defaults.test.ts components/task-create-dialog-form-body.test.tsx components/task/new-subtask-form-parts.test.tsx components/task/new-subtask-form-state.test.ts components/task/use-subtask-submit.test.ts components/task/task-item.test.tsx components/task/chat/chat-input-area.test.tsx lib/kanban/map-task.test.ts)
|
||||
(cd apps/web && pnpm run typecheck)
|
||||
(cd apps/web && pnpm run lint)
|
||||
(cd apps/web && pnpm run i18n:check)
|
||||
(cd apps/web && pnpm run i18n:ratchet)
|
||||
```
|
||||
|
||||
## Files likely touched
|
||||
|
||||
- `apps/web/lib/types/http.ts`
|
||||
- `apps/web/lib/api/domains/kanban-api.ts`
|
||||
- `apps/web/lib/kanban/map-task.ts`
|
||||
- `apps/web/components/task-create-dialog-types.ts`
|
||||
- `apps/web/components/task-create-dialog-state.ts`
|
||||
- `apps/web/components/task-create-dialog-defaults.ts`
|
||||
- `apps/web/components/task-create-dialog-form-body.tsx`
|
||||
- `apps/web/components/task-create-dialog-prop-builders.ts`
|
||||
- `apps/web/components/task-create-dialog-submit.tsx`
|
||||
- `apps/web/components/task/new-subtask-dialog.tsx`
|
||||
- `apps/web/components/task/new-subtask-form-state.ts`
|
||||
- `apps/web/components/task/new-subtask-form-parts.tsx`
|
||||
- `apps/web/components/task/use-subtask-submit.ts`
|
||||
- `apps/web/components/task/task-session-sidebar-item.ts`
|
||||
- `apps/web/components/task/task-switcher-types.ts`
|
||||
- `apps/web/components/task/task-item.tsx`
|
||||
- `apps/web/components/task/chat/chat-input-area.tsx`
|
||||
- `apps/web/src/locales/en/task.json`
|
||||
- `apps/web/src/locales/pt-pt/task.json`
|
||||
- `apps/web/src/locales/pseudo/task.json`
|
||||
- `apps/web/src/locales/zh-cn/task.json`
|
||||
- `apps/web/components/task-create-dialog-defaults.test.ts`
|
||||
- `apps/web/components/task-create-dialog-form-body.test.tsx`
|
||||
- `apps/web/components/task/new-subtask-form-parts.test.tsx`
|
||||
- `apps/web/components/task/new-subtask-form-state.test.ts`
|
||||
- `apps/web/components/task/use-subtask-submit.test.ts`
|
||||
- `apps/web/components/task/task-item.test.tsx`
|
||||
- `apps/web/components/task/chat/chat-input-area.test.tsx`
|
||||
- `apps/web/lib/kanban/map-task.test.ts`
|
||||
|
||||
## Dependencies
|
||||
|
||||
- Task 01 supplies the HTTP/DTO field and compatibility behavior.
|
||||
|
||||
## Parallelism
|
||||
|
||||
Can run in parallel with Task 02. This task owns frontend API, dialog, task-row,
|
||||
composer, and locale files; Task 02 owns backend runtime files.
|
||||
|
||||
## Inputs
|
||||
|
||||
- Spec sections `User experience`, `Creation API`, and the mobile acceptance scenario.
|
||||
- Plan `Mobile design contract`.
|
||||
- Existing create dialog boolean rows, `ChatStatusBar`, `TaskItem`, and
|
||||
`taskPendingAction` mapping.
|
||||
|
||||
## Output contract
|
||||
|
||||
Report the frontend field/default, create-mode visibility rules, component and
|
||||
translation keys, icon precedence, keyboard/touch behavior, narrow-width overflow
|
||||
result, tests/checks run, and screenshots or DOM evidence used for accessibility.
|
||||
|
||||
## Results
|
||||
|
||||
Done. Added create-only switches for tasks and subtasks, shared task mapping,
|
||||
localized yellow sidebar/chat indicators, pending-question precedence, and mobile
|
||||
sheet propagation. Focused tests, typecheck, lint, i18n checks, and narrow viewport
|
||||
overflow assertions pass. The fixup also covers stale direct-task fallback and
|
||||
primary-session-clear WebSocket preservation.
|
||||
@@ -0,0 +1,77 @@
|
||||
---
|
||||
id: "05-prove-autopilot-e2e"
|
||||
title: "Prove the autopilot lifecycle end to end"
|
||||
status: done
|
||||
wave: 4
|
||||
depends_on:
|
||||
- "03-build-parent-question-lifecycle"
|
||||
- "04-build-autopilot-ui"
|
||||
plan: "plan.md"
|
||||
spec: "../../specs/tasks/autopilot-mode.md"
|
||||
---
|
||||
|
||||
# Task 05: Prove the Autopilot Lifecycle End to End
|
||||
|
||||
## Acceptance
|
||||
|
||||
- A deterministic test creates an autopilot child, observes its prompt/tool
|
||||
contract, opens one parent question, waits visibly, accepts one correlated parent
|
||||
reply, and resumes the child exactly once.
|
||||
- Desktop and mobile Playwright coverage verifies the create switch, yellow chip,
|
||||
secondary autopilot icon, primary question indicator, cleared wait state, and
|
||||
absence of horizontal overflow.
|
||||
- Restart or integration coverage proves a pending question reconstructs without
|
||||
duplicating the parent prompt, and normal task clarification remains unchanged.
|
||||
|
||||
## Verification
|
||||
|
||||
```bash
|
||||
(cd apps && pnpm install --frozen-lockfile)
|
||||
(cd apps/web && pnpm e2e:run --project chromium tests/task/autopilot-mode.spec.ts)
|
||||
(cd apps/web && pnpm e2e:run --project mobile-chrome tests/task/mobile-autopilot-mode.spec.ts)
|
||||
(cd apps/backend && go test ./internal/integration/... ./internal/mcp/handlers/... ./internal/task/statussummary/...)
|
||||
```
|
||||
|
||||
## Files likely touched
|
||||
|
||||
- `apps/backend/cmd/mock-agent/scenarios.go`
|
||||
- `apps/backend/cmd/mock-agent/script.go`
|
||||
- `apps/backend/cmd/mock-agent/mock_agent_test.go`
|
||||
- `apps/backend/internal/integration/mcp_integration_test.go`
|
||||
- `apps/web/e2e/tests/task/autopilot-mode.spec.ts`
|
||||
- `apps/web/e2e/tests/task/mobile-autopilot-mode.spec.ts`
|
||||
- `apps/web/e2e/fixtures/backend.ts`
|
||||
|
||||
## Dependencies
|
||||
|
||||
- Task 03 completes the backend lifecycle.
|
||||
- Task 04 completes the shared desktop/mobile UI.
|
||||
|
||||
## Parallelism
|
||||
|
||||
Runs after all behavior and UI tasks. Keep E2E fixture changes scoped to deterministic
|
||||
test controls; do not duplicate product state machines in the mock agent.
|
||||
|
||||
## Inputs
|
||||
|
||||
- All spec acceptance scenarios.
|
||||
- Existing task creation, MCP integration, mobile sidebar, and task-status E2E
|
||||
exemplars.
|
||||
- The repository E2E README and containers-project boundary.
|
||||
|
||||
## Output contract
|
||||
|
||||
Report each scenario and project run, mock directive/API added, task/session states
|
||||
observed, parent and child message counts, restart evidence, mobile viewport and
|
||||
overflow measurement, exact commands/results, and any scenario left to a lower test
|
||||
layer with justification.
|
||||
|
||||
## Results
|
||||
|
||||
Done. The mock agent invokes the real parent-question tool, waits for the parent
|
||||
answer, and replies through the real correlated message path. Chromium and mobile
|
||||
Playwright scenarios pass, including creation controls, prompt waiting, identity and
|
||||
question icons, chat chip, answer/resume, and horizontal-overflow checks. Backend
|
||||
message/repository tests cover durable question reconstruction and idempotent
|
||||
answer state. A full process-restart Playwright scenario was not run; that remains
|
||||
an explicit follow-up for the fixture rather than an unverified claim.
|
||||
@@ -0,0 +1,69 @@
|
||||
---
|
||||
id: "06-document-autopilot"
|
||||
title: "Document the autopilot public contract"
|
||||
status: done
|
||||
wave: 3
|
||||
depends_on:
|
||||
- "01-persist-task-contract"
|
||||
- "02-derive-runtime-contract"
|
||||
plan: "plan.md"
|
||||
spec: "../../specs/tasks/autopilot-mode.md"
|
||||
---
|
||||
|
||||
# Task 06: Document the Autopilot Public Contract
|
||||
|
||||
## Acceptance
|
||||
|
||||
- Public automation and coordination docs describe `autopilot` creation, its false
|
||||
default and immutability, compatible session boundary, and visible UI state.
|
||||
- Public MCP guidance describes the `kanban-task`, `office-task`, `configuration`,
|
||||
and `external` surfaces, and explains that context-specific capability groups
|
||||
control optional tools.
|
||||
- Agent communication docs give accurate ask-parent and correlated-reply payloads,
|
||||
direct-parent authorization, immediate turn ending, top-level behavior, and stale
|
||||
answer semantics. It states that an autopilot root receives no question tool.
|
||||
- Examples never advertise the operator clarification tool to autopilot tasks or
|
||||
task creation through the Office surface, and all public-doc validation passes.
|
||||
|
||||
## Verification
|
||||
|
||||
```bash
|
||||
node --test scripts/validate-public-docs.test.mjs
|
||||
node scripts/validate-public-docs.mjs
|
||||
rtk rg -n "autopilot|ask_parent_question_kandev|reply_to_question_id" docs/public docs/specs docs/decisions
|
||||
```
|
||||
|
||||
## Files likely touched
|
||||
|
||||
- `docs/public/automation-and-mcp.md`
|
||||
- `docs/public/agent-communication.md`
|
||||
- `docs/public/coordination.md`
|
||||
|
||||
## Dependencies
|
||||
|
||||
- Task 01 fixes the creation field and compatibility behavior.
|
||||
- Task 02 fixes the public tool names and runtime inventory.
|
||||
|
||||
## Parallelism
|
||||
|
||||
Can run alongside Task 03 after the payload names in the spec are treated as fixed.
|
||||
If implementation changes a public field or error, update the spec and this task
|
||||
before final validation.
|
||||
|
||||
## Inputs
|
||||
|
||||
- Spec sections `Creation API`, `Parent question protocol`, `State model`, and `Permissions and boundaries`.
|
||||
- Existing public MCP creation and parent/child communication documentation.
|
||||
|
||||
## Output contract
|
||||
|
||||
Report sections/examples changed, exact public request/response shapes documented,
|
||||
compatibility and scope callouts, validation commands/results, and any internal-only
|
||||
state intentionally omitted from public docs.
|
||||
|
||||
## Results
|
||||
|
||||
Done. Updated automation/MCP, agent communication, and coordination pages with the
|
||||
short creation parameter, profile/capability rules, parent-question and correlated
|
||||
reply payloads, direct-parent ownership, root behavior, and waiting semantics. Public
|
||||
docs validation passes (58 tests; 41 published pages).
|
||||
@@ -79,6 +79,44 @@ message_task_kandev(
|
||||
|
||||
There is no persistent channel or shared socket between tasks. Each `message_task_kandev` call is discrete. The conversation thread is implicit — both tasks can recover context by reading back the relevant messages (see [Reading the thread](#reading-the-thread) below).
|
||||
|
||||
## Autopilot parent questions
|
||||
|
||||
An autopilot child does not call `ask_user_question_kandev`. If it reaches a
|
||||
critical decision, it calls `ask_parent_question_kandev`:
|
||||
|
||||
```json
|
||||
{
|
||||
"questions": [
|
||||
{"id": "database", "prompt": "Which database should I use?", "options": ["SQLite", "Postgres"]}
|
||||
],
|
||||
"context": "The migration needs a database choice before implementation."
|
||||
}
|
||||
```
|
||||
|
||||
The tool creates a durable pending question for the direct parent and returns
|
||||
without waiting. The child must end its turn after the call. The question
|
||||
message contains a `question_id`, the child task ID, and the question data.
|
||||
Only that direct parent may answer it. A parent sends the answer to the child
|
||||
with `message_task_kandev`:
|
||||
|
||||
```json
|
||||
{
|
||||
"task_id": "<child task UUID>",
|
||||
"prompt": "Use Postgres. Keep the migration reversible.",
|
||||
"reply_to_question_id": "<question_id from the child message>"
|
||||
}
|
||||
```
|
||||
|
||||
The answer is correlated by `reply_to_question_id` and is idempotent. A repeat
|
||||
answer, an answer from another task, or an answer after reparenting is rejected
|
||||
or reported as already answered; it never starts a second child turn. The
|
||||
child leaves the waiting state only after the accepted correlated answer is
|
||||
delivered. The existing primary question icon shows this wait in the sidebar.
|
||||
|
||||
An autopilot root has no parent, so its task MCP profile contains no question
|
||||
tool. It must continue without asking the operator. A normal task keeps the
|
||||
operator-facing `ask_user_question_kandev` flow.
|
||||
|
||||
## Reading the thread
|
||||
|
||||
`get_task_conversation_kandev(task_id)` returns the message history for any task you know the ID of. Use it to:
|
||||
|
||||
@@ -165,6 +165,48 @@ Task tools use normal client discovery. When `step_complete_kandev` is required
|
||||
|
||||
`create_task_kandev` advertises `prompt` for instructions delivered to a newly started agent. Older callers may still send `description` when `prompt` is absent, but sending both is an error; the compatibility name is intentionally omitted from the advertised schema.
|
||||
|
||||
### Autopilot tasks and MCP profiles
|
||||
|
||||
Task creation accepts one optional boolean:
|
||||
|
||||
```go
|
||||
mcp.WithBoolean(
|
||||
"autopilot",
|
||||
mcp.Description(
|
||||
"Start this task in autopilot mode. Default: false. The value is fixed at creation and is not inherited by subtasks. The agent does not ask the user directly; it asks its direct parent only for critical decisions.",
|
||||
),
|
||||
),
|
||||
```
|
||||
|
||||
The value defaults to `false`. It is fixed when the task is created and is not
|
||||
copied to a subtask. The task record is the source of truth after creation; a
|
||||
later task update cannot switch the prompt or MCP tools between normal and
|
||||
autopilot behavior.
|
||||
|
||||
The top-level task dialog does not expose this option. The subtask dialog has a
|
||||
compact Autopilot switch with help text, but the value remains fixed after the
|
||||
subtask is created.
|
||||
|
||||
Kandev builds the task MCP server from a backend-owned profile. The base
|
||||
surfaces are `kanban-task`, `office-task`, `configuration`, and `external`.
|
||||
Optional capability groups, such as task titles, provider automation, user
|
||||
questions, and parent questions, are added or removed from that base profile.
|
||||
This keeps tool discovery small and makes a context change atomic.
|
||||
|
||||
For a Kanban task, normal sessions receive `ask_user_question_kandev`.
|
||||
An autopilot child receives `ask_parent_question_kandev` instead. An autopilot
|
||||
root receives neither question tool. Kandev never registers both question
|
||||
tools for one task session. Office sessions use their smaller skill/CLI
|
||||
surface and do not receive Kanban task-creation tools.
|
||||
|
||||
An autopilot child should ask its parent only when a decision blocks useful
|
||||
progress. `ask_parent_question_kandev` returns a `question_id` immediately;
|
||||
the child turn then ends. The parent receives a durable question message and
|
||||
answers with `message_task_kandev` using the child task ID and
|
||||
`reply_to_question_id`. The child stays in the waiting-for-input state until
|
||||
the correlated answer arrives, so the sidebar shows the normal question
|
||||
indicator during the wait.
|
||||
|
||||
### Create idempotency with `external_id`
|
||||
|
||||
A caller that cannot tell whether an earlier `create_task_kandev` call (or `POST /api/v1/tasks`) actually landed — a crash before recording the response, a webhook redelivery — can pass an `external_id` and retry safely instead of guessing. `external_id` is an opaque, caller-chosen string, case-sensitive and byte-exact, unique per workspace: two workspaces can each hold their own task for the same value, but a second create for a value already held in the same workspace never makes a second task there. It is validated and trimmed like other free-text fields; a value that is empty after trimming is treated as if the field were omitted.
|
||||
|
||||
@@ -83,6 +83,11 @@ Choose a workspace mode:
|
||||
|
||||
The context choices are **Blank**, **Copy initial prompt**, and, when a utility agent is configured, **Summarize session**. Context supplies background; it does not create a shared conversation. Attachments and prompt enhancement are also available.
|
||||
|
||||
The subtask dialog includes an optional **Autopilot** switch. Use the info control
|
||||
beside it for help: the child works independently and asks its parent only when a
|
||||
critical decision blocks progress. The top-level task dialog does not show this
|
||||
switch; use `create_task_kandev` when you need an autopilot root task.
|
||||
|
||||
The subtask dialog currently does not enforce agent/executor credential compatibility. For an isolated multi-repository subtask, choose **Worktree**, **Local Docker**, **SSH**, or **Sprites**; Local/Local PC creation remains gated and Remote Docker is not implemented. For every subtask, choose an agent profile configured on the inherited or selected executor; otherwise creation can succeed while agent launch or repository materialization fails.
|
||||
|
||||
Regular Kanban allows one subtask level: a root task can have children, but a child cannot have another child. Split further work into sibling subtasks, additional sessions, or a separate top-level task. Arbitrary-depth trees belong to the in-progress Office surface.
|
||||
@@ -98,6 +103,7 @@ Detaching changes task hierarchy only. An inherited workspace remains shared wit
|
||||
Call `create_task_kandev` with `parent_id: "self"`. `workspace_mode` defaults to `inherit_parent`; set it to `new_workspace` for isolated materialization.
|
||||
|
||||
- `start_agent` defaults to `true`. Supply a detailed `prompt` when it is true; if omitted, Kandev still starts the agent without task-specific instructions. Set it to `false` for a placeholder task.
|
||||
- `autopilot` defaults to `false`. Set it to `true` to start an autonomous task. This choice is immutable and is not inherited by subtasks. An autopilot child receives `ask_parent_question_kandev` instead of `ask_user_question_kandev`; an autopilot root receives neither question tool. See [Agent Communication](agent-communication.md#autopilot-parent-questions) for the answer protocol.
|
||||
- The tool inherits the parent workspace, workflow, profile, executor, repositories, and base branches unless overridden.
|
||||
- Inherited repository attachments deliberately do not copy an explicit checkout branch.
|
||||
- An explicit same-repository child uses the inherited base branch. An explicit cross-repository child defaults to that repository's default branch unless `base_branch` is supplied.
|
||||
|
||||
@@ -93,9 +93,10 @@
|
||||
"audiences": ["user"],
|
||||
"stability": "stable",
|
||||
"docs": ["sessions-and-review", "coordination", "automation-and-mcp", "agent-communication"],
|
||||
"sources": ["apps/backend/internal/mcp/handlers/spawn_session.go", "apps/web/components/task/dockview-session-tabs.ts"],
|
||||
"tests": ["apps/backend/internal/mcp/handlers/spawn_session_test.go", "apps/web/components/task/dockview-session-tabs.test.ts"],
|
||||
"sources": ["apps/backend/internal/mcp/handlers/spawn_session.go", "apps/backend/internal/mcp/handlers/parent_question.go", "apps/web/components/task/dockview-session-tabs.ts"],
|
||||
"tests": ["apps/backend/internal/mcp/handlers/spawn_session_test.go", "apps/backend/internal/mcp/handlers/parent_question_test.go", "apps/web/components/task/dockview-session-tabs.test.ts"],
|
||||
"mcpTools": [
|
||||
"ask_parent_question_kandev",
|
||||
"ask_user_question_kandev",
|
||||
"get_task_conversation_kandev",
|
||||
"get_task_document_kandev",
|
||||
|
||||
@@ -94,6 +94,7 @@ Kandev's task model: documents, execution stages, labels, blocker escalation, su
|
||||
| [external-id-idempotency](tasks/external-id-idempotency/spec.md) | draft |
|
||||
| [prompt-attachments](tasks/prompt-attachments.md) | draft |
|
||||
| [sidebar-task-edit](tasks/sidebar-task-edit.md) | approved |
|
||||
| [autopilot-mode](tasks/autopilot-mode.md) | draft |
|
||||
| [explicit-completion-signal](workflow/explicit-completion-signal/spec.md) | shipped |
|
||||
| [cancelled-turn-completion](workflow/cancelled-turn-completion/spec.md) | building |
|
||||
| [conditional-session-settings](workflow-session-settings/spec.md) | approved |
|
||||
|
||||
@@ -0,0 +1,313 @@
|
||||
---
|
||||
status: implemented
|
||||
created: 2026-08-08
|
||||
owner: cfl
|
||||
---
|
||||
|
||||
# Task Autopilot Mode
|
||||
|
||||
## Why
|
||||
|
||||
Delegated tasks should be able to make progress without repeatedly blocking on the
|
||||
operator. Today, a child agent can call the operator clarification tool and wait
|
||||
inside that call even when its parent agent owns the delegation and could answer.
|
||||
That creates avoidable timeouts, sends questions to the wrong owner, and gives no
|
||||
durable indication that a child is waiting on its parent.
|
||||
|
||||
Autopilot makes autonomy an explicit task contract. It is visible to the operator,
|
||||
changes the agent's instructions and available MCP tools, and gives an exceptional
|
||||
question a non-blocking, parent-owned lifecycle.
|
||||
|
||||
Decision: [ADR-2026-08-08-task-autopilot-contract](../../decisions/2026-08-08-task-autopilot-contract.md)
|
||||
MCP profile decision: [ADR-2026-08-08-mcp-tool-profiles](../../decisions/2026-08-08-mcp-tool-profiles.md)
|
||||
|
||||
## User experience
|
||||
|
||||
### Creation and identity
|
||||
|
||||
- Top-level task creation through the UI does not expose an **Autopilot** switch;
|
||||
set it through `create_task_kandev` for now.
|
||||
- The subtask creation dialog contains a compact **Autopilot** switch, off by
|
||||
default. Its info control explains that the child works independently and
|
||||
asks its parent only when a critical decision blocks progress.
|
||||
- The setting is immutable after creation. Edit-task and session-creation surfaces
|
||||
display no control that implies it can be changed.
|
||||
- An autopilot task shows a yellow **Autopilot** chip in the status row above its
|
||||
chat composer.
|
||||
- Its sidebar row shows a secondary autopilot icon. Pointer and keyboard users can
|
||||
reveal the localized description **Autopilot mode**; assistive technology gets
|
||||
the same label.
|
||||
- Desktop and mobile use the same task property and shared row/composer components.
|
||||
The mobile task switcher keeps the icon visible, and the chip wraps without
|
||||
causing horizontal page scrolling.
|
||||
|
||||
### Autonomous behavior
|
||||
|
||||
The first-turn Kandev context for an autopilot task says that the task is in
|
||||
autopilot mode and must:
|
||||
|
||||
- make safe, reversible assumptions and continue independently;
|
||||
- ask only when a decision is genuinely essential and a wrong assumption would
|
||||
materially change the requested outcome;
|
||||
- never ask the operator directly;
|
||||
- when a direct parent exists, call `ask_parent_question_kandev` only as the last
|
||||
action of the turn, then end the turn immediately;
|
||||
- when no parent exists, proceed with best judgment and disclose material
|
||||
assumptions in its eventual result.
|
||||
|
||||
Normal tasks retain their current prompt and operator clarification tool.
|
||||
|
||||
The MCP question capability is mutually exclusive:
|
||||
|
||||
| Task mode | Direct parent | Question tool |
|
||||
|---|---|---|
|
||||
| Normal | Any | `ask_user_question_kandev` |
|
||||
| Autopilot | Present | `ask_parent_question_kandev` |
|
||||
| Autopilot | Absent | None |
|
||||
|
||||
An autopilot task never receives both question tools. Other task-mode tools remain
|
||||
available when they are required by the task mode or configured provider.
|
||||
|
||||
## MCP profiles
|
||||
|
||||
Kandev builds the MCP tool list from a backend-owned profile context. The context
|
||||
has a base surface and additive capability groups. The agent cannot provide an
|
||||
arbitrary tool list.
|
||||
|
||||
The base surfaces are:
|
||||
|
||||
| Surface | Tool surface |
|
||||
|---|---|
|
||||
| `kanban-task` | Kanban task operations, planning, walkthrough, review, related tasks, workspace/branch actions, step completion, and diagnostics |
|
||||
| `office-task` | Interaction, planning, related tasks, and task documents; no Kanban task creation tools |
|
||||
| `configuration` | Workflow, agent, MCP, executor, and configuration-task tools |
|
||||
| `external` | Configuration tools plus `create_task_kandev`; no live-session tools |
|
||||
|
||||
The first additive groups are `user-question`, `parent-question`, `task-title`,
|
||||
GitHub PR automation, and GitLab MR automation. The backend adds these groups from
|
||||
session purpose, autopilot state, direct-parent presence, title ownership, and
|
||||
attached providers.
|
||||
|
||||
The profile is runtime state. It is rebuilt on launch and resume. A live profile
|
||||
replacement atomically rebuilds the MCP list and sends one `tools/list_changed`
|
||||
notification. The task's `autopilot` value remains the durable source for the
|
||||
autopilot choice.
|
||||
|
||||
## Creation API
|
||||
|
||||
Task creation requests gain an optional boolean `autopilot` field:
|
||||
|
||||
```json
|
||||
{
|
||||
"title": "Investigate flaky test",
|
||||
"parent_id": "<parent task id>",
|
||||
"autopilot": true
|
||||
}
|
||||
```
|
||||
|
||||
- Omitted is equivalent to `false`.
|
||||
- The value does not inherit from the parent.
|
||||
- The HTTP task-creation endpoint and `create_task_kandev` use the same validation
|
||||
and persistence path.
|
||||
- The MCP parameter description is: **"Start this task in autopilot mode. Default:
|
||||
false. The value is fixed at creation and is not inherited by subtasks. The agent
|
||||
does not ask the user directly; it asks its direct parent only for critical
|
||||
decisions."**
|
||||
- `autopilot: true` is rejected when the resolved agent profile cannot receive the
|
||||
Kandev task-mode MCP capability set. It is not silently downgraded.
|
||||
- Task read/list/boot payloads expose the persisted boolean so every frontend entry
|
||||
point renders the same state.
|
||||
|
||||
## Parent question protocol
|
||||
|
||||
### Request tool
|
||||
|
||||
Autopilot child sessions with a direct parent discover this tool instead of
|
||||
`ask_user_question_kandev`:
|
||||
|
||||
```json
|
||||
{
|
||||
"questions": [
|
||||
{
|
||||
"id": "database",
|
||||
"prompt": "Which database should I use?",
|
||||
"options": [
|
||||
{"label": "SQLite", "description": "Use the embedded database."},
|
||||
{"label": "Postgres", "description": "Use the hosted database."}
|
||||
]
|
||||
}
|
||||
],
|
||||
"context": "The migration needs a database choice before implementation."
|
||||
}
|
||||
```
|
||||
|
||||
`questions` contains one to four question objects. Each question has a required
|
||||
non-empty `prompt`; `id`, `title`, and `options` are optional. Sender task and
|
||||
session identity come from the authenticated MCP context; the caller cannot choose
|
||||
the parent or child session. `context` gives the parent the short reason for the
|
||||
request.
|
||||
|
||||
The backend resolves the task's current direct parent, persists the question, and
|
||||
queues an attributed, structured prompt to that parent. The call returns immediately:
|
||||
|
||||
```json
|
||||
{
|
||||
"question_id": "<id>",
|
||||
"parent_task_id": "<direct parent id>",
|
||||
"status": "waiting_for_parent"
|
||||
}
|
||||
```
|
||||
|
||||
Repeated creation attempts with the same tool-call identity return the same
|
||||
question and do not send duplicate parent prompts. A task without a direct parent
|
||||
does not receive this tool. A stale client call gets a no-parent error and creates
|
||||
no pending record.
|
||||
|
||||
The parent prompt includes the child task/session identity, exact question,
|
||||
reason, blocked effect, options, question ID, and the exact correlated reply shape.
|
||||
It must not reinterpret the request as an operator clarification automatically.
|
||||
|
||||
### Reply
|
||||
|
||||
`message_task_kandev` gains an optional `reply_to_question_id`:
|
||||
|
||||
```json
|
||||
{
|
||||
"task_id": "<child task id>",
|
||||
"prompt": "Preserve the column for this release.",
|
||||
"reply_to_question_id": "<question id>"
|
||||
}
|
||||
```
|
||||
|
||||
For a correlated reply, the backend verifies that:
|
||||
|
||||
- the question is still pending;
|
||||
- the target task and selected session match the recorded child;
|
||||
- the sender is the child's currently recorded direct parent; and
|
||||
- the reply has not already been accepted.
|
||||
|
||||
An accepted reply atomically resolves the question and starts or resumes the child
|
||||
with an attributed parent answer. Retrying the same accepted reply returns the
|
||||
resolved outcome without delivering a second prompt. A wrong parent, wrong child,
|
||||
unknown question, or stale question is rejected with no delivery side effect.
|
||||
Uncorrelated `message_task_kandev` behavior is unchanged.
|
||||
|
||||
## State model
|
||||
|
||||
Each parent question is a typed, hidden child-session message with stable metadata:
|
||||
|
||||
- `question_id`
|
||||
- child task and session IDs
|
||||
- parent task ID at request time
|
||||
- question, reason, blocked effect, and optional choices
|
||||
- originating prompt generation or tool-call identity
|
||||
- lifecycle status and resolution timestamps
|
||||
|
||||
Lifecycle states are:
|
||||
|
||||
| State | Meaning | Exit |
|
||||
|---|---|---|
|
||||
| `pending` | Parent prompt was durably queued or delivered; child is gated. | Answer, explicit superseding child input, or terminal state. |
|
||||
| `answered` | One correlated parent answer was accepted and delivered once. | Terminal. |
|
||||
| `superseded` | Explicit new operator/parent input replaced the wait without claiming to answer it. | Terminal. |
|
||||
| `stale` | The child or session became terminal, was archived/deleted, or the recorded relationship can no longer accept the answer. | Terminal. |
|
||||
|
||||
While the latest child turn has a `pending` parent question:
|
||||
|
||||
- the child session settles in `WAITING_FOR_INPUT` after its agent turn ends;
|
||||
- workflow `on_turn_complete` transitions do not run;
|
||||
- ordinary queued prompts do not drain ahead of the correlated decision;
|
||||
- the task's pending-action projection is `clarification`, so the existing sidebar
|
||||
question indicator is shown;
|
||||
- no operator clarification card or `ask_user_question_kandev` request is created.
|
||||
|
||||
An explicit new child prompt that is not a correlated answer supersedes the pending
|
||||
question before normal prompt admission. Archive, delete, cancellation, or another
|
||||
terminal session transition marks it stale. A late answer to a non-pending question
|
||||
cannot resume the child.
|
||||
|
||||
## Persistence and restart
|
||||
|
||||
- The task's autopilot boolean is stored in the task row with a default of false so
|
||||
existing databases and tasks remain non-autopilot.
|
||||
- Parent questions and their lifecycle metadata are committed before the parent
|
||||
prompt is dispatched.
|
||||
- Task list, boot-state, and status-summary rebuilding derive the question indicator
|
||||
from durable pending metadata after restart.
|
||||
- Restart recovery preserves a pending child gate and does not replay the parent
|
||||
prompt if its durable delivery/queue record already exists.
|
||||
- Answer resolution and child prompt admission are atomic from the protocol caller's
|
||||
perspective: a crash cannot make one answer create two child turns.
|
||||
|
||||
## Permissions and boundaries
|
||||
|
||||
- Only the authenticated task session may open its own parent question.
|
||||
- Only the recorded direct parent task may answer it.
|
||||
- Parent routing is one hop. An autopilot parent that cannot decide may open its own
|
||||
question to its parent, producing a separate correlation ID.
|
||||
- The feature applies to persistent task-mode sessions with Kandev MCP-capable agent
|
||||
profiles. Quick chat, Office-owned work, config/utility sessions, passthrough-only
|
||||
profiles, and non-task MCP modes are out of scope.
|
||||
- Autopilot is not an authorization bypass. All existing task, workspace, and MCP
|
||||
handler checks still apply.
|
||||
|
||||
## Failure behavior
|
||||
|
||||
- If durable question creation fails, no parent prompt is sent and the tool returns
|
||||
an error; the agent may continue with best judgment.
|
||||
- If parent prompt dispatch fails after persistence, the pending record remains
|
||||
recoverable and retry does not create a second question.
|
||||
- If no parent exists, no pending indicator is created.
|
||||
- If the parent is busy, the question uses the existing peer-message queue and the
|
||||
child waits without holding an MCP request open.
|
||||
- If an answer races a superseding prompt or terminal transition, exactly one state
|
||||
change wins; the loser has no delivery side effect.
|
||||
- Multiple independent questions cannot be pending for one child session at once.
|
||||
A second request in the same wait returns the existing pending question rather
|
||||
than producing a message storm.
|
||||
|
||||
## Acceptance scenarios
|
||||
|
||||
**GIVEN** task creation omits `autopilot`, **WHEN** the task is launched, **THEN** it
|
||||
has the normal prompt, discovers `ask_user_question_kandev`, and shows no autopilot
|
||||
chip or icon.
|
||||
|
||||
**GIVEN** a compatible child task is created with `autopilot: true`, **WHEN** it is
|
||||
listed and launched, **THEN** the persisted property is returned, the yellow chip
|
||||
and sidebar icon appear, its system prompt contains the autonomy contract, and it
|
||||
discovers `ask_parent_question_kandev` but not `ask_user_question_kandev`.
|
||||
|
||||
**GIVEN** an autopilot child has an essential question, **WHEN** it calls the parent
|
||||
question tool, **THEN** the call returns immediately, exactly one structured prompt
|
||||
is queued or delivered to its direct parent, the child ends in waiting state, and
|
||||
its sidebar row shows the question indicator.
|
||||
|
||||
**GIVEN** the direct parent sends a correlated answer, **WHEN** the answer is
|
||||
accepted, **THEN** the pending indicator clears and exactly one child turn starts
|
||||
with the attributed answer.
|
||||
|
||||
**GIVEN** Kandev restarts while a child awaits its parent, **WHEN** state is rebuilt,
|
||||
**THEN** the child remains waiting, the question indicator is restored, and the
|
||||
parent prompt is not duplicated.
|
||||
|
||||
**GIVEN** a pending question is superseded or made stale, **WHEN** a late correlated
|
||||
answer arrives, **THEN** it is rejected and does not resume the child.
|
||||
|
||||
**GIVEN** an autopilot task has no parent, **WHEN** its MCP tools are listed,
|
||||
**THEN** no question tool is present and the task remains responsible for proceeding
|
||||
with best judgment.
|
||||
|
||||
**GIVEN** the task switcher is opened on a narrow mobile viewport, **WHEN** an
|
||||
autopilot child is waiting on its parent, **THEN** both autopilot identity and the
|
||||
question state are perceivable without horizontal scrolling or a desktop-only
|
||||
interaction.
|
||||
|
||||
## Out of scope
|
||||
|
||||
- Changing autopilot after task creation.
|
||||
- Automatically inheriting autopilot from a parent.
|
||||
- Routing directly to the ultimate root instead of the direct parent.
|
||||
- Asking the operator from a top-level autopilot task.
|
||||
- Applying autopilot to Office, quick chat, utility/config sessions, or runtimes
|
||||
that cannot enforce the Kandev task MCP contract.
|
||||
- General-purpose approvals, permissions, or multi-party voting.
|
||||
Reference in New Issue
Block a user