Documentation
¶
Index ¶
- Constants
- func ActiveSessionEntryKey(platform string, delivery agentkit.SessionID, scope SessionScope, ...) agentkit.SessionID
- func AgentStoreSessionID(ctx context.Context) agentkit.SessionID
- func AppendAutoRetryEnd(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, ...) error
- func AppendAutoRetryStart(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, ...) error
- func AppendCompaction(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, ...) error
- func AppendMessage(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, ...) error
- func AppendOverflowRecovery(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, ...) error
- func AppendRunFinish(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, ...) error
- func AppendSessionRecovery(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, ...) error
- func AppendSkillLoad(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, ...) error
- func AppendStepEnd(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, step int) error
- func AppendStepStart(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, step int) error
- func AppendSubagentEnd(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, ...) error
- func AppendSubagentStart(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, ...) error
- func AppendSummarizationRetryEnd(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, ...) error
- func AppendSummarizationRetryStart(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, ...) error
- func AppendTodoUpdate(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, ...) error
- func AppendToolCall(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, ...) error
- func AppendToolResult(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, ...) error
- func AppendTurnContinue(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, ...) error
- func AppendTurnEnd(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, steps int) error
- func AppendTurnStart(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID) error
- func AppendUsage(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, ...) error
- func ApplyScope(delivery agentkit.SessionID, scope SessionScope, userID string) agentkit.SessionID
- func BuildDeliverySessionID(platform, channel, thread, user string) agentkit.SessionID
- func ChannelKeyFromContext(ctx context.Context) string
- func ChannelKeyMatches(jobChannelKey, contextChannelKey string) bool
- func DeliveryWithUser(delivery agentkit.SessionID, userID string) agentkit.SessionID
- func EstimateLogicalChars(msg agentkit.ModelMessage) int
- func HydrateLocalAttachments(ctx context.Context, msgs []agentkit.ModelMessage, ws workspace.Service, ...) ([]agentkit.ModelMessage, error)
- func InterruptedToolResult(call agentkit.ToolCall) agentkit.ToolResult
- func LastAssistantText(events []agentkit.SessionEvent, seq agentkit.EventSeq) string
- func LatestEventSeq(events []agentkit.SessionEvent) agentkit.EventSeq
- func LatestSeq(ctx context.Context, s agentkit.Session) (agentkit.EventSeq, error)
- func NewCLISessionID() agentkit.SessionID
- func NewJSONL(cfg JSONLConfig) (agentkit.Session, error)
- func NewMemory(cfg MemoryConfig) (agentkit.Session, error)
- func NewSessionID(base agentkit.SessionID) agentkit.SessionID
- func NewStatic(_ StaticConfig, deps StaticDeps) (agentkit.SessionStore, error)
- func NewStore(cfg StoreConfig, deps StoreDeps) (agentkit.SessionStore, error)
- func ReadAllEvents(ctx context.Context, s agentkit.Session) ([]agentkit.SessionEvent, error)
- func RepeatedToolCalls(events []agentkit.SessionEvent, seq agentkit.EventSeq) int
- func RunStartSeq(events []agentkit.SessionEvent) agentkit.EventSeq
- func SanitizeModelMessageForStorage(msg agentkit.ModelMessage, maxTextBytes int) agentkit.ModelMessage
- func SlackSessionID(channelID, threadTS string) agentkit.SessionID
- func SlackSessionIDForScope(scope SessionScope, channelID, threadTS, userID string) agentkit.SessionID
- func StepCount(events []agentkit.SessionEvent, seq agentkit.EventSeq) int
- func SumLogicalCharsFromEvents(events []agentkit.SessionEvent, agentID agentkit.AgentID) int
- func TrimCompacted(s agentkit.Session, agentID agentkit.AgentID, beforeSeq agentkit.EventSeq)
- type ActiveSessionData
- type AgentBindData
- type AutoRetryEndData
- type AutoRetryStartData
- type CLICurrentStore
- type DeliveryParts
- type FileBacked
- type IncompleteTurn
- type IndexedMessage
- type JSONL
- func (s *JSONL) Append(ctx context.Context, event agentkit.SessionEvent) (agentkit.EventSeq, error)
- func (s *JSONL) DeriveMessages(ctx context.Context) ([]agentkit.ModelMessage, error)
- func (s *JSONL) FilePath() string
- func (s *JSONL) ID() agentkit.SessionID
- func (s *JSONL) LatestSeq() agentkit.EventSeq
- func (s *JSONL) Read(ctx context.Context, from agentkit.EventSeq) ([]agentkit.SessionEvent, error)
- type JSONLConfig
- type Memory
- func (s *Memory) Append(_ context.Context, event agentkit.SessionEvent) (agentkit.EventSeq, error)
- func (s *Memory) DeriveMessages(ctx context.Context) ([]agentkit.ModelMessage, error)
- func (s *Memory) ID() agentkit.SessionID
- func (s *Memory) LatestSeq() agentkit.EventSeq
- func (s *Memory) Read(_ context.Context, from agentkit.EventSeq) ([]agentkit.SessionEvent, error)
- type MemoryConfig
- type OverflowRecoveryData
- type RecoveryData
- type RunFinishData
- type SessionScope
- type StaticConfig
- type StaticDeps
- type StaticStore
- func (s *StaticStore) ActiveSession(_ context.Context, id agentkit.SessionID) (agentkit.SessionID, error)
- func (s *StaticStore) AgentBind(_ context.Context, id agentkit.SessionID) (agentkit.AgentID, error)
- func (s *StaticStore) Get(_ context.Context, id agentkit.SessionID) (agentkit.Session, error)
- func (s *StaticStore) SetActiveSession(_ context.Context, id, active agentkit.SessionID) error
- func (s *StaticStore) SetAgentBind(_ context.Context, id agentkit.SessionID, agent agentkit.AgentID) error
- type StepEndData
- type StepStartData
- type Store
- func (s *Store) ActiveSession(ctx context.Context, id agentkit.SessionID) (agentkit.SessionID, error)
- func (s *Store) AgentBind(ctx context.Context, id agentkit.SessionID) (agentkit.AgentID, error)
- func (s *Store) Commands() []agentkit.Command
- func (s *Store) Get(ctx context.Context, id agentkit.SessionID) (agentkit.Session, error)
- func (s *Store) ResolveCLICurrent(ctx context.Context) (agentkit.SessionID, error)
- func (s *Store) SetActiveSession(ctx context.Context, id, active agentkit.SessionID) error
- func (s *Store) SetAgentBind(ctx context.Context, id agentkit.SessionID, agent agentkit.AgentID) error
- func (s *Store) SetCLICurrent(ctx context.Context, id agentkit.SessionID) error
- type StoreConfig
- type StoreDeps
- type SubagentEndData
- type SubagentStartData
- type SummarizationRetryEndData
- type SummarizationRetryStartData
- type Todo
- type TodoUpdateData
- type TurnContinueData
- type TurnEndData
- type TurnStartData
- 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 CLICurrentLinkName = "cli_current.jsonl"
CLICurrentLinkName is a symlink in the session store dir pointing at the JSONL file CLI should attach to on the next start.
const DefaultCLISessionID = agentkit.SessionID("cli:default")
const DefaultMaxStoredTextBytes = 8192
DefaultMaxStoredTextBytes caps text persisted in session history.
const DefaultSessionScope = ScopeChannel
DefaultSessionScope is the runner default when sessionScope is unset.
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 message size on user/assistant events.
Variables ¶
This section is empty.
Functions ¶
func ActiveSessionEntryKey ¶ added in v0.1.6
func ActiveSessionEntryKey(platform string, delivery agentkit.SessionID, scope SessionScope, userID string) agentkit.SessionID
ActiveSessionEntryKey returns the stable session-store key used for /new active-session mapping. IM platforms use the effective id after sessionScope; chat-api keeps the per-conversation delivery id.
func AgentStoreSessionID ¶ added in v0.1.6
AgentStoreSessionID is the session file agents read and append to during a turn. Runner keeps KeySessionID at the collapsed effective id for locking and tenant workspace, and sets KeyStoreSessionID when a stable entry key maps to a distinct logical history.
Inside a subagent, KeySessionID already points at the child sub:… session. Ignore KeyStoreSessionID there so a parent chat-api mapping cannot redirect the child's turn lifecycle or recovery onto the parent's open delegate turn.
func AppendAutoRetryEnd ¶
func AppendAutoRetryStart ¶
func AppendCompaction ¶
func AppendMessage ¶
func AppendOverflowRecovery ¶
func AppendRunFinish ¶
func AppendSessionRecovery ¶
func AppendSkillLoad ¶
func AppendStepEnd ¶
func AppendStepStart ¶
func AppendSubagentEnd ¶
func AppendSubagentStart ¶
func AppendTodoUpdate ¶
func AppendToolCall ¶
func AppendToolResult ¶
func AppendTurnContinue ¶
func AppendTurnEnd ¶
func AppendTurnStart ¶
func AppendUsage ¶
func ApplyScope ¶ added in v0.1.3
ApplyScope derives the effective session id used for Loop locking, history, and permission pending. delivery is the platform-owned routing id; userID fills in a missing :u: segment when present on the event envelope.
func BuildDeliverySessionID ¶ added in v0.1.3
BuildDeliverySessionID is the canonical finest-grain id platforms should emit. Runner applies sessionScope to collapse it for scheduling and history.
Examples:
slack:C001 slack:C001:t:1712345678.9 slack:C001:t:1712345678.9:u:U456
func ChannelKeyFromContext ¶ added in v0.1.10
ChannelKeyFromContext derives the channel-scoped key for the current turn. It collapses delivery to channel scope so scheduled jobs can be isolated per IM channel.
func ChannelKeyMatches ¶ added in v0.1.10
ChannelKeyMatches reports whether a job belongs to the given channel key.
func DeliveryWithUser ¶ added in v0.1.3
DeliveryWithUser returns a delivery SessionID with the :u: segment set or replaced. Non-routable ids (cli:default, sub:...) are returned unchanged.
func EstimateLogicalChars ¶ added in v0.1.12
func EstimateLogicalChars(msg agentkit.ModelMessage) int
EstimateLogicalChars approximates model-visible size before session storage. Data URLs are counted as a small fixed slot because media is stripped on disk.
func HydrateLocalAttachments ¶ added in v0.1.12
func HydrateLocalAttachments(ctx context.Context, msgs []agentkit.ModelMessage, ws workspace.Service, maxImageBytes int) ([]agentkit.ModelMessage, error)
HydrateLocalAttachments reloads workspace images for LLM vision: attachment_ref on the latest user message, and read-tool image paths from the current tool batch since that user turn.
func InterruptedToolResult ¶
func InterruptedToolResult(call agentkit.ToolCall) agentkit.ToolResult
InterruptedToolResult is the stand-in result for a call that never ran to completion.
func LastAssistantText ¶
func LastAssistantText(events []agentkit.SessionEvent, seq agentkit.EventSeq) string
LastAssistantText returns the text of the most recent assistant message after seq. It is the fallback answer for a run that stopped without calling tool/finish, which is the common case for a child agent that was only asked a question.
func LatestEventSeq ¶
func LatestEventSeq(events []agentkit.SessionEvent) agentkit.EventSeq
func LatestSeq ¶ added in v0.1.9
LatestSeq returns the highest durable event sequence for the session.
func NewCLISessionID ¶
NewCLISessionID returns a fresh opaque CLI session id.
func NewJSONL ¶
func NewJSONL(cfg JSONLConfig) (agentkit.Session, error)
NewJSONL registers session/jsonl: Append-only JSONL event log for one session.
Best practices:
- Reopening a file resumes event sequence numbering, so seq stays unique across restarts.
func NewMemory ¶
func NewMemory(cfg MemoryConfig) (agentkit.Session, error)
NewMemory registers session/memory: Ephemeral in-memory session. Nothing survives the process.
func NewSessionID ¶ added in v0.1.6
NewSessionID returns a fresh logical session id derived from the current stable session key. CLI keeps its historic cli:<timestamp> format.
func NewStatic ¶
func NewStatic(_ StaticConfig, deps StaticDeps) (agentkit.SessionStore, error)
NewStatic registers session/static: Wrap one pre-built Session as a store that returns it for every id.
Best practices:
- For tests and single-session hosts; every session id maps to the same log.
func NewStore ¶
func NewStore(cfg StoreConfig, deps StoreDeps) (agentkit.SessionStore, error)
NewStore registers session/store: Resolve durable JSONL sessions by id; contributes /new and /session.
func ReadAllEvents ¶
func RepeatedToolCalls ¶
func RepeatedToolCalls(events []agentkit.SessionEvent, seq agentkit.EventSeq) int
RepeatedToolCalls returns how many times the most recent tool call signature repeats consecutively at the tail of the log, counting only calls after seq. A stuck agent calling the same tool with the same input is the cheapest stall signal available.
func RunStartSeq ¶
func RunStartSeq(events []agentkit.SessionEvent) agentkit.EventSeq
RunStartSeq returns the seq of the most recent inbound user message, which marks where the current run began. Continuations are recorded as turn/continue events rather than user/message events, so they never shift it.
func SanitizeModelMessageForStorage ¶ added in v0.1.12
func SanitizeModelMessageForStorage(msg agentkit.ModelMessage, maxTextBytes int) agentkit.ModelMessage
SanitizeModelMessageForStorage removes bulky media payloads and truncates long text before writing user/assistant messages to durable session history.
func SlackSessionID ¶
SlackSessionID builds a stable session key from Slack channel and optional thread timestamp. Use threadTS from event.ThreadTimeStamp; for top-level channel messages pass "".
func SlackSessionIDForScope ¶
func SlackSessionIDForScope(scope SessionScope, channelID, threadTS, userID string) agentkit.SessionID
SlackSessionIDForScope builds the effective session id for Slack components. Prefer ApplyScope(BuildDeliverySessionID(...), scope, userID) in new code; this helper remains for tests and direct agent invocations.
func StepCount ¶
func StepCount(events []agentkit.SessionEvent, seq agentkit.EventSeq) int
StepCount counts the steps completed after seq. Unlike turn/end's Steps field it is also available for a turn that failed partway through.
func SumLogicalCharsFromEvents ¶ added in v0.1.12
func SumLogicalCharsFromEvents(events []agentkit.SessionEvent, agentID agentkit.AgentID) int
SumLogicalCharsFromEvents totals logical message size for compaction estimates.
Types ¶
type ActiveSessionData ¶ added in v0.1.6
type AgentBindData ¶ added in v0.1.6
AgentBindData is stored in each session work dir as agent.json.
type AutoRetryEndData ¶
type AutoRetryStartData ¶
type CLICurrentStore ¶
type CLICurrentStore interface {
ResolveCLICurrent(ctx context.Context) (agentkit.SessionID, error)
SetCLICurrent(ctx context.Context, id agentkit.SessionID) error
}
CLICurrentStore tracks which CLI session is active across process restarts.
type DeliveryParts ¶ added in v0.1.5
type DeliveryParts struct {
Platform string
Channel string
Thread string
User string
Routable bool
}
DeliveryParts holds parsed segments of a platform delivery SessionID.
func ParseDelivery ¶ added in v0.1.5
func ParseDelivery(id agentkit.SessionID, fallbackUser string) DeliveryParts
ParseDelivery splits a delivery SessionID into routing segments. fallbackUser fills a missing :u: segment when present on the event envelope.
type FileBacked ¶
type FileBacked interface {
FilePath() string
}
FileBacked is implemented by sessions that persist to a file path.
type IncompleteTurn ¶
type IncompleteTurn struct {
TurnStartSeq agentkit.EventSeq
AgentID agentkit.AgentID
StepsStarted int
StepsEnded int
// OpenStep is the index of a step/start with no step/end, or -1 when the
// last step closed cleanly.
OpenStep int
// OrphanCalls are tool calls in the derived history that no tool result
// answers. Left alone they make the history unusable: providers reject an
// assistant message whose tool calls have no replies.
OrphanCalls []agentkit.ToolCall
}
IncompleteTurn describes a turn that never reached turn/end, which is what a crash, SIGKILL, or power loss leaves behind.
func ScanIncomplete ¶
func ScanIncomplete(events []agentkit.SessionEvent) *IncompleteTurn
ScanIncomplete reports the trailing unterminated turn, or nil when the log ends cleanly. Only the last turn can be incomplete: every earlier turn either wrote turn/end or was repaired on a previous startup.
type IndexedMessage ¶ added in v0.1.9
type IndexedMessage = compaction.IndexedMessage
IndexedMessage is a model-visible message with its primary source event seq.
func IndexMessagesForCompaction ¶ added in v0.1.9
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 JSONL ¶
type JSONL struct {
// contains filtered or unexported fields
}
JSONL persists session events as append-only JSON lines.
func (*JSONL) DeriveMessages ¶
type JSONLConfig ¶
type JSONLConfig struct {
// Path is the log file itself, not a directory.
Path string `json:"path"`
// ID is fixed session id.
ID agentkit.SessionID `json:"id"`
// MaxLoadedEvents limits non-compaction events kept in memory on load. Zero loads the full file.
MaxLoadedEvents int `json:"maxLoadedEvents"`
}
type Memory ¶
type Memory struct {
// contains filtered or unexported fields
}
Memory is an in-memory session backend for tests and ephemeral runs.
func (*Memory) DeriveMessages ¶
type MemoryConfig ¶
type OverflowRecoveryData ¶
type RecoveryData ¶
type RecoveryData struct {
TurnStartSeq agentkit.EventSeq `json:"turnStartSeq"`
Steps int `json:"steps"`
OrphanResults int `json:"orphanResults"`
ClosedStep int `json:"closedStep"`
Reason string `json:"reason"`
}
RecoveryData is the audit payload of a session/recovery event.
func RepairIncomplete ¶
func RepairIncomplete(ctx context.Context, s agentkit.Session, turn *IncompleteTurn) (RecoveryData, error)
RepairIncomplete makes an interrupted turn replayable and closes it: it answers every orphan tool call, ends the open step, writes turn/end, then records a session/recovery event for audit.
type RunFinishData ¶
type RunFinishData struct {
Status string `json:"status"`
Summary string `json:"summary,omitempty"`
}
RunFinishData is the payload of an EventRunFinish event: the agent's explicit statement that it is done, which is what stops an autonomous run.
func FinishAfter ¶
func FinishAfter(events []agentkit.SessionEvent, seq agentkit.EventSeq) *RunFinishData
FinishAfter returns the run/finish event recorded after seq, or nil when the agent has not declared completion since then. Callers pass the seq of the message that started the current run so a stale finish cannot end a new run.
type SessionScope ¶
type SessionScope string
SessionScope selects how delivery SessionIDs collapse for Loop scheduling and session history. It is configured on runner.config.sessionScope and is deliberately independent of the working directory: every scope below derives the same cap/tenant key, so a channel keeps one workdir no matter how finely its history is split.
const ( // ScopeChannel gives the whole channel a single session. Everyone in the // group shares one history and is told apart by per-message user // attribution, which is what makes "两个人在同一个群里接着聊" work. ScopeChannel SessionScope = "channel" // ScopeThread gives each thread its own session, with the channel's // top-level messages sharing one. This is the usual choice for a busy // channel where unrelated tasks run side by side. ScopeThread SessionScope = "thread" // ScopeUser gives each person their own session inside the channel: shared // working directory, private history. ScopeUser SessionScope = "user" )
func ParseScope ¶ added in v0.1.3
func ParseScope(raw string) SessionScope
ParseScope normalizes runner config. Unknown values fall back to channel scope.
type StaticConfig ¶
type StaticConfig struct{}
type StaticDeps ¶
type StaticStore ¶
type StaticStore struct {
// contains filtered or unexported fields
}
StaticStore returns one Session for matching IDs. Useful for CLI presets and tests where a single session instance is wired through pluginkit.
func NewStaticStore ¶
func NewStaticStore(sess agentkit.Session) *StaticStore
func (*StaticStore) ActiveSession ¶ added in v0.1.6
func (*StaticStore) SetActiveSession ¶ added in v0.1.6
func (*StaticStore) SetAgentBind ¶ added in v0.1.6
type StepEndData ¶
type StepEndData struct {
Step int `json:"step"`
}
type StepStartData ¶
type StepStartData struct {
Step int `json:"step"`
}
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store opens one JSONL session file per SessionID under Dir. Suitable for IM platforms where each channel/thread maps to a distinct session.
func (*Store) ActiveSession ¶ added in v0.1.6
func (*Store) ResolveCLICurrent ¶
ResolveCLICurrent returns the session id behind cli_current.jsonl, or DefaultCLISessionID when the link is missing. A missing link is also written so the default session file is discoverable without knowing the id format.
func (*Store) SetActiveSession ¶ added in v0.1.6
func (*Store) SetAgentBind ¶ added in v0.1.6
type StoreConfig ¶
type StoreConfig struct {
// Dir is root directory holding one file per session, resolved through the workspace.
Dir string `json:"dir"`
// MaxCachedSessions limits in-memory hot sessions (LRU). Zero keeps every opened session cached.
MaxCachedSessions int `json:"maxCachedSessions"`
// CacheIdleTTL evicts sessions unused for this duration (for example "30m"). Empty disables idle eviction.
CacheIdleTTL string `json:"cacheIdleTTL"`
// MaxLoadedEvents limits non-compaction events kept in memory per session on load. Zero loads the full file.
MaxLoadedEvents int `json:"maxLoadedEvents"`
}
type SubagentEndData ¶
type SubagentEndData struct {
Agent string `json:"agent"`
Session string `json:"session"`
Status string `json:"status"`
Summary string `json:"summary,omitempty"`
Steps int `json:"steps"`
Error string `json:"error,omitempty"`
}
SubagentEndData records the outcome of a delegation. Summary duplicates what the model sees in the tool result, on purpose: reading the parent log alone should be enough to reconstruct what came back.
type SubagentStartData ¶
type SubagentStartData struct {
Agent string `json:"agent"`
Session string `json:"session"`
Task string `json:"task"`
}
SubagentStartData records a delegation on the *parent* session. The child's own work lives in its own session; these two events are the audit trail linking the two logs together.
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.
func LatestTodos ¶
func LatestTodos(events []agentkit.SessionEvent) []Todo
LatestTodos returns the task list from the most recent todo/update event.
func PendingTodos ¶
PendingTodos filters LatestTodos down to entries that still need work.
type TodoUpdateData ¶
type TodoUpdateData struct {
Items []Todo `json:"items"`
}
TodoUpdateData is the payload of an EventTodoUpdate event. It carries the full list after the update so the latest event alone reconstructs the state.
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. Messages holds the text injected to keep the agent going; derive replays it as a user message, so this single event is both the audit record and the model-visible source.
type TurnEndData ¶
type TurnEndData struct {
Steps int `json:"steps"`
}
type TurnStartData ¶
type TurnStartData struct{}
type UsageData ¶
type UsageData struct {
InputTokens int `json:"inputTokens"`
OutputTokens int `json:"outputTokens"`
TotalTokens int `json:"totalTokens"`
}
UsageData records token accounting for one model step.
func LatestUsage ¶
func LatestUsage(events []agentkit.SessionEvent) UsageData
LatestUsage returns the most recent usage event. Its InputTokens is the measured prompt size at that step — the best available reading of how large the context currently is, already net of any earlier compaction.
func TotalUsage ¶
func TotalUsage(events []agentkit.SessionEvent, seq agentkit.EventSeq) UsageData
TotalUsage sums usage events recorded after seq.