pub struct Item {
pub id: Option<MessageId>,
pub kind: ItemKind,
pub parts: Vec<Part>,
pub metadata: MetadataMap,
}Expand description
A single entry in the agent transcript.
An Item represents one message or event in the conversation between
the system, user, assistant, and tools. Each item has a kind
that determines its role and a vector of Parts that carry its content.
Items are the primary unit of data flowing through the agentkit loop:
callers submit user and system items, the loop appends assistant and tool
items, and compaction strategies operate on the full Vec<Item> transcript.
§Example
use agentkit_core::{Item, ItemKind};
let user_msg = Item::text(ItemKind::User, "List the workspace crates.");
assert_eq!(user_msg.kind, ItemKind::User);
assert_eq!(user_msg.parts.len(), 1);Fields§
§id: Option<MessageId>Optional provider-assigned or user-supplied message identifier.
kind: ItemKindThe role of this item in the transcript.
parts: Vec<Part>The content parts that make up this item.
metadata: MetadataMapArbitrary key-value metadata for this item.
Implementations§
Source§impl Item
impl Item
Sourcepub fn new(kind: ItemKind, parts: Vec<Part>) -> Self
pub fn new(kind: ItemKind, parts: Vec<Part>) -> Self
Builds an item with the given role and parts.
Sourcepub fn notification(text: impl Into<String>) -> Self
pub fn notification(text: impl Into<String>) -> Self
Builds a ItemKind::Notification item carrying free-form text.
Adapters wrap the content in <system-reminder> and deliver it as
a user-role message so the model can react to the notification on
its next turn without violating tool_use/tool_result pairing.
Sourcepub fn with_metadata(self, metadata: MetadataMap) -> Self
pub fn with_metadata(self, metadata: MetadataMap) -> Self
Replaces the item metadata.