derive

package
v0.3.33 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 22, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const AuditSpillPath = "spill_path"

AuditSpillPath records the workspace-relative spill file for a truncated tool result.

View Source
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).

View Source
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.

Variables

This section is empty.

Functions

func AppendSkillLoad

func AppendSkillLoad(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, content skill.Content) (string, error)

func DeriveMessages

func DeriveMessages(ctx context.Context, events []agentkit.SessionEvent, maxToolBytes int) []agentkit.ModelMessage

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 LatestSeq

func LatestSeq(ctx context.Context, s agentkit.Session) (agentkit.EventSeq, error)

LatestSeq returns the highest durable event sequence for the session.

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 ReadAllEvents(ctx context.Context, s agentkit.Session) ([]agentkit.SessionEvent, error)

func RenderSkillLoaded added in v0.3.33

func RenderSkillLoaded(content skill.Content) string

RenderSkillLoaded formats a loaded skill for the model, including resource-base guidance.

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

func SanitizeToolCall(call agentkit.ToolCall) agentkit.ToolCall

SanitizeToolCall prepares a tool call for durable session storage.

func SpillPathAbs

func SpillPathAbs(ctx context.Context, ws cw.Service, rel string) (string, error)

SpillPathAbs resolves a stored spill_path audit entry to an absolute path.

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(events []agentkit.SessionEvent, agentID agentkit.AgentID) []IndexedMessage

IndexMessagesForCompaction rebuilds the model-visible list used for compaction, including the latest compaction summary and retained tail when present.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL