pub enum PiMessage {
System {
content: Value,
sections: Map<String, Value>,
tools_added: Vec<Value>,
tools_removed: Vec<Value>,
timestamp: f64,
extra: Map<String, Value>,
},
User {
content: Value,
timestamp: f64,
attachments: Vec<Value>,
extra: Map<String, Value>,
},
Assistant {
content: Vec<ContentBlock>,
api: String,
provider: String,
model: String,
usage: Option<Usage>,
stop_reason: String,
timestamp: f64,
extra: Map<String, Value>,
},
ToolResult {
tool_call_id: String,
tool_name: String,
content: Value,
usage: Option<Usage>,
is_error: bool,
timestamp: f64,
extra: Map<String, Value>,
},
BashExecution {
command: String,
output: String,
exit_code: Option<i64>,
cancelled: bool,
truncated: bool,
full_output_path: Option<String>,
timestamp: f64,
extra: Map<String, Value>,
},
}Expand description
A conversation message, discriminated on role. This is pi’s
AgentMessage union plus the RPC-only bashExecution role.
Variants§
System
The prompt and tool loadout (pi ≥ 0.86.0). The first request of a
session emits one carrying every prompt section and tool
declaration; later changes emit further system messages that
patch sections by name (null removes one) and list
toolsAdded / toolsRemoved. Replaying them in order yields the
current prompt and tools. Streams as message_start /
message_end ahead of the user message and leads agent_end’s
messages.
Fields
content: ValueA plain string or an array of text blocks; empty when the
prompt lives entirely in sections.
sections: Map<String, Value>Named prompt sections (preamble, tools, rules, cwd,
docs, project_context, …) — string bodies, or null
to remove a section declared earlier.
User
Fields
Assistant
Fields
content: Vec<ContentBlock>ToolResult
Fields
BashExecution
Created by the RPC bash command, never by LLM tool calls. On the
next prompt it is rewritten into a user message for the model.