Documentation / guides
AgenticMessages
Preserve an ordered, mixed conversation thread for inference requests.
AgenticMessages is a named slice of sealed conversation turns. Its zero value is an empty thread, so a caller can build a request incrementally without a constructor.
API surface
type AgenticMessages []Conversation
thread := content.AgenticMessages{}
thread = append(thread,
&content.UserMessage{Message: content.Message{
Role: content.RoleUser,
Blocks: []content.Block{&content.TextBlock{Text: "Hello"}},
}},
&content.AIMessage{Message: content.Message{
Role: content.RoleAssistant,
Blocks: []content.Block{&content.TextBlock{Text: "Hi"}},
}},
)
The slice preserves every turn’s concrete type and block order. It does not expose append, truncation, token counting, or role validation helpers; callers own thread policy and should run request feature validation before invoking a client.
Lifecycle
- Append system, user, and prior assistant turns in provider-neutral order.
- Invoke with
inference.Request.Messages. - Append the returned
AIMessageif another turn is needed. - For a tool call, append a matching
ToolResultMessagebefore the next assistant invocation.
Do not mutate a thread concurrently with a client that is encoding it. The slice and its blocks are ordinary Go values with no synchronization.
Proof
- Source:
core/content/message.go - Tests:
core/content/message_test.gocovers nil, empty, and mixed four-type threads. - Example:
core/examples/content/example_test.go
Related: Conversation, Request messages.