Documentation
¶
Index ¶
- Constants
- func AppendSkillLoad(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, ...) error
- func DeriveMessages(ctx context.Context, events []agentkit.SessionEvent, maxToolBytes int) []agentkit.ModelMessage
- func EstimateLogicalChars(msg agentkit.ModelMessage) int
- func EstimateMessagesChars(messages []agentkit.ModelMessage) int
- func FlattenTextParts(parts []agentkit.ContentPart, sep string) string
- func FormatSessionRecall(hits []capsessionindex.Hit) string
- func HydrateLocalAttachments(ctx context.Context, msgs []agentkit.ModelMessage, ws workspace.Service, ...) ([]agentkit.ModelMessage, error)
- func InterruptedToolResult(call agentkit.ToolCall) agentkit.ToolResult
- func LatestEventSeq(events []agentkit.SessionEvent) agentkit.EventSeq
- func LatestSeq(ctx context.Context, s agentkit.Session) (agentkit.EventSeq, error)
- func PrepareMessagesForLLM(ctx context.Context, msgs []agentkit.ModelMessage, ws workspace.Service, ...) ([]agentkit.ModelMessage, error)
- func PrepareToolResultForStorage(ctx context.Context, sessionID agentkit.SessionID, result agentkit.ToolResult, ...) (agentkit.ToolResult, error)
- func PruneToolResults(messages []agentkit.ModelMessage, maxBytes int) []agentkit.ModelMessage
- func ReadAllEvents(ctx context.Context, s agentkit.Session) ([]agentkit.SessionEvent, error)
- func SanitizeModelMessageForStorage(msg agentkit.ModelMessage, maxTextBytes int) agentkit.ModelMessage
- func SanitizeModelMessageForStorageWS(msg agentkit.ModelMessage, maxTextBytes int, ws workspace.Service) agentkit.ModelMessage
- func SanitizeToolCall(call agentkit.ToolCall) agentkit.ToolCall
- func SpillPathAbs(ctx context.Context, ws cw.Service, rel string) (string, error)
- func SumLogicalCharsFromEvents(events []agentkit.SessionEvent, agentID agentkit.AgentID) int
- func ToolResultMessage(result agentkit.ToolResult) agentkit.ModelMessage
- func TruncateToolResult(result agentkit.ToolResult, maxBytes int) agentkit.ToolResult
- type IndexedMessage
- type RunFinishData
- type RunState
- type Todo
- type TodoUpdateData
- type TurnContinueData
- type UsageData
Constants ¶
const ( TodoPending = "pending" TodoInProgress = "in_progress" TodoDone = "done" )
Todo statuses. Anything other than TodoDone counts as outstanding work.
const ( FinishCompleted = "completed" FinishBlocked = "blocked" )
Run finish statuses.
const AuditSpillPath = "spill_path"
AuditSpillPath records the workspace-relative spill file for a truncated tool result.
const DefaultMaxStoredTextBytes = 8192
DefaultMaxStoredTextBytes caps embedded tool-result text and spill preview views (pi-style truncation applies at tool execution / PrepareToolResultForStorage, not chat message bodies).
const InterruptedToolResultText = "tool execution was interrupted before it produced a result (process exited); re-run it if the result is still needed"
InterruptedToolResultText is the tool result synthesized for a call the process never got to answer. It is model-visible on purpose: the agent needs to know the call was cut off rather than silently succeeded.
const MetadataLogicalChars = "logical_chars"
MetadataLogicalChars stores pre-sanitize size when storage shrinks the message (e.g. stripped inline media).
Variables ¶
This section is empty.
Functions ¶
func AppendSkillLoad ¶
func DeriveMessages ¶
func DeriveMessages(ctx context.Context, events []agentkit.SessionEvent, maxToolBytes int) []agentkit.ModelMessage
func EstimateLogicalChars ¶
func EstimateLogicalChars(msg agentkit.ModelMessage) int
EstimateLogicalChars approximates model-visible size before session storage.
func EstimateMessagesChars ¶
func EstimateMessagesChars(messages []agentkit.ModelMessage) int
EstimateMessagesChars sums logical character counts for a message list (e.g. pre-step history including hydrated vision).
func FlattenTextParts ¶
func FlattenTextParts(parts []agentkit.ContentPart, sep string) string
FlattenTextParts joins non-empty text parts with sep (empty type is treated as text).
func FormatSessionRecall ¶
func FormatSessionRecall(hits []capsessionindex.Hit) string
FormatSessionRecall renders FTS hits for the review digest.
func HydrateLocalAttachments ¶
func HydrateLocalAttachments(ctx context.Context, msgs []agentkit.ModelMessage, ws workspace.Service, maxImageBytes int) ([]agentkit.ModelMessage, error)
HydrateLocalAttachments reloads workspace images for LLM vision (text + image modalities).
func InterruptedToolResult ¶
func InterruptedToolResult(call agentkit.ToolCall) agentkit.ToolResult
InterruptedToolResult is the stand-in result for a call that never ran to completion.
func LatestEventSeq ¶
func LatestEventSeq(events []agentkit.SessionEvent) agentkit.EventSeq
func PrepareMessagesForLLM ¶
func PrepareMessagesForLLM(ctx context.Context, msgs []agentkit.ModelMessage, ws workspace.Service, maxImageBytes int, modalities []string) ([]agentkit.ModelMessage, error)
PrepareMessagesForLLM applies modality policy and optional vision hydration before an LLM call.
func PrepareToolResultForStorage ¶
func PrepareToolResultForStorage(ctx context.Context, sessionID agentkit.SessionID, result agentkit.ToolResult, maxViewBytes int) (agentkit.ToolResult, error)
PrepareToolResultForStorage keeps the model-visible body bounded while persisting the full output to workspace (pi-style spill). When workspace is unavailable, falls back to in-event truncation only.
func PruneToolResults ¶
func PruneToolResults(messages []agentkit.ModelMessage, maxBytes int) []agentkit.ModelMessage
PruneToolResults truncates oversized tool result text deterministically.
func ReadAllEvents ¶
func SanitizeModelMessageForStorage ¶
func SanitizeModelMessageForStorage(msg agentkit.ModelMessage, maxTextBytes int) agentkit.ModelMessage
SanitizeModelMessageForStorage strips bulky inline media before durable session history. User and assistant message text is persisted in full (aligned with pi session JSONL). When maxTextBytes > 0, only tests or explicit callers may cap message body text.
func SanitizeModelMessageForStorageWS ¶
func SanitizeModelMessageForStorageWS(msg agentkit.ModelMessage, maxTextBytes int, ws workspace.Service) agentkit.ModelMessage
SanitizeModelMessageForStorageWS is like SanitizeModelMessageForStorage but normalizes attachment Source paths relative to work dir (no local:/global:/work/ prefixes) when ws implements layout.
func SanitizeToolCall ¶
SanitizeToolCall prepares a tool call for durable session storage.
func SpillPathAbs ¶
SpillPathAbs resolves a stored spill_path audit entry to an absolute path.
func SumLogicalCharsFromEvents ¶
func SumLogicalCharsFromEvents(events []agentkit.SessionEvent, agentID agentkit.AgentID) int
SumLogicalCharsFromEvents totals logical message size for compaction estimates.
func ToolResultMessage ¶
func ToolResultMessage(result agentkit.ToolResult) agentkit.ModelMessage
ToolResultMessage wraps a tool result as a tool-role model message.
func TruncateToolResult ¶
func TruncateToolResult(result agentkit.ToolResult, maxBytes int) agentkit.ToolResult
TruncateToolResult truncates oversized tool result content after execution.
Types ¶
type IndexedMessage ¶
type IndexedMessage = compaction.IndexedMessage
IndexedMessage is a model-visible message with its primary source event seq.
func IndexMessagesForCompaction ¶
func IndexMessagesForCompaction(ctx context.Context, events []agentkit.SessionEvent) []IndexedMessage
IndexMessagesForCompaction rebuilds the model-visible list used for compaction, including the latest compaction summary and retained tail when present.
type RunFinishData ¶
type RunFinishData struct {
Status string `json:"status"`
Summary string `json:"summary,omitempty"`
}
RunFinishData is the payload of an EventRunFinish event.
type RunState ¶
type RunState struct {
StartSeq agentkit.EventSeq
Todos []Todo
Pending []Todo
Finish *RunFinishData
Repeats int
Usage UsageData
Context int
}
RunState is a snapshot of autonomous-run signals from the session log.
type Todo ¶
type Todo struct {
ID string `json:"id"`
Title string `json:"title"`
Status string `json:"status"`
}
Todo is one entry of the durable task list written by tool/todo.
type TodoUpdateData ¶
type TodoUpdateData struct {
Items []Todo `json:"items"`
}
TodoUpdateData is the payload of an EventTodoUpdate event.
type TurnContinueData ¶
type TurnContinueData struct {
Segment int `json:"segment"`
Reason string `json:"reason"`
Steps int `json:"steps"`
Messages []agentkit.ModelMessage `json:"messages,omitempty"`
}
TurnContinueData records one autonomous turn extension.