AIP-78: TURN-TASK (turn-task/v1): projecting one session turn as an MCP task
Specifies how a host that serves the 2026-07-28 MCP era projects a single turn of an AIP-46 session as an MCP task: server-decided creation for agent_start and agent_prompt, an opaque unguessable taskId bound to a prompt ticket and to its creating principal through a durable ledger, the turn-to-task state mapping, tasks/get, tasks/update and tasks/cancel semantics, cooperative cancellation that ends the turn and not the session, retention, and error codes. It does not replace the AIP-20 work board and does not change the multi-turn lifecycle of AIP-46.
| Field | Value |
|---|---|
| AIP | 78 |
| Title | TURN-TASK (turn-task/v1): projecting one session turn as an MCP task |
| Author | Jeremy André <[email protected]> |
| Status | Draft |
| Type | Schema |
| Requires | AIP-1 (process), AIP-46 (SESSION: sessions, turns, agent_start, agent_prompt, interrupt), AIP-77 (MCP-GATEWAY: the 2026-07-28 era, server/discover, extension negotiation, error mapping) |
| Composes with | AIP-7 (GOVERNANCE), AIP-19 (SECRETS), AIP-20 (WORK), AIP-58 (RUN) |
| Created | 2026-11-26 |
| Packages (ref-impl) | @agentproto/runtime (mcp-modern) |
| Prior art | Model Context Protocol 2026-07-28 Tasks extension (io.modelcontextprotocol/tasks: CreateTaskResult, tasks/get, tasks/update, tasks/cancel) |
Abstract
The MCP 2026-07-28 Tasks extension gives a long-running request a handle
(taskId) that a client polls, updates with input, or cancels. An
AIP-46 session is not a request: it is a multi-turn process
that stays running and idle between turns.
TURN-TASK defines the only projection that is faithful to both: one turn of
a session is one MCP task. The task is created by the server when
agent_start or agent_prompt starts or queues a turn, resolves through a
durable ledger to (sessionId, promptId), ends when the turn ends, and never
changes the session's own lifecycle.
Motivation
- A client that delegates work through the session tools (
agent_start,agent_prompt) today either blocks on a long call or polls session state it must interpret itself. The Tasks extension is the standard shape for that. - Mapping a whole session to one task breaks: the session is
runningand idle after every turn, so the task would never leaveworking, andtasks/cancel(an interrupt) ends a turn but leaves the session alive, so it could never reachcancelled. - The AIP-20 work board and MCP tasks share a word and nothing else. Without an explicit statement, implementers conflate a board item with a protocol handle.
Scope
- In: projection of a turn started or queued by
agent_start(with a prompt) oragent_promptinto an MCP task on the2026-07-28era of the authenticated/mcpendpoint (AIP-77). - Out: the
2025-11-25era (its experimental tasks methods are not specified here;tasks/resultanswers-32601on the modern era), tasks for other tools, and the transport of questions and approvals while a turn waits for input (reused as-is: this AIP only says how the task reflects that wait). - This AIP does not replace the AIP-20 work board and does not change the multi-turn semantics of AIP-46. It adds a handle for one turn; the session remains the unit of lifecycle, identity and state.
Design principles
- A task is a request handle; a turn is the request. One turn, one task.
A second
agent_promptcreates a new task. No task spans turns. - The server decides, the client never asks. The client only declares the extension; the server chooses when a call returns a task.
- The session stays the source of truth. Session state is read from the
session descriptor plus the recorded turn outcome. The projection is
one-directional (turn to task); a task state never drives a session except
through
tasks/updateandtasks/cancel. - Opaque handle.
taskIdcarries no session information and is not derivable from one. - Durable before visible. The task record exists before the creating response is sent.
Specification
Terms
- Principal: the caller identity the host resolves server-side for a request (AIP-46 §Session principals). It is never taken from a client-supplied field.
- Prompt ticket: a host-assigned, stable identifier (
promptId) for one prompt accepted by a session, whether it starts a turn at once or waits in the queue (AIP-46 §Multi-turn semantics). A task is bound to a prompt ticket, not to a position in the queue, so reordering or dropping queue entries cannot re-point a task. - Turn outcome: how the turn of a ticket ended. A closed enumeration:
finished(the turn ended naturally,turn-end),interrupted(cancelled by the interrupt route, by a prompt carryinginterrupt: true, or bytasks/cancel),dropped(removed from the queue before it started),session-error,session-killed,session-exited,session-forgotten(the session record was forgotten, deleted or collected while the ticket was queued or in flight),host-restart. The last five are derived from the AIP-46 sessionstatus(error,killed,exited), from the removal of the session, or from a host restart; they are not new session fields. - Pending input: the host's own record that the turn is waiting on a human answer (a permission, a question, or a suspended run). AIP-46 defines no field for it; this AIP only requires that the host can tell, per ticket, whether such a request is pending.
Extension declaration and creation
A client declares support in the request metadata:
_meta["io.modelcontextprotocol/clientCapabilities"].extensions["io.modelcontextprotocol/tasks"] = {}.
The host advertises extensions["io.modelcontextprotocol/tasks"] in
server/discover (AIP-77) when the feature is enabled.
Which tools return a task is a host setting with three explicit modes, applied
uniformly and documented by the host: agent_start only, agent_prompt only,
or both (the reference default). agent_start without a prompt starts no turn
and never returns a task.
When a covered call starts or queues a turn and the client declared the
extension, the host MUST answer with a CreateTaskResult (resultType: "task"). Otherwise it answers with the ordinary result. A client MUST NOT be
able to force or suppress task creation by any parameter. If the host cannot
answer a non-declaring client without a task (for example, a host policy that
makes every turn start asynchronous), it MUST reject with -32021 carrying
error.data.requiredCapabilities.extensions. A host that can always answer
synchronously never returns -32021 here.
Order of operations. The host MUST:
- check the capability (and the per-principal task cap below) and reject with
-32021or a tool error before it creates any ticket, ledger entry or turn, so a refused call has no side effect; - reserve the identifiers: pre-allocate the
promptIdand, foragent_start, thesessionId(the host chooses it before spawning), then durably write the ledger entry in stateworking(queued) with those reserved identifiers; - only then spawn the session (for
agent_start) and hand the prompt to it, using the reserved identifiers; - send the
CreateTaskResult.
If step 3 fails, the host marks the entry failed and answers the call with
the tool's own error rather than a task. A reserved entry found at start-up
whose session or ticket never came to exist is marked failed (with
data.reason: "host-restart") by the restart rule.
CreateTaskResult MUST carry the session it belongs to in
_meta["io.agentproto/turn-task"] = { sessionId, promptId }, so the client can
keep using the session tools (agent_prompt, agent_output,
agent_sessions_list, agent_kill) with the real sessionId.
Task identity, ledger and ownership
taskIdMUST be generated from at least 128 bits of randomness (reference format:task_followed by 16 random bytes in hex). It MUST NOT be derived from asessionId.- The ledger keeps at least, per task:
{ taskId, sessionId, promptId, principal, createdAt, ttlMs, pollIntervalMs, lastStatus, lastUpdatedAt, endedAt?, outcome?, result? }.principalis the resolved principal that created the task. A host MAY keep further fields (for example the boot it was written under, whether the turn started, the laststatusMessage); this AIP does not require them. - Writes MUST be atomic (write to a temporary file in the same directory,
fsync, rename) and the files readable only by the host user (mode0600). The ledger MUST survive a host restart. - A task is visible to, and can be updated or cancelled by, its creating
principal, and by a principal that the host's session rules
(AIP-46 §Delegation, §Session principals) allow to act on the
underlying session. For anyone else the answer is
-32602, identical to an unknown task. - The host MUST cap the number of non-terminal tasks per principal (the limit is a host setting). Creation beyond the cap is refused as in step 1.
Task object
interface Task {
taskId: string
status: "working" | "input_required" | "completed" | "cancelled" | "failed"
statusMessage?: string
createdAt: string // ISO 8601
lastUpdatedAt: string // ISO 8601, monotonic per task
ttlMs: number // retention after the terminal state
pollIntervalMs?: number
}
type CreateTaskResult = Result & Task & { resultType: "task" }
type DetailedTask =
| (Task & { status: "working" })
| (Task & { status: "input_required"; inputRequests: Record<string, unknown> })
| (Task & { status: "completed"; result: TurnResult })
| (Task & { status: "failed"; error: { code: number; message: string; data?: unknown } })
| (Task & { status: "cancelled" })
interface TurnResult {
sessionId: string
text: string // final assistant text of the turn, bounded
truncated: boolean // true when text was cut at the bound
}TurnResult is the same for agent_start and agent_prompt. It is not the
Session JSON; the session is read through the session tools. text is
bounded by a host setting, and the host MUST redact values it holds as secrets
(AIP-19) before storing it. A transcript is never stored.
inputRequests is a map whose keys are generated by the host and stay stable
over the life of the task. Each value is the request object of the mechanism
that raised it, in the shape that mechanism defines (an MCP elicitation request
for a permission or question, or the same for a suspended run). Its entries
are removed once answered.
Turn-to-task state mapping
Recording. The host MUST write the terminal state and the result to the
ledger at the moment the turn ends (and at every other terminal transition),
not when a client reads. The rows below are evaluated in order, first match
wins, only for an entry with no recorded terminal state; an entry already
terminal is never re-derived. A crash between the end of a turn and the ledger
write is an accepted window: such a turn has no recorded outcome and is
reported failed (host-restart) even though the agent finished; the host
SHOULD keep that window as small as it can (write before acknowledging the
turn end to any observer). host-restart is therefore declared only for an
entry that has no recorded terminal state: a turn that ended and was recorded
before the restart stays completed (or its recorded state). A session resumed
after a restart does not revive a failed task; a prompt sent to it creates a
new ticket and a new task.
| Condition on the ticket | Task status | Detail |
|---|---|---|
outcome interrupted or dropped | cancelled | the session is untouched: it stays running |
outcome session-killed (turn queued or in flight) | cancelled | |
outcome session-exited, turn in flight | failed | error.code: -32603, data: { reason: "session-exited", sessionId, exitCode? } |
outcome session-exited, turn never started | cancelled | no work was done |
outcome session-error, turn in flight | failed | data.reason: "session-error" |
outcome session-error, turn never started | cancelled | no work was done |
outcome session-forgotten, turn in flight | failed | data.reason: "session-forgotten" |
outcome session-forgotten, turn never started | cancelled | no work was done |
outcome host-restart, task non-terminal | failed | data.reason: "host-restart" |
outcome finished | completed | bounded result written to the ledger |
| in flight and pending input | input_required | inputRequests carries the pending requests |
| in flight | working | statusMessage MAY name the phase |
| queued, not started | working | statusMessage: "queued", pollIntervalMs set |
A turn in which a tool reported isError: true but that ended finished is
completed: the tool outcome stays in the text of the result, not in error.
failed is for abnormal ends only. On a host restart, only tasks that were not
terminal become failed; a task that was already completed, cancelled or
failed keeps its state and result.
Methods
tasks/get{ taskId }returnsresultType: "complete"plus theDetailedTask. It MUST have no observable effect on the task or the session: it never carriesinputResponses, and it is idempotent. (The host MAY refresh its own derived state or sweep expired entries; neither is visible to the caller.) Once a turn ends, the bounded result is stored, so a latetasks/getis stable even if the session has started another turn.tasks/getis not a cacheable operation: nocacheScope, andttlMsis the retention, never a cache hint.tasks/update{ taskId, inputResponses }answers pending input and returns an empty acknowledgement ({ resultType: "complete" }). Keys that are unknown or already answered are ignored. On a task that is notinput_required(including a terminal one) it is an acknowledged no-op. The answer is applied through the mechanism that raised the request, so that mechanism's rules still hold, including AIP-7 (an answer on an input channel is not a governance decision).tasks/cancel{ taskId }returns an empty acknowledgement and is idempotent and cooperative. It acts only on the task's own ticket:- ticket queued: remove it from the queue; the task becomes
cancelled(outcomedropped); - ticket is the turn in flight: interrupt it as AIP-46
§Interrupt describes; the turn ends, the task becomes
cancelled, the session stays alive; - the harness cannot cancel a turn (AIP-46 §Interrupt, HTTP
409): this applies only to a ticket that is the turn in flight; the call returns a JSON-RPC error (tasks/cancelis a method, not a tool call) and the task staysworking; - ticket already ended, or the task terminal: acknowledged, no effect. In
particular
tasks/cancelMUST NOT interrupt a later turn of the same session. A cancel that races the move of its ticket from queued to in flight is atomic with respect to that move: the host serializes both on the session, so the ticket is either dropped (it never starts) or interrupted (it started), never both and never neither. The transition tocancelledis not guaranteed: if the turn finishes first,completedis a valid outcome.tasks/cancelMUST NOT kill the session, andnotifications/cancelledMUST NOT be used to cancel a task.
- ticket queued: remove it from the queue; the task becomes
- Interplay with the queue. A queued prompt removed through the queue
controls ends its task as
cancelled. A prompt sent withinterrupt: trueends the previous in-flight turn (its task becomescancelled) and creates a separate task for the new ticket. tasks/listandtasks/resultdo not exist on this era;tasks/resultanswers-32601. Discovery of sessions stays withagent_sessions_list.
Transport and errors
tasks/get, tasks/update and tasks/cancel MUST carry
Mcp-Method: <method> and Mcp-Name: <taskId>; an inconsistent header is
-32020 (HTTP 400). Error mapping follows AIP-77: -32021 is
HTTP 400; an unknown, expired, or not visible taskId is -32602, HTTP
400. Because Mcp-Name carries the handle in a header, a host SHOULD NOT
write the full taskId to shared logs or access logs (a prefix or a hash is
enough).
Retention
Every task has an explicit ttlMs: a host default and a host maximum apply.
ttlMs counts from the moment the task reaches a terminal state; before that
it reports the retention that will apply. The host MUST NOT purge a task that
is not terminal. A terminal entry is purged only after ttlMs has elapsed since
its endedAt, and its result MUST already be in the ledger. The host sweeps at
start-up and during reads. An expired entry answers -32602. A session
forgotten or collected while its ticket was non-terminal does not leave a task
without result: it ends the task as session-forgotten (see the mapping).
Rationale
- Turn, not session. A session is long-lived and multi-turn; the Tasks extension models one request. Projecting the turn keeps both honest.
- Prompt ticket, not position. Queue positions change when prompts are reordered or dropped; a stable ticket keeps each task bound to its own prompt.
- Server-decided creation. The extension lets the server choose; making it a client option would create two result shapes per call and a new place for clients to disagree. Declaring support is enough.
- Cancel the turn, not the session. The existing interrupt ends a turn and
keeps context. Reusing it, only for the task's own ticket, gives
tasks/cancela precise, non-destructive meaning. - Random handle, owner-bound, plus ledger. Session ids are short and guessable; the handle must not derive from them, must not work for another principal, and must resolve after a restart.
- Distinct from AIP-20. A work board item is a unit of planned work with owners, dependencies and verification. An MCP task is a transient protocol handle. They are unrelated and neither reads nor writes the other.
Reference Implementation
@agentproto/runtime (packages/runtime/src/mcp-modern) implements the
projection, the prompt tickets, the ledger, the state mapping and the three
methods behind the host configuration flag mcp.tasks. The host settings the
text above leaves to the host are mcp.tasksTools (both, the default,
agent_start or agent_prompt), mcp.tasksTtlMs and mcp.tasksMaxTtlMs (the
retention default and maximum), mcp.tasksMaxPerPrincipal (the cap of
non-terminal tasks per principal; a call beyond it is refused with a tool error)
and mcp.tasksResultMaxChars (the bound of TurnResult.text, cut at the bound).
That host answers every covered call synchronously for a client that did not
declare the extension, so it never returns -32021 from agent_start or
agent_prompt.
Security considerations
- Unguessable handles. 128-bit random ids; never derived from a session id.
- No privilege through a task. A task is bound to the principal resolved
server-side when it was created. Reading, updating or cancelling it needs
that principal, or one allowed to act on the session. A known
taskIdgrants nothing. - Bounded creation. The capability check and the per-principal cap of non-terminal tasks run before any turn or ledger entry exists.
- Secrets. Stored results are redacted and bounded; the handle is kept out of shared logs.
- No new decision path.
tasks/updatereuses the existing answer paths and cannot decide a governance approval (AIP-7). - Bounded storage. Ledger results are bounded text, not transcripts;
terminal entries expire after
ttlMs; files are0600and written atomically. - Cooperative cancel only.
tasks/cancelcannot terminate a session.
Conformance
A host conforms to turn-task/v1 when:
- A client that declared the Tasks extension receives a
CreateTaskResultfrom each covered tool (agent_startwith a prompt,agent_prompt, per the configured mode); a client that did not receives the ordinary result or-32021. CreateTaskResultcarries thesessionId; the task reachescompletedat the end of the turn while the session staysrunning; a secondagent_promptcreates a second task.tasks/getimplements the state mapping above and has no observable effect.tasks/cancelon the in-flight turn yieldscancelled(orcompletedon a race) and leaves the session alive; on a queued ticket it drops it; on an ended task or ticket it is an idempotent no-op that never interrupts a later turn.- A task whose turn ended is recorded as terminal at that moment, so a restart
afterwards leaves it unchanged. A host restart between creation and a later
tasks/getturns a task with no recorded terminal state intofailedwithdata.reason: "host-restart", leaves terminal tasks unchanged, and every task still resolves. - An inconsistent
Mcp-Nameis-32020; an unknown, expired or not visibletaskIdis-32602;tasks/resultis-32601; a task is not visible to a different principal. - A session forgotten, deleted or collected while a ticket is queued or in
flight ends its task (
cancelledorfailedper the table); no task staysworkingforever or keeps counting against the per-principal cap. - A refused creation (
-32021, per-principal cap) leaves no ticket, ledger entry or turn behind. - The AIP-20 work board behaves identically with the feature on or off.
See also
- AIP-1: process and RFC 2119 terminology
- AIP-7: GOVERNANCE, approvals are never decided by an answer to a prompt
- AIP-20: WORK, the work board this AIP does not replace
- AIP-46: SESSION, the multi-turn lifecycle this AIP leaves unchanged
- AIP-58: RUN, whose pending runs can also surface as input requests
- AIP-77: MCP-GATEWAY, the endpoint, era and extension negotiation
AIP-77: MCP-GATEWAY (mcp-gateway/v1): dual-era MCP host gateway, server/discover, and extension negotiation
Specifies how an agentproto host serves its authenticated MCP gateway (/mcp) across both the legacy 2025-11-25 Streamable HTTP era and the stateless 2026-07-28 modern era: authentication-first dispatch, header and single-read body era routing, strict separation of accepted vs advertised protocol versions, server/discover and capabilities.extensions, error status mapping including -32021 (HTTP 400), shared tool-factory discovery modes (deferredTools/tool_search), unified session observability, and configuration rollback. Scope v1 covers /mcp only; /mcp/orchestrator and /mcp/imported/<id> stay on 2025-11-25. It also binds the beta MCP Skills extension (skills/list, skills/get, skill:// resources) and the transport of human input (permissions, questions, approvals, runs) as MRTR elicitation. Host primitives remain specified by their existing AIPs.
AIP-79: COLLECT (collect/v1): collecting public items and their counters with provenance
Specifies a source-agnostic format and engine contract for collecting public items (articles, posts, threads, submissions, reviews, videos) and their metrics with provenance: the collection recipe (collect.recipe/v1: sources, queries with subject labels, window, sampling bands with quota, per-domain cap and seed, caps, workers, lookahead), the collected item, the append-only observation (a missing counter is never zero, the displayed value is kept), the actor with dated audience readings (karma is not audience, an unknown audience carries a reason), the pickup (kind, method, verified rule), the connector contract (a deterministic plan, a network-only fetch, a pure replayable parse, plus a declaration of counters, access, capabilities and pace), the transport contract (api, http, browser, with the failures that escalate and the browser challenge hard stop), dedup at three levels, and run provenance (content-addressed raw bodies, a task log, deterministic resume). It fixes no source: platforms appear only as non-normative examples. A collected item can be imported as an AIP-10 knowledge source.