Skip to main content

UserMessage

Struct UserMessage 

Source
pub struct UserMessage {
Show 36 fields pub message: MessageContent, pub session_id: Option<Uuid>, pub parent_tool_use_id: Option<String>, pub uuid: Option<String>, pub timestamp: Option<String>, pub tool_use_result: Option<Value>, pub agent_id: Option<String>, pub subagent_type: Option<String>, pub task_description: Option<String>, pub origin: Option<MessageOrigin>, pub priority: Option<String>, pub is_synthetic: Option<bool>, pub should_query: Option<bool>, pub is_meta: Option<bool>, pub is_visible_in_transcript_only: Option<bool>, pub is_virtual: Option<bool>, pub is_compact_summary: Option<bool>, pub summarize_metadata: Option<SummarizeMetadata>, pub mcp_meta: Option<McpMeta>, pub tool_result_meta: Option<Vec<ToolResultMeta>>, pub source_tool_use_id: Option<String>, pub source_tool_assistant_uuid: Option<String>, pub image_paste_ids: Option<Vec<u64>>, pub client_platform: Option<String>, pub inbound_origin: Option<String>, pub is_replay: Option<bool>, pub file_attachments: Option<Vec<Value>>, pub seeded_summon: Option<bool>, pub client_composed: Option<bool>, pub text_not_typed: Option<bool>, pub initiator: Option<String>, pub pasted_content: Option<Vec<Value>>, pub historical: Option<bool>, pub server_received_wall_ms: Option<f64>, pub refused_message_id: Option<String>, pub requeue_if_interrupted_within_ms: Option<u64>,
}
Expand description

User message

Fields§

§message: MessageContent§session_id: Option<Uuid>§parent_tool_use_id: Option<String>

Parent tool use ID for nested agent messages

§uuid: Option<String>

Message-level unique identifier

§timestamp: Option<String>

CLI-emitted ISO-8601 timestamp for the message (present on echoed tool results).

§tool_use_result: Option<Value>

Structured tool result data echoed by the CLI alongside the tool_result content block. The shape depends on which tool produced it (e.g. for AskUserQuestion it is { questions, answers }; for Bash it is { stdout, stderr, exit_code, ... }). Stored as raw JSON to preserve wire fidelity; use UserMessage::tool_use_result_as to parse into a typed shape when you know which tool was invoked.

§agent_id: Option<String>

ID of the subagent this user message belongs to (the task_id of its task events), on the prompt echoed into a local_agent subagent. Seen on the wire from CLI 2.1.292, where it is not part of the published user-message schema. Not settable by clients.

§subagent_type: Option<String>

Subagent type, when this user message is the prompt echoed into a local_agent subagent (e.g. general-purpose).

§task_description: Option<String>

Short description of the subagent task, present alongside subagent_type.

§origin: Option<MessageOrigin>§priority: Option<String>§is_synthetic: Option<bool>§should_query: Option<bool>§is_meta: Option<bool>§is_visible_in_transcript_only: Option<bool>§is_virtual: Option<bool>§is_compact_summary: Option<bool>§summarize_metadata: Option<SummarizeMetadata>§mcp_meta: Option<McpMeta>§tool_result_meta: Option<Vec<ToolResultMeta>>

Display metadata for this message’s tool_result blocks, keyed by tool_use_id.

§source_tool_use_id: Option<String>§source_tool_assistant_uuid: Option<String>§image_paste_ids: Option<Vec<u64>>§client_platform: Option<String>§inbound_origin: Option<String>§is_replay: Option<bool>§file_attachments: Option<Vec<Value>>§seeded_summon: Option<bool>

Desktop host only: the host’s own seeded summon (CLI 2.1.239+).

§client_composed: Option<bool>

True when the client composed this turn from content the user did not type; its text is delivered as written (CLI 2.1.259+).

§text_not_typed: Option<bool>

True when no person typed this message’s text in this session (a server or an app composed it). The text is delivered as written: no slash-command dispatch, no at-mention expansion beyond the message’s own uploaded files, no keyword reminders or commands, and a skill it names does not count as typed by the user. Unlike client_composed, the turn-start attachment pass still runs. Who sent it stays with origin (CLI 2.1.300+).

§initiator: Option<String>

The host’s own label for what started this turn (e.g. the desktop app’s scheduled-task, sleep-auto-resume); user or absent means a person sent it. Usage attribution only; it does not change how the turn runs (CLI 2.1.278+).

§pasted_content: Option<Vec<Value>>

Content the user pasted into the prompt rather than typed: each entry a string or an array of content blocks. The CLI appends the text of each entry after the typed text, in order, and may wrap it in <pasted_content> tags. Blocks other than text are ignored; send images and documents in message.content (CLI 2.1.278+).

§historical: Option<bool>

Replayed history rather than a live message: the Remote Control bridge stamps it on the messages it flushes to the session server, which also stamps it on deliveries it replays (CLI 2.1.266+).

§server_received_wall_ms: Option<f64>

Epoch milliseconds on the session server’s clock when it received the HTTP request that delivered this message. Written by the session server; the CLI copies it to the turn’s result as user_message_server_received_wall_ms (CLI 2.1.286+). Not settable by clients.

§refused_message_id: Option<String>

Only on the synthetic message that re-asks the same model after a refusal: the API msg_* id of the refused response. Absent when the CLI has no well-formed id for it (CLI 2.1.290+).

§requeue_if_interrupted_within_ms: Option<u64>

Input only: asks the CLI to put this prompt back at the front of its queue, under the same uuid, when an interrupt without cancel_queued stops the turn taking it in within this many milliseconds (counted from the turn’s system/status requesting frame) and before the model’s reply begins. Values above 10000 count as 10000 (CLI 2.1.307+).

Implementations§

Source§

impl UserMessage

Source

pub fn tool_use_result_as<T: DeserializeOwned>( &self, ) -> Option<Result<T, Error>>

Parse the tool_use_result field into a caller-specified type.

Returns None if tool_use_result is absent, otherwise returns the deserialization result. The caller must know which tool produced the result and supply a matching type — e.g. for AskUserQuestion use AskUserQuestionInput, whose questions + answers fields match the wire result shape.

Source

pub fn subagent_result(&self) -> Option<SubagentResult>

Parse the tool_use_result as a subagent (Task) run result.

When this user message echoes the result of a Task tool call, the CLI attaches a structured tool_use_result carrying the subagent’s token, timing, and tool-use accounting. Returns None when the field is absent or does not parse as a SubagentResult.

Summing SubagentResult::total_tokens across every Task result in a session yields the subagent token rollup the CLI renders as subagent_tokens in its terminal <usage> block.

Trait Implementations§

Source§

impl Clone for UserMessage

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for UserMessage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for UserMessage

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for UserMessage

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.