pub struct UserMessage {Show 26 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 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>>,
}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.
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>>Implementations§
Source§impl UserMessage
impl UserMessage
Sourcepub fn tool_use_result_as<T: DeserializeOwned>(
&self,
) -> Option<Result<T, Error>>
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.
Sourcepub fn subagent_result(&self) -> Option<SubagentResult>
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
impl Clone for UserMessage
Source§fn clone(&self) -> UserMessage
fn clone(&self) -> UserMessage
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more