Documentation
¶
Index ¶
- func BuildToolPool(cwd string, mainTools []agentcore.Tool) []agentcore.Tool
- func CodebotToolClassifier(name string) bool
- func FilterToolsForAgent(in []agentcore.Tool, opts FilterOpts) []agentcore.Tool
- func SessionMemorySeedFn(cwd string) func() (string, error)
- type AgentDefinition
- type AgentSource
- type BuildDeps
- type CacheStats
- type CompactionKind
- type CompactionResult
- type CompactionSnapshot
- type ContextBreakdown
- type ContextSuggestion
- type ErrorSnapshot
- type FilterOpts
- type ModelFactory
- type PlanModeSignal
- type ReminderSnapshot
- type RuntimeMetricsSnapshot
- type RuntimeReminderKind
- type Session
- func (s *Session) APIKey() string
- func (s *Session) Abort()
- func (s *Session) AbortSilent()
- func (s *Session) ApplySkillDelta(name string, delta skill.Delta) error
- func (s *Session) ApplySkillInvocation(result *skill.InvocationResult) error
- func (s *Session) BaseURL() string
- func (s *Session) CacheStats() CacheStats
- func (s *Session) ClearConversation()
- func (s *Session) Close()
- func (s *Session) Compact() (CompactionResult, error)
- func (s *Session) ContextBreakdown() ContextBreakdown
- func (s *Session) ContextSnapshot() (*agentcore.ContextSnapshot, bool)
- func (s *Session) ContextSuggestions() []ContextSuggestion
- func (s *Session) ContextUsage() *agentcore.ContextUsage
- func (s *Session) CostEstimate() (inputTokens, outputTokens int, cost float64)
- func (s *Session) CurrentSessionInfo() (storage.SessionInfo, error)
- func (s *Session) GenerateSuggestion(ctx context.Context) (string, error)
- func (s *Session) HandleOverflowRewrite(info agentctx.RewriteEvent)
- func (s *Session) HandleProjectedRewrite(info agentctx.RewriteEvent)
- func (s *Session) IsRunning() bool
- func (s *Session) LastAssistantText() string
- func (s *Session) LastCompaction() (CompactionSnapshot, bool)
- func (s *Session) LastReminder() (ReminderSnapshot, bool)
- func (s *Session) LastRunSummary() (agentcore.RunSummary, bool)
- func (s *Session) LastTurnOutcome() TurnOutcomeSnapshot
- func (s *Session) ListSessions() ([]storage.SessionInfo, error)
- func (s *Session) Messages() []agentcore.AgentMessage
- func (s *Session) ModelName() string
- func (s *Session) OverlayPrompt(key, text string)
- func (s *Session) PostSummaryRecoveryHook() agentctx.PostSummaryHook
- func (s *Session) Prompt(text string) error
- func (s *Session) PromptWithBlocks(blocks []agentcore.ContentBlock) error
- func (s *Session) Provider() string
- func (s *Session) RecentErrors(limit int) []ErrorSnapshot
- func (s *Session) RecentToolCalls(limit int) []ToolCallSnapshot
- func (s *Session) Registry() *provider.ModelRegistry
- func (s *Session) Reload()
- func (s *Session) ReplaceAllTools(tools []agentcore.Tool)
- func (s *Session) ReplaceMCPTools(tools []agentcore.Tool)
- func (s *Session) Reset() error
- func (s *Session) ResetTaskList() error
- func (s *Session) RestoreAllTools(extra ...agentcore.Tool)
- func (s *Session) RuntimeMetrics() RuntimeMetricsSnapshot
- func (s *Session) SessionID() string
- func (s *Session) SetBeforePrompt(fn func())
- func (s *Session) SetMCPInstructions(text string)
- func (s *Session) SetModel(prov, model string) error
- func (s *Session) SetPlanModeSignal(fn func() PlanModeSignal)
- func (s *Session) SetSkillCatalog(catalog *skill.Catalog)
- func (s *Session) SetTaskNotifyFn(fn storage.TaskNotifyFn)
- func (s *Session) SetThinkingLevel(level agentcore.ThinkingLevel)
- func (s *Session) SetTools(tools ...agentcore.Tool)
- func (s *Session) Settings() config.Resolved
- func (s *Session) SideQuestion(ctx context.Context, question string) (string, error)
- func (s *Session) SkillCatalog() *skill.Catalog
- func (s *Session) Skills() []skill.Spec
- func (s *Session) Steer(text string)
- func (s *Session) Subscribe(fn func(SessionEvent)) func()
- func (s *Session) SwitchSession(id string) error
- func (s *Session) TaskSnapshot() storage.TaskSnapshot
- func (s *Session) ToolsByName(names ...string) []agentcore.Tool
- func (s *Session) TotalTokens() int
- type SessionConfig
- type SessionEvent
- type SessionEventType
- type SessionMemory
- type ToolCallSnapshot
- type ToolTokenUsage
- type TurnOutcomeSnapshot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildToolPool ¶ added in v0.1.3
BuildToolPool returns a tool list suitable as input to FilterToolsForAgent. Read / write / edit are replaced with fresh instances sharing a sub-agent- local FileReadState so a read in a sub-agent cannot poison the parent's read-stamp cache (which would let the parent's next write of the same file silently skip its own read-before-write check). Other tools are passed through by reference — they are either stateless or already keyed by cwd.
Call this ONCE PER SUB-AGENT KIND. Two sub-agent kinds (e.g. explore and coder) must NOT share the returned slice: doing so re-introduces the same cross-pollination of read state that we created this function to prevent.
func CodebotToolClassifier ¶ added in v0.1.0
func FilterToolsForAgent ¶ added in v0.1.3
func FilterToolsForAgent(in []agentcore.Tool, opts FilterOpts) []agentcore.Tool
FilterToolsForAgent returns the subset of `in` that a sub-agent may use.
Checks per tool, in order:
- The `subagent` tool itself is dropped (recursive spawn guard, applied unconditionally — not configurable).
- MCP tools (mcp__ prefix) pass through iff AllowMCP, bypassing the allow/deny lists.
- allAgentDisallowed is dropped.
- customAgentDisallowed is dropped when !IsBuiltIn.
- ExtraDisallowed (per-agent) is dropped.
- When IsAsync, only asyncAgentAllowed passes; everything else is dropped.
func SessionMemorySeedFn ¶ added in v0.1.1
SessionMemorySeedFn returns a closure suitable for plugging into agentcore's SessionMemoryStrategy. The closure reads the project-scoped memory file on each compaction attempt and returns the empty string when the file is missing or still matches the initial template — both of which signal "no useful memory yet, fall through to LLM summarization".
Types ¶
type AgentDefinition ¶ added in v0.1.3
type AgentDefinition struct {
// Name is the unique identifier the LLM passes to the subagent tool.
// Must be non-empty and globally unique after merging — MergeAgents
// resolves name collisions by source precedence (user > project > builtin).
Name string
// Description is shown to the LLM in the subagent tool's schema enum
// description. Treat it like a docstring: it tells the model WHEN to
// invoke this agent, not what the agent does internally.
Description string
// SystemPrompt is the agent's system prompt. For built-ins it is a Go
// string literal; for file-loaded agents it is the markdown body that
// follows the frontmatter.
SystemPrompt string
// Tools is an allow-list of tool names. nil or {"*"} means "everything
// the filter rules allow"; otherwise the listed names are intersected
// with the filter output. Used by file-loaded agents to scope the
// surface further than the global filter does.
Tools []string
// DisallowedTools is a per-agent deny-list, applied AFTER the global
// rules. Mapped to FilterOpts.ExtraDisallowed at BuildConfig time.
DisallowedTools []string
// Model is "inherit" (use the parent's model), an explicit model name,
// or empty (defaults to inherit).
Model string
// MaxTurns caps the agent's loop. Zero means use the subagent default.
MaxTurns int
// Background, when true, marks the agent as one that should run async
// by default. The subagent tool can still override this per call via
// its `background` parameter.
Background bool
// Provenance — set by the loader, read by tooling that wants to point
// the user at a definition's origin (`/agents show explore` etc.).
Source AgentSource
BaseDir string // directory the agent was loaded from, or "builtin"
Filename string // file path within BaseDir, or "" for built-ins
}
AgentDefinition is codebot's spec layer for a sub-agent. It carries every piece of information needed to materialise a subagent.Config, plus provenance metadata used by callers, the UI, and `/agents` listings.
Three places construct AgentDefinitions:
- Built-in defaults (see builtinAgentDefinitions)
- agent_loader.LoadAgentsDir reading .codebot/agents/*.md frontmatter
- (Future) plugin contributions
All three feed MergeAgents and then BuildConfig in turn.
func BuiltinDefinitions ¶ added in v0.1.3
func BuiltinDefinitions(cwd string) []AgentDefinition
BuiltinDefinitions returns the three sub-agents that ship with codebot.
They use the same AgentDefinition shape that file-loaded agents use, so the bootstrap pipeline can treat builtin / project / user agents uniformly. Two practical consequences:
- A user can override `explore` by dropping their own .codebot/agents/explore.md into the project. The MergeAgents step picks up the later source by name.
- Built-ins go through the same Validate() and BuildConfig() pipeline as everything else, so a typo in the prompt loader can't produce a different runtime shape from a typo in a Go literal.
If you find yourself adding a fourth built-in, ask first whether it should be a built-in at all — a project-level agent in .codebot/agents/ is usually the more honest place for codebase-specific roles.
func LoadAgentsDir ¶ added in v0.1.3
func LoadAgentsDir(dir string, source AgentSource) (defs []AgentDefinition, errs []error)
LoadAgentsDir reads every *.md file under dir and parses them as agent definitions. Files that fail to parse are reported but do not abort the load — a single broken file should not block the user from using the rest of their agent library. The returned errors slice has one entry per broken file; the returned definitions slice excludes those files.
dir is allowed to not exist (returns nil, nil) — the loader is happy to be called speculatively against directories that haven't been created yet.
func MergeAgents ¶ added in v0.1.3
func MergeAgents(groups ...[]AgentDefinition) []AgentDefinition
MergeAgents combines definitions from multiple sources, with later groups overriding earlier ones by name. The expected call order is:
MergeAgents(builtin, project, user)
so a user file overrides a project file overrides a built-in. This matches the trust-vs-customisability ordering: ship sensible defaults, let teams override per-project, let individuals override per-machine.
IMPORTANT: override is WHOLE-DEFINITION replacement, not field-level merge. A user file that re-declares `explore` but omits `disallowedTools` will drop the read-only restriction the built-in version had. This is intentional — field-level merging is hard to predict ("did I inherit X from project or builtin?") and we'd rather force the user to be explicit than make them debug surprising privilege escalations. Document this in any user-facing agent-authoring guide.
Empty names are skipped silently — Validate() should catch them upstream; MergeAgents is the wrong place to surface schema errors.
func (*AgentDefinition) BuildConfig ¶ added in v0.1.3
func (d *AgentDefinition) BuildConfig(deps BuildDeps, ctxFactory func(agentcore.ChatModel) agentcore.ContextManager) (subagent.Config, error)
BuildConfig converts an AgentDefinition into a subagent.Config ready to be passed to subagent.New(...). It is responsible for:
- Resolving the model name to a ChatModel (inherit vs explicit).
- Calling BuildToolPool to give the sub-agent its own read/write/edit instances (independent FileReadState — see Stage 2 review).
- Running FilterToolsForAgent with rules derived from Source/Background.
- Applying AgentDefinition.Tools as a post-filter allow-list when set.
- Wiring a fresh ContextManager via the factory the caller supplied.
BuildConfig is pure with respect to BuildDeps: calling it twice with the same definition and deps yields independent subagent.Config values (which is what the per-agent FileReadState invariant requires).
func (*AgentDefinition) Validate ¶ added in v0.1.3
func (d *AgentDefinition) Validate() error
Validate checks the structural invariants we can verify without the world — required fields present, tool-name strings non-empty, etc. Returns the first error encountered. Loader call sites must invoke this after parsing.
type AgentSource ¶ added in v0.1.3
type AgentSource string
AgentSource is the provenance of an AgentDefinition. It maps to a trust tier: built-in is code-controlled and trusted; project lives in version control (team-reviewed); user is per-machine and the least scrutinised.
The source is consulted at tool-pool assembly time — see FilterToolsForAgent's IsBuiltIn flag — so adding a new source means deciding whether sub-agents loaded from it should be subject to customAgentDisallowed.
const ( SourceBuiltin AgentSource = "builtin" SourceProject AgentSource = "project" // .codebot/agents/ SourceUser AgentSource = "user" // ~/.codebot/agents/ )
func (AgentSource) IsBuiltIn ¶ added in v0.1.3
func (s AgentSource) IsBuiltIn() bool
IsBuiltIn reports whether the source qualifies for the built-in trust tier in tool filtering. Today only SourceBuiltin does; SourceProject is kept out because a project agent file changes via PR review but executes on every collaborator's machine — different threat model from code that shipped with the binary.
type BuildDeps ¶ added in v0.1.3
type BuildDeps struct {
// Cwd is the workspace root. Used by sub-agent prompts and by the
// per-agent tool pool when constructing scoped read/write/edit
// instances.
Cwd string
// MainTools is the parent agent's tool list AS HANDED TO buildSubAgentTool
// — that is, before the subagent and Skill tools are appended. Every
// AgentDefinition gets this list re-pooled into independent instances
// inside BuildConfig (see BuildToolPool's contract).
MainTools []agentcore.Tool
// DefaultModel is the parent agent's chat model, used when the
// AgentDefinition either omits Model or sets it to "inherit".
DefaultModel agentcore.ChatModel
// ContextWindow is the parent's context window size, threaded to the
// per-agent ContextManager so summary thresholds align with the model
// in use.
ContextWindow int
// ResolveModel maps an explicit model name from AgentDefinition.Model
// to a ChatModel. May be nil when the build pipeline doesn't support
// per-agent model override; in that case any explicit Model that
// isn't "inherit" produces an error from BuildConfig.
ResolveModel func(name string) (agentcore.ChatModel, error)
}
BuildDeps carries the runtime context BuildConfig needs to materialise an AgentDefinition into a subagent.Config. It is constructed once per call to buildSubAgentTool and reused across every definition.
Why a struct instead of positional args: BuildConfig is called from bootstrap, and bootstrap already has eight parameters threading through subagent assembly. A struct lets us add fields (e.g. eventual MCP server inheritance) without breaking call sites.
type CacheStats ¶ added in v0.1.3
type CacheStats struct {
Input int
ReadTokens int
WriteTokens int
HitRate float64
SavedUSD float64
}
CacheStats reports session-cumulative prompt cache metrics. Input includes CacheRead per litellm convention; HitRate is CacheRead / Input. SavedUSD estimates the dollars saved by serving CacheRead tokens at the cache-read rate instead of the full input rate.
type CompactionKind ¶ added in v0.1.0
type CompactionKind string
const ( CompactionKindMicro CompactionKind = "micro" CompactionKindFull CompactionKind = "full" CompactionKindTrim CompactionKind = "trim" CompactionKindPrune CompactionKind = "prune" )
type CompactionResult ¶ added in v0.0.2
type CompactionSnapshot ¶ added in v0.1.0
type ContextBreakdown ¶ added in v0.1.0
type ContextBreakdown struct {
UserText int
AssistantText int
ToolCalls int
ToolResults int
Summaries int
Images int
Total int
ContextWindow int
// TopTools lists the heaviest tools by total (call + result) tokens.
TopTools []ToolTokenUsage
}
ContextBreakdown reports per-category token distribution in the conversation.
type ContextSuggestion ¶ added in v0.1.0
type ContextSuggestion struct {
Severity string // "warning" or "info"
Message string
Savings int // estimated token savings, 0 if unknown
}
ContextSuggestion is an actionable recommendation to reduce context usage.
type ErrorSnapshot ¶ added in v0.1.0
type FilterOpts ¶ added in v0.1.3
type FilterOpts struct {
// IsBuiltIn is true when the agent is defined in code, false when loaded
// from a user-controlled source (.codebot/agents/, plugins).
IsBuiltIn bool
// IsAsync is true for background-mode runs. Async agents cannot prompt
// the user, so they are restricted to the asyncAgentAllowed list.
IsAsync bool
// AllowMCP controls whether MCP tools (mcp__*) pass through. Defaults
// false — call sites that want MCP must opt in.
AllowMCP bool
// ExtraDisallowed is a per-agent denylist applied on top of the global
// rules. Used by built-in agents to scope themselves further (e.g. the
// explore agent excludes write/edit/bash to stay read-only).
ExtraDisallowed []string
}
FilterOpts controls how FilterToolsForAgent selects tools for a sub-agent.
type ModelFactory ¶
ModelFactory creates a chat model instance for a provider/model tuple.
type PlanModeSignal ¶ added in v0.1.3
PlanModeSignal describes the plan-mode state observed at the moment the runtime polls before queueing a per-prompt reminder. Three distinct situations need different behavior:
- Active=true: plan mode is on; emit the sparse "still read-only" reminder on its 5-turn cadence (PlanFilePath gives the writable plan file).
- JustCancelled=true: plan mode was cancelled via /plan cancel since the last poll; emit a one-shot "you have exited plan mode" reminder so the model knows the MUST-NOT rules buried in the EnterPlanMode tool_result no longer apply. Mirrors CC's needsPlanModeExitAttachment flag (refer/claude-code-src/utils/attachments.ts:1252).
- All zero: plan mode is off; no reminder needed.
Active and JustCancelled are mutually exclusive — the producer (plan.Manager) guarantees that. JustCancelled is consumed on read: a second poll without a fresh Cancel() returns the zero value.
type ReminderSnapshot ¶ added in v0.1.0
type ReminderSnapshot struct {
Kind RuntimeReminderKind
Mode string
Timestamp time.Time
}
type RuntimeMetricsSnapshot ¶ added in v0.1.0
type RuntimeMetricsSnapshot struct {
ReminderTotal int
ReminderByKind map[RuntimeReminderKind]int
CompactionTotal int
CompactionChanged int
CompactionSaved int
CompactionByKind map[CompactionKind]int
CompactionSavedByKind map[CompactionKind]int
ErrorTotal int
ErrorByCategory map[diag.Category]int
}
type RuntimeReminderKind ¶ added in v0.1.0
type RuntimeReminderKind string
const ( ReminderRepeatToolCall RuntimeReminderKind = "repeat_tool_call" ReminderPostStopValidation RuntimeReminderKind = "post_stop_validation" ReminderSkillPaths RuntimeReminderKind = "skill_paths" ReminderTaskManagement RuntimeReminderKind = "task_management" ReminderPlanMode RuntimeReminderKind = "plan_mode" )
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session is the business-logic core that wraps Agent + session persistence. It is independent of any UI framework and drives interactive, print, and RPC modes.
func NewSession ¶
func NewSession(cfg SessionConfig) *Session
NewSession creates a Session and wires auto-persist to the agent.
func (*Session) AbortSilent ¶
func (s *Session) AbortSilent()
func (*Session) ApplySkillDelta ¶ added in v0.1.0
func (*Session) ApplySkillInvocation ¶ added in v0.1.0
func (s *Session) ApplySkillInvocation(result *skill.InvocationResult) error
func (*Session) CacheStats ¶ added in v0.1.3
func (s *Session) CacheStats() CacheStats
func (*Session) ClearConversation ¶
func (s *Session) ClearConversation()
func (*Session) Compact ¶
func (s *Session) Compact() (CompactionResult, error)
func (*Session) ContextBreakdown ¶ added in v0.1.0
func (s *Session) ContextBreakdown() ContextBreakdown
ContextBreakdown computes a per-category token breakdown of the current conversation messages. It does NOT include system prompt or tool definitions.
func (*Session) ContextSnapshot ¶ added in v0.1.0
func (s *Session) ContextSnapshot() (*agentcore.ContextSnapshot, bool)
func (*Session) ContextSuggestions ¶ added in v0.1.0
func (s *Session) ContextSuggestions() []ContextSuggestion
ContextSuggestions generates actionable suggestions based on context usage and the message breakdown.
func (*Session) ContextUsage ¶
func (s *Session) ContextUsage() *agentcore.ContextUsage
func (*Session) CostEstimate ¶
func (*Session) CurrentSessionInfo ¶
func (s *Session) CurrentSessionInfo() (storage.SessionInfo, error)
func (*Session) GenerateSuggestion ¶ added in v0.0.4
GenerateSuggestion calls the current model with a condensed conversation history plus a suggestion prompt to predict the user's next input. Returns "" when no suggestion is available (first turn, no model, etc.).
func (*Session) HandleOverflowRewrite ¶ added in v0.1.0
func (s *Session) HandleOverflowRewrite(info agentctx.RewriteEvent)
func (*Session) HandleProjectedRewrite ¶ added in v0.1.0
func (s *Session) HandleProjectedRewrite(info agentctx.RewriteEvent)
func (*Session) LastAssistantText ¶
func (*Session) LastCompaction ¶ added in v0.1.0
func (s *Session) LastCompaction() (CompactionSnapshot, bool)
func (*Session) LastReminder ¶ added in v0.1.0
func (s *Session) LastReminder() (ReminderSnapshot, bool)
func (*Session) LastRunSummary ¶ added in v0.1.0
func (s *Session) LastRunSummary() (agentcore.RunSummary, bool)
func (*Session) LastTurnOutcome ¶ added in v0.1.0
func (s *Session) LastTurnOutcome() TurnOutcomeSnapshot
func (*Session) ListSessions ¶
func (s *Session) ListSessions() ([]storage.SessionInfo, error)
func (*Session) Messages ¶ added in v0.0.2
func (s *Session) Messages() []agentcore.AgentMessage
Messages returns the current agent message history.
func (*Session) OverlayPrompt ¶ added in v0.1.1
OverlayPrompt registers or removes a named instructions overlay. Pass empty text to remove. Overlays are rendered in insertion order.
func (*Session) PostSummaryRecoveryHook ¶ added in v0.1.0
func (s *Session) PostSummaryRecoveryHook() agentctx.PostSummaryHook
func (*Session) PromptWithBlocks ¶
func (s *Session) PromptWithBlocks(blocks []agentcore.ContentBlock) error
func (*Session) RecentErrors ¶ added in v0.1.0
func (s *Session) RecentErrors(limit int) []ErrorSnapshot
func (*Session) RecentToolCalls ¶ added in v0.1.0
func (s *Session) RecentToolCalls(limit int) []ToolCallSnapshot
func (*Session) Registry ¶
func (s *Session) Registry() *provider.ModelRegistry
func (*Session) ReplaceAllTools ¶
func (*Session) ReplaceMCPTools ¶ added in v0.1.0
func (*Session) Reset ¶ added in v0.1.1
Reset closes the current session log and starts a fresh session in the same cwd. The in-memory conversation and harness state are cleared; the previous file is flushed.
func (*Session) ResetTaskList ¶ added in v0.1.0
func (*Session) RestoreAllTools ¶
func (*Session) RuntimeMetrics ¶ added in v0.1.0
func (s *Session) RuntimeMetrics() RuntimeMetricsSnapshot
func (*Session) SetBeforePrompt ¶
func (s *Session) SetBeforePrompt(fn func())
func (*Session) SetMCPInstructions ¶ added in v0.1.0
func (*Session) SetPlanModeSignal ¶ added in v0.1.3
func (s *Session) SetPlanModeSignal(fn func() PlanModeSignal)
SetPlanModeSignal registers a callback the runtime polls before every user prompt to decide whether to queue a plan-mode reminder. plan.Manager wires this so the reminder cadence stays driven by the actual plan-mode state rather than a side-channel boolean.
func (*Session) SetSkillCatalog ¶ added in v0.1.0
func (*Session) SetTaskNotifyFn ¶ added in v0.1.0
func (s *Session) SetTaskNotifyFn(fn storage.TaskNotifyFn)
func (*Session) SetThinkingLevel ¶
func (s *Session) SetThinkingLevel(level agentcore.ThinkingLevel)
func (*Session) SideQuestion ¶ added in v0.0.4
SideQuestion sends a one-shot question to the current model using the full conversation context but without tool definitions or conversation history mutation. The answer is ephemeral — it never enters the session store. This powers the /btw side-chain Q&A feature.
func (*Session) SkillCatalog ¶ added in v0.1.0
func (*Session) Subscribe ¶
func (s *Session) Subscribe(fn func(SessionEvent)) func()
func (*Session) SwitchSession ¶
func (*Session) TaskSnapshot ¶ added in v0.1.0
func (s *Session) TaskSnapshot() storage.TaskSnapshot
func (*Session) TotalTokens ¶
type SessionConfig ¶
type SessionConfig struct {
Agent *agentcore.Agent
ContextManager agentcore.ContextManager
Store *storage.Store
Manager *storage.Manager
Registry *provider.ModelRegistry
Settings config.Resolved
Cwd string
TaskStore *storage.TaskStore
// CreateModel allows tests/integrations to override model construction.
// Defaults to provider.CreateModel when nil.
CreateModel ModelFactory
// LazyPersist buffers user messages and flushes them only when
// an assistant response arrives. Disabled by default for safety.
LazyPersist bool
// ChatModel is the active ChatModel reference.
ChatModel agentcore.ChatModel
// HookRunner fires lifecycle hooks (notification, etc.). Nil when no hooks configured.
HookRunner *hooks.Runner
// Tools is the full set of tools registered with the agent.
// Used by ToolsByName / RestoreAllTools for plan mode filtering.
Tools []agentcore.Tool
// ContextFiles holds loaded context files for dynamic system prompt rebuilding.
// When tools change the prompt is regenerated from these inputs.
ContextFiles config.ContextFiles
// Skills holds loaded skills for system prompt injection and /skill: commands.
Skills []skill.Spec
// SkillCatalog provides indexed skill lookup and reload support.
SkillCatalog *skill.Catalog
// SkillUsage persists cross-session usage statistics for prompt ordering.
SkillUsage *skill.UsageTracker
// DeferredToolsPreamble is injected as the first user message (once).
DeferredToolsPreamble string
// Reminders are <system-reminder> fragments prepended to each user message.
Reminders []string
// PreambleInjected indicates the preamble was already in conversation history (resume).
PreambleInjected bool
// SkillAllowsSetter updates temporary tool allows for the active skill.
SkillAllowsSetter func([]string)
// FileReadState records read timestamps consumed by write/edit Validators.
// Held on the Session so Clear / Reset / SwitchSession can drop stale
// stamps — otherwise the LLM may write based on stamps from a read it
// no longer has in its conversation history.
FileReadState *agenttools.FileReadState
// FrozenIdentity / FrozenInstructions are the process-stable parts of the
// system prompt (block 1 + block 2). Computed once at assembly time and
// reused on every rebuild — never recomputed during the session.
// See config.BuildFrozenSystemParts.
FrozenIdentity string
FrozenInstructions string
// InitialMCPOverlay seeds the mcp overlay when the assembly already knows
// the MCP instructions (e.g. MCP managers that connect synchronously).
// Written directly into the overlay store without triggering a rebuild.
InitialMCPOverlay string
}
SessionConfig configures a new Session.
type SessionEvent ¶
type SessionEvent struct {
Type SessionEventType
AgentEvent *agentcore.Event
// Session-level fields (populated based on Type)
ModelName string
Provider string
Level agentcore.ThinkingLevel
SessionID string
Error error
Reminder string
ReminderKind RuntimeReminderKind
// Retry fields (populated for SEAutoRetryStart / SEAutoRetryEnd)
RetryAttempt int
RetryMax int
RetryDelay time.Duration
RetrySuccess bool
// Compaction reason: "overflow" or "threshold"
CompactionReason string
CompactionKind CompactionKind
CompactionStrategy string
CompactionChanged bool
TokensBefore int
TokensAfter int
CompactedCount int
KeptCount int
SplitTurn bool
}
SessionEvent extends agent events with session-level metadata. When Type == SEAgentEvent, AgentEvent is non-nil.
type SessionEventType ¶
type SessionEventType string
SessionEventType identifies a session-level event.
const ( // SEAgentEvent wraps an agentcore.Event transparently. SEAgentEvent SessionEventType = "agent_event" // Session lifecycle events SEAutoCompactionStart SessionEventType = "auto_compaction_start" SEAutoCompactionEnd SessionEventType = "auto_compaction_end" SEAutoRetryStart SessionEventType = "auto_retry_start" SEAutoRetryEnd SessionEventType = "auto_retry_end" SEModelChanged SessionEventType = "model_changed" SEThinkingChanged SessionEventType = "thinking_changed" SESessionSwitched SessionEventType = "session_switched" SERuntimeReminder SessionEventType = "runtime_reminder" SEError SessionEventType = "session_error" )
type SessionMemory ¶ added in v0.1.1
SessionMemory is the on-disk shape of a memory file. We write the body as plain markdown (no frontmatter) so the file is readable and editable by a human. UpdatedAt comes from the filesystem mtime, not a stored field.
type ToolCallSnapshot ¶ added in v0.1.0
type ToolTokenUsage ¶ added in v0.1.0
ToolTokenUsage tracks token consumption for a single tool.