Skip to main content

Crate agentkit_core

Crate agentkit_core 

Source
Expand description

Core transcript, content, usage, and cancellation primitives for agentkit.

This crate provides the foundational data model shared by every crate in the agentkit workspace. It defines:

§Example

use agentkit_core::{Item, ItemKind};

// Build a minimal transcript to feed into the agent loop.
let transcript = vec![
    Item::text(ItemKind::System, "You are a coding assistant."),
    Item::text(ItemKind::User, "What files are in this repo?"),
];

assert_eq!(transcript[0].kind, ItemKind::System);

Structs§

ApprovalId
Identifies a pending tool-use approval request.
ArtifactId
Identifies a binary or text artifact stored externally.
CancellationController
Owner-side handle for broadcasting cancellation to running turns.
CancellationHandle
Read-only view of cancellation state, cheaply cloneable.
CostUsage
Monetary cost for a single model turn.
CustomPart
A provider-specific content part that does not fit the standard variants.
FilePart
A file attachment within an Item.
Item
A single entry in the agent transcript.
MediaPart
Binary or encoded media content (image, audio, video).
MessageId
Identifies a transcript Item.
PartId
Identifies a content part within a streaming Delta sequence.
ProviderMessageId
Provider-assigned identifier for a message.
ReasoningPart
Model reasoning or chain-of-thought output.
SessionId
Identifies an agent session.
StructuredPart
Structured JSON content, optionally paired with a JSON Schema for validation.
TaskId
Identifies a task tracked by a task manager.
TextPart
Plain text content within an Item.
Timestamp
A wall-clock instant carried on items, expressed as milliseconds since the Unix epoch in UTC. Stamped by the loop when items land in the transcript so consumers can sort, filter, or expire by age without depending on a particular date-time crate.
TokenUsage
Token counts broken down by direction and special categories.
ToolCallId
Identifies a tool call emitted by the model.
ToolCallPart
A tool invocation request emitted by the model.
ToolResultId
Identifies a tool result.
ToolResultPart
The result of executing a tool, sent back to the model.
TurnCancellation
A snapshot of the cancellation generation at the start of a turn.
TurnId
Identifies a single turn within a session.
Usage
Token and cost usage reported by a model provider for a single turn.

Enums§

AgentError
Top-level error type that unifies normalisation and protocol errors.
DataRef
A reference to content data that may live inline, at a URI, or in an artifact store.
Delta
An incremental update emitted while a model turn is streaming.
FinishReason
The reason a model turn ended.
ItemKind
The role of an Item in the transcript.
Modality
The kind of media carried by a MediaPart.
NormalizeError
Error returned when content cannot be normalised into the agentkit data model.
Part
A content part within an Item.
PartKind
Discriminant for Part variants, used in streaming Deltas.
ProtocolError
Error indicating an invalid state in the provider protocol.
ToolOutput
The payload returned by a tool execution.

Type Aliases§

MetadataMap
A map of arbitrary key-value metadata attached to items, parts, and other structures.