The Prompt Turn Lifecycle
A prompt turn follows a structured flow that enables rich interactions between the user, Agent, and any connected tools.1. User Message
The turn begins when the Client sends asession/prompt
:
The contents of the user message, e.g. text, images, files, etc.Clients MUST restrict types of content according to the Prompt Capabilities established during initialization.
Learn more about Content
2. Agent Processing
Upon receiving the prompt request, the Agent processes the user’s message and sends it to the language model, which MAY respond with text content, tool calls, or both.3. Agent Reports Output
The Agent reports the model’s output to the Client viasession/update
notifications. This may include the Agent’s plan for accomplishing the task:
Learn more about Agent Plans
4. Check for Completion
If there are no pending tool calls, the turn ends and the Agent MUST respond to the originalsession/prompt
request with a StopReason
:
StopReason
.
5. Tool Invocation and Status Reporting
Before proceeding with execution, the Agent MAY request permission from the Client via thesession/request_permission
method.
Once permission is granted (if required), the Agent SHOULD invoke the tool and report a status update marking the tool as in_progress
:
fs
) methods to access resources within the Client’s environment.
When the tool completes, the Agent sends another update with the final status and any content:
Learn more about Tool Calls
6. Continue Conversation
The Agent sends the tool results back to the language model as another request. The cycle returns to step 2, continuing until the language model completes its response without requesting additional tool calls or the turn gets stopped by the Agent or cancelled by the Client.Stop Reasons
When an Agent stops a turn, it must specify the correspondingStopReason
:
end_turn
The language model finishes responding without requesting more tools
max_tokens
The maximum token limit is reached
max_turn_requests
The maximum number of model requests in a single turn is exceeded
refusal
The Agent refuses to continue
cancelled
The Client cancels the turn
Cancellation
Clients MAY cancel an ongoing prompt turn at any time by sending asession/cancel
notification:
cancelled
as soon as it sends the session/cancel
notification.
The Client MUST respond to all pending session/request_permission
requests with the cancelled
outcome.
When the Agent receives this notification, it SHOULD stop all language model requests and all tool call invocations as soon as possible.
After all ongoing operations have been successfully aborted and pending updates have been sent, the Agent MUST respond to the original session/prompt
request with the cancelled
stop reason.
API client libraries and tools often throw an exception when their operation is aborted, which may propagate as an error response to
session/prompt
.Clients often display unrecognized errors from the Agent to the user, which would be undesirable for cancellations as they aren’t considered errors.Agents MUST catch these errors and return the semantically meaningful cancelled
stop reason, so that Clients can reliably confirm the cancellation.session/update
notifications with content or tool call updates after receiving the session/cancel
notification, but it MUST ensure that it does so before responding to the session/prompt
request.
The Client SHOULD still accept tool call updates received after sending session/cancel
.
Once a prompt turn completes, the Client may send another
session/prompt
to continue the conversation, building on the context established in previous turns.