Skip to main content

Module message

Module message 

Source
Expand description

Messages stored in sessions and sent to providers.

Mirrors packages/ai/src/types.ts and packages/coding-agent/src/core/messages.ts in pi v1.0.0. Fields are declared in the order pi’s providers and agent loop build them; see the crate docs for why existing files are not re-serialized from these types.

Structs§

AssistantMessage
A model response. Providers append responseId and the fields after it once the response arrives, so they follow timestamp.
BashExecutionMessage
Output of a user !command.
BranchSummaryMessage
CompactionSummaryMessage
Cost
Cost in US dollars.
CustomMessage
DeferredHandle
Handle to a response the provider finishes later.
ImageContent
NestedToolCall
NestedToolCalls
Bounded record of the tool calls a tool made, for example from a codemode script.
SystemMessage
System prompt state at one point in the transcript. The first system message is the prompt; later ones patch it.
TextContent
ThinkingContent
ToolCall
ToolDeclaration
A tool as declared to the model.
ToolReference
A tool referenced by name.
ToolResultMessage
Result of one tool call. nestedCalls is attached after the result is built, so it follows timestamp.
Usage
Token usage and cost of one request.
UserMessage

Enums§

Content
Message content: plain text or a list of blocks.
ContentBlock
A content block, tagged by type. Which kinds a role allows follows pi’s types: assistants use text, thinking and tool calls; users and tool results use text and images.
Message
A message in a session or agent context, tagged by role.
NestedToolCallStatus
StopReason
ThinkingLevel
pi thinking level, from off to max, ordered by effort.

Functions§

blocks_text
The text blocks of blocks joined by separator.