pub struct UserMessage {
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>,
}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.
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