pub struct Task {Show 20 fields
pub id: String,
pub tool_name: String,
pub arguments: Value,
pub status: TaskStatus,
pub created_at: Instant,
pub created_at_str: String,
pub last_updated_at_str: String,
pub ttl: u64,
pub poll_interval: u64,
pub status_message: Option<String>,
pub meta: Option<Value>,
pub result: Option<CallToolResult>,
pub error: Option<JsonRpcError>,
pub owner: TaskOwner,
pub input_requests: InputRequests,
pub answered_input_keys: BTreeSet<String>,
pub superseded_input_keys: BTreeSet<String>,
pub cancellation_token: CancellationToken,
pub completed_at: Option<Instant>,
pub completion_notify: Arc<Notify>,
}Expand description
Internal task representation with full state
Fields§
§id: StringUnique task identifier
tool_name: StringName of the tool being executed
arguments: ValueArguments passed to the tool
status: TaskStatusCurrent task status
created_at: InstantWhen the task was created
created_at_str: StringISO 8601 timestamp string
last_updated_at_str: StringISO 8601 timestamp of last state change
ttl: u64Time-to-live in milliseconds (for cleanup after completion)
poll_interval: u64Suggested polling interval in milliseconds
status_message: Option<String>Human-readable status message
meta: Option<Value>Protocol metadata retained across every task view.
result: Option<CallToolResult>The result of the tool call (when completed)
error: Option<JsonRpcError>Structured execution error (when failed).
SEP-2663 requires tasks/get to surface a JSON-RPC error object, not a
message string. A tool that returns CallToolResult { isError: true }
is a completed task carrying an error result, so it never sets this.
owner: TaskOwnerPrincipal that created the task, or None when it was created
without an authenticated context.
Never serialized: ownership is an authorization fact, not wire state.
input_requests: InputRequestsInput requests currently awaiting a client response, keyed as sent.
answered_input_keys: BTreeSet<String>Keys answered by a previous tasks/update.
superseded_input_keys: BTreeSet<String>Keys displaced by a later TaskStore::require_input before being
answered.
cancellation_token: CancellationTokenCancellation token for aborting the task
completed_at: Option<Instant>When the task reached terminal status (for TTL tracking)
completion_notify: Arc<Notify>Notified when task reaches a terminal state
Implementations§
Source§impl Task
impl Task
Sourcepub fn to_task_object(&self) -> TaskObject
pub fn to_task_object(&self) -> TaskObject
Convert to TaskObject for API responses
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if this task should be cleaned up (TTL expired).
The clock runs from creation, per SEP-2663. A long-running task can
therefore expire while still working, which is the intended behavior:
ttlMs bounds how long the server retains the task, not how long it
lingers after finishing.
Sourcepub fn outstanding_input_requests(&self) -> &InputRequests
pub fn outstanding_input_requests(&self) -> &InputRequests
Outstanding input requests, if the task is waiting on the client.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Check if the task has been cancelled