Documentation
¶
Overview ¶
Package assistant manages AI conversations with configurable models, providers, and tool execution.
Index ¶
- Variables
- type Assistant
- func (a *Assistant) AgentState() slash.AgentState
- func (a *Assistant) AutoEnabled() bool
- func (a *Assistant) AutoSave() error
- func (a *Assistant) Builder() *conversation.Builder
- func (a *Assistant) CacheModelList(v []slash.ProviderModels)
- func (a *Assistant) CallRewrite(ctx context.Context, resolved FeatureResolution, thinkingContent string) (string, error)
- func (a *Assistant) Cfg() config.Config
- func (a *Assistant) CheckGuardrail(ctx context.Context, scope, toolName, content string) (bool, string, error)
- func (a *Assistant) CheckInput(ctx context.Context, text string) (est int, msg string)
- func (a *Assistant) CheckPaths(read, write []string) error
- func (a *Assistant) CheckResult(ctx context.Context, output string) (est int, rejected bool, msg string)
- func (a *Assistant) ClearModelListCache()
- func (a *Assistant) Close()
- func (a *Assistant) Compact(ctx context.Context, force bool) error
- func (a *Assistant) CompactChunks(ctx context.Context, provider providers.Provider, mdl model.Model, ...) (string, error)
- func (a *Assistant) CompactOnce(ctx context.Context, provider providers.Provider, mdl model.Model, ...) (string, error)
- func (a *Assistant) CompactWith(ctx context.Context, force bool, keepLast int) error
- func (a *Assistant) CompactWithKeepLast(ctx context.Context, keepLast int) error
- func (a *Assistant) ContextLength() model.ContextLength
- func (a *Assistant) CycleThink() error
- func (a *Assistant) DisplayHints() ui.DisplayHints
- func (a *Assistant) Done() <-chan struct{}
- func (a *Assistant) DoneEnabled() bool
- func (a *Assistant) EmitAll()
- func (a *Assistant) EmitDisplayHints()
- func (a *Assistant) EmitStatus()
- func (a *Assistant) EnableAsk(cb func(context.Context, ask.Request) (string, error)) error
- func (a *Assistant) EstimateTokens(_ context.Context) int
- func (a *Assistant) EventChan() chan<- ui.Event
- func (a *Assistant) ExecuteSubTool(ctx context.Context, toolName string, args map[string]any) (string, error)
- func (a *Assistant) FilterTools(filter tool.Filter) error
- func (a *Assistant) GenerateTitle(ctx context.Context) (string, error)
- func (a *Assistant) HasCompactor() bool
- func (a *Assistant) InjectorRegistry() *injector.Registry
- func (a *Assistant) InjectorState() *injector.State
- func (a *Assistant) IsToolParallel(name string) bool
- func (a *Assistant) Loop(ctx context.Context, inputs <-chan ui.UserInput, actions <-chan ui.UserAction, ...) error
- func (a *Assistant) MCPSessions() []*mcp.Session
- func (a *Assistant) MaxSteps() int
- func (a *Assistant) MergeFeatures(overlay config.Features) error
- func (a *Assistant) ModelListCache() []slash.ProviderModels
- func (a *Assistant) NextAgent() error
- func (a *Assistant) NextMode() error
- func (a *Assistant) PathChecker() subagent.PathChecker
- func (a *Assistant) Paths() config.Paths
- func (a *Assistant) PluginSummary() string
- func (a *Assistant) ProcessInput(ctx context.Context, input string) error
- func (a *Assistant) ReadBeforePolicy() tool.ReadBeforePolicy
- func (a *Assistant) RecoverCompaction(ctx context.Context, keepLast int) error
- func (a *Assistant) RegisterMCPSession(s *mcp.Session) error
- func (a *Assistant) RegisterMCPTools(sessions []*mcp.Session)
- func (a *Assistant) Reload(ctx context.Context) error
- func (a *Assistant) RequestExit()
- func (a *Assistant) ResetTokens()
- func (a *Assistant) ResizeContext(size int) error
- func (a *Assistant) ResolveAgent(ctx context.Context, cfg FeatureAgentConfig) (FeatureResolution, error)
- func (a *Assistant) ResolveCompaction(ctx context.Context) (FeatureResolution, error)
- func (a *Assistant) ResolveGuardrail(ctx context.Context, scope string) (FeatureResolution, error)
- func (a *Assistant) ResolveModel(ctx context.Context, label string, ag *agent.Agent, cache **model.Model) (model.Model, error)
- func (a *Assistant) ResolvedModel() model.Model
- func (a *Assistant) ResumeSession(ctx context.Context, sess *session.Session) []string
- func (a *Assistant) RewriteThinking(ctx context.Context, keepLast, tokenThreshold int) error
- func (a *Assistant) RunSubagent(ctx context.Context, agentName, prompt string) (subagent.Result, error)
- func (a *Assistant) Runtime() *config.Runtime
- func (a *Assistant) SandboxDisplay() string
- func (a *Assistant) SandboxEnabled() bool
- func (a *Assistant) SandboxRequested() bool
- func (a *Assistant) Send(event ui.Event)
- func (a *Assistant) SessionManager() *session.Manager
- func (a *Assistant) SessionMeta() session.Meta
- func (a *Assistant) SessionStats() *stats.Stats
- func (a *Assistant) SetAuto(val bool)
- func (a *Assistant) SetDone(val bool) error
- func (a *Assistant) SetNoop(p providers.Provider)
- func (a *Assistant) SetReadBeforePolicy(p tool.ReadBeforePolicy) error
- func (a *Assistant) SetSandbox(enabled bool) error
- func (a *Assistant) SetThink(t thinking.Value) error
- func (a *Assistant) SetVerbose(val bool)
- func (a *Assistant) SetWorkDir(wd string) error
- func (a *Assistant) ShouldCheck(toolName string) bool
- func (a *Assistant) ShouldCompact() bool
- func (a *Assistant) ShouldContinue() bool
- func (a *Assistant) ShouldTrim() bool
- func (a *Assistant) SnapshotManager() *snapshot.Manager
- func (a *Assistant) Status() ui.Status
- func (a *Assistant) StripThinking(ctx context.Context, keepLast, tokenThreshold int)
- func (a *Assistant) SwitchAgent(name, reason string) error
- func (a *Assistant) SwitchMode(mode string) error
- func (a *Assistant) SwitchModel(ctx context.Context, providerName, modelName string) error
- func (a *Assistant) TemplateData() config.TemplateData
- func (a *Assistant) TemplateVars() map[string]string
- func (a *Assistant) TodoList() *todo.List
- func (a *Assistant) ToggleAuto()
- func (a *Assistant) ToggleSandbox() error
- func (a *Assistant) ToggleThink() error
- func (a *Assistant) ToggleVerbose()
- func (a *Assistant) Tokens() int
- func (a *Assistant) ToolPolicy() *config.ToolPolicy
- func (a *Assistant) Track(name string, args map[string]any, result, toolErr string, ...)
- func (a *Assistant) TrimSynthetics()
- func (a *Assistant) Verbose() bool
- func (a *Assistant) WireEstimation()
- func (a *Assistant) WorkDir() string
- type FeatureAgentConfig
- type FeatureResolution
- type Params
- type SlashHandler
Constants ¶
This section is empty.
Variables ¶
var ErrCompactionConfig = errors.New("compaction misconfigured")
ErrCompactionConfig indicates a configuration error that will never succeed on retry.
var ErrCompactionExhausted = errors.New("compaction recovery exhausted")
ErrCompactionExhausted indicates all compaction recovery attempts failed.
var ErrMaxSteps = errors.New("maximum steps exceeded")
ErrMaxSteps indicates the assistant exceeded its configured step limit.
var ErrTokenBudget = errors.New("token budget exceeded")
ErrTokenBudget indicates the assistant exceeded its cumulative token budget.
Functions ¶
This section is empty.
Types ¶
type Assistant ¶
type Assistant struct {
// contains filtered or unexported fields
}
Assistant orchestrates the conversation loop, tool execution, compaction, and state management. Fields are grouped into inner structs by lifecycle:
loopState — ephemeral, reset at the start of each processInputs() call.
Tracks per-turn concerns: iteration count, tool history, patch counts.
resolvedState — derived from config + agent + mode. Invalidated by rebuildState(),
which is called after any mutation (SetAgent, SetMode, SetModel,
ToggleSandbox, /reload, etc.). Contains: resolved model, sandbox,
tool policy, hooks, guardrail model caches, prompt template.
Note: model is intentionally preserved across rebuildState() —
only SetAgent() and SetModel() clear it.
sessionState — persistent across turns. Session manager, stats, cumulative usage,
dirty flag, session-scoped approvals. Only reset on session clear.
streamState — streaming coordination. Active flag, pending messages, done channel,
cancel func. Reset between streaming turns.
toolState — tool infrastructure. Plugin cache, injector registry, LLM estimator,
LSP manager, MCP sessions, snapshot manager, loaded deferred tools.
Rebuilt by rebuildState() for tool list; plugin cache persists.
toggleState — runtime toggles (verbose, auto, done, exit, sandbox).
Mutated by Set*/Toggle* methods, persisted across turns.
tokenState — per-turn token tracking. Accumulates during a turn, reset next turn.
rebuildState() must be called after any mutation that affects: agent, mode, model, thinking, sandbox, tool filters, loaded tools, MCP connections, or feature overrides. It rebuilds: tool list, prompt template, sandbox config, guardrail state, hook config, and invalidates all 5 feature model caches (compact, title, thinking, guardrail×2).
func New ¶
New creates a fully-wired Assistant. All dependencies are provided at construction — no post-construction field assignment needed.
func (*Assistant) AgentState ¶
func (a *Assistant) AgentState() slash.AgentState
AgentState returns a snapshot of the agent's current runtime state. Each call returns a fresh snapshot reflecting any mutations since the last call.
func (*Assistant) AutoEnabled ¶
AutoEnabled returns whether auto mode is active.
func (*Assistant) AutoSave ¶
AutoSave persists the current session state without title generation. Safe to call during shutdown (no LLM calls).
func (*Assistant) Builder ¶
func (a *Assistant) Builder() *conversation.Builder
Builder returns the conversation builder.
func (*Assistant) CacheModelList ¶
func (a *Assistant) CacheModelList(v []slash.ProviderModels)
CacheModelList stores the model list cache.
func (*Assistant) CallRewrite ¶
func (a *Assistant) CallRewrite( ctx context.Context, resolved FeatureResolution, thinkingContent string, ) (string, error)
CallRewrite makes a single LLM call to rewrite one thinking block.
func (*Assistant) CheckGuardrail ¶
func (a *Assistant) CheckGuardrail(ctx context.Context, scope, toolName, content string) (bool, string, error)
CheckGuardrail runs a guardrail check for the given scope/content. Returns (blocked, raw response, error). Short-circuits if mode=="" or scope not active. For tool_calls: also checks ShouldCheck before calling the model.
func (*Assistant) CheckInput ¶
CheckInput estimates user input and rejects it if adding it would push context usage above the configured percentage. Returns the token estimate (always computed) and a rejection message ("" if accepted).
func (*Assistant) CheckPaths ¶
CheckPaths validates that all paths a tool will access are allowed by the sandbox.
func (*Assistant) CheckResult ¶
func (a *Assistant) CheckResult(ctx context.Context, output string) (est int, rejected bool, msg string)
CheckResult estimates the tool result and rejects it if it exceeds the configured limit. In "tokens" mode, rejects when the result alone exceeds Result.MaxTokens. In "percentage" mode, rejects when adding the result would push context usage above Result.MaxPercentage. Returns the token estimate (always computed), whether the result was rejected, and the rejection message.
func (*Assistant) ClearModelListCache ¶
func (a *Assistant) ClearModelListCache()
ClearModelListCache invalidates the cached model list.
func (*Assistant) Close ¶
func (a *Assistant) Close()
Close releases all resources held by the assistant.
func (*Assistant) Compact ¶
Compact performs context compaction using the configured KeepLastMessages. When force is true (explicit /compact or emergency), KeepLastMessages is clamped to what's actually possible so compaction can proceed with fewer message.
func (*Assistant) CompactChunks ¶
func (a *Assistant) CompactChunks( ctx context.Context, provider providers.Provider, mdl model.Model, contextLen int, systemPrompt string, toCompact message.Messages, n int, maxLen int, ) (string, error)
CompactChunks splits the compactable history into n chunks and summarizes them sequentially, passing each chunk's summary as context to the next.
func (*Assistant) CompactOnce ¶
func (a *Assistant) CompactOnce( ctx context.Context, provider providers.Provider, mdl model.Model, contextLen int, systemPrompt string, toCompact message.Messages, maxLen int, includeTodos bool, ) (string, error)
CompactOnce tries to compact messages with the given tool result truncation length. When includeTodos is true, the todo list is appended to the compaction prompt.
func (*Assistant) CompactWith ¶
CompactWith performs context compaction by summarizing old messages via an LLM call. When force is true, keepLast is clamped to what's actually possible. If no summarization agent is configured, only mechanical pruning runs.
func (*Assistant) CompactWithKeepLast ¶
CompactWithKeepLast performs forced compaction with an explicit keepLast value. Used by RecoverCompaction to progressively reduce preserved message.
func (*Assistant) ContextLength ¶
func (a *Assistant) ContextLength() model.ContextLength
ContextLength returns the context window size to use for display and compaction. User-configured context always wins; otherwise falls back to the provider-reported value.
func (*Assistant) CycleThink ¶
CycleThink cycles through: false -> true -> low -> medium -> high -> false.
func (*Assistant) DisplayHints ¶
func (a *Assistant) DisplayHints() ui.DisplayHints
DisplayHints returns the current UI display preferences.
func (*Assistant) Done ¶
func (a *Assistant) Done() <-chan struct{}
Done returns a channel that is closed when Loop() returns.
func (*Assistant) DoneEnabled ¶
DoneEnabled returns whether the Done tool is active.
func (*Assistant) EmitAll ¶
func (a *Assistant) EmitAll()
EmitAll sends both system status and display hints to the UI.
func (*Assistant) EmitDisplayHints ¶
func (a *Assistant) EmitDisplayHints()
EmitDisplayHints sends the current display preferences to the UI.
func (*Assistant) EmitStatus ¶
func (a *Assistant) EmitStatus()
EmitStatus sends the current system status to the UI.
func (*Assistant) EnableAsk ¶
EnableAsk registers the Ask tool callback. Delegates to rebuildState so the tool respects agent+mode filtering.
func (*Assistant) EstimateTokens ¶
EstimateTokens returns a client-side token estimate by summing per-message Tokens.Total for messages that affect context budget (excludes internal types) plus cached schema tokens. No re-rendering or provider calls — O(n) message count, not O(n) text.
func (*Assistant) ExecuteSubTool ¶
func (a *Assistant) ExecuteSubTool(ctx context.Context, toolName string, args map[string]any) (string, error)
ExecuteSubTool runs a single tool call through a minimal pipeline. Used by the Batch tool for concurrent sub-calls. Runs security-critical steps (plugins, policy, guardrails, hooks, sandbox) but skips conversation-history steps (builder, tracking, LSP, stats, streaming).
func (*Assistant) FilterTools ¶
FilterTools sets a persistent additional tool filter applied after agent+mode. Used by task runner to restrict tools beyond what agent+mode provide.
func (*Assistant) GenerateTitle ¶
GenerateTitle generates a short title for the current conversation.
Three modes:
- disabled: returns the first user message, truncated to max_length
- no agent/prompt configured: returns the first user message (fallback)
- agent or prompt configured: sends first user messages to a dedicated/self-use agent
func (*Assistant) HasCompactor ¶
HasCompactor returns true if a compaction agent or prompt is configured. When false, compaction skips LLM summarization and only performs mechanical pruning.
func (*Assistant) InjectorRegistry ¶
InjectorRegistry returns the synthetic message injection registry.
func (*Assistant) InjectorState ¶
InjectorState creates a State snapshot for injectors.
func (*Assistant) IsToolParallel ¶
IsToolParallel reports whether a tool is safe for concurrent execution, checking global parallel toggle, config-level overrides, and the tool's ParallelOverride interface. Used by the Batch tool to mirror the main pipeline's two-pass dispatch logic.
func (*Assistant) Loop ¶
func (a *Assistant) Loop( ctx context.Context, inputs <-chan ui.UserInput, actions <-chan ui.UserAction, cancel <-chan struct{}, ) error
Loop processes user inputs until cancelled.
func (*Assistant) MCPSessions ¶
MCPSessions returns the connected MCP server sessions.
func (*Assistant) MergeFeatures ¶
MergeFeatures applies feature overrides on top of the current effective features. Non-zero overlay fields win; zero/nil falls through. Routes through rebuildState so prompt, sandbox, hooks, and toolPolicy are rebuilt.
func (*Assistant) ModelListCache ¶
func (a *Assistant) ModelListCache() []slash.ProviderModels
ModelListCache returns the cached model list (nil on first call).
func (*Assistant) PathChecker ¶
func (a *Assistant) PathChecker() subagent.PathChecker
PathChecker wraps CheckPaths for the Runner's PathChecker signature.
func (*Assistant) Paths ¶
Paths returns the filesystem paths context (immutable after construction).
func (*Assistant) PluginSummary ¶
PluginSummary returns a formatted display of all loaded plugins and their capabilities.
func (*Assistant) ProcessInput ¶
ProcessInput processes a single input synchronously. Blocks until the assistant completes (no more tool calls).
func (*Assistant) ReadBeforePolicy ¶
func (a *Assistant) ReadBeforePolicy() tool.ReadBeforePolicy
ReadBeforePolicy returns the current read-before enforcement policy.
func (*Assistant) RecoverCompaction ¶
RecoverCompaction performs compaction with progressive retry. It loops up to maxCompactionAttempts, decrementing keepLast on each failure or when compaction is ineffective. Returns nil on success, ErrCompactionExhausted when all attempts fail, or a wrapped ErrCompactionConfig on fatal config errors.
func (*Assistant) RegisterMCPSession ¶
RegisterMCPSession appends a single MCP session mid-conversation. Unlike RegisterMCPTools (used at startup), this calls rebuildState so the new tools appear immediately in the agent's tool list and status bar.
func (*Assistant) RegisterMCPTools ¶
RegisterMCPTools integrates MCP sessions into the running assistant. It adds discovered tools to the config and re-applies CLI tool filters. It does NOT call rebuildState — the work callback is responsible for triggering a rebuild at the right time (after task/mode overrides are applied). This prevents a premature StatusChanged that would display the wrong agent in the welcome banner for task runs.
func (*Assistant) Reload ¶
Reload re-reads config from disk, rebuilds all derived state, and reconnects MCP servers. Conversation history, session state, stats, and runtime toggles are preserved.
func (*Assistant) RequestExit ¶
func (a *Assistant) RequestExit()
RequestExit signals the assistant loop to exit gracefully.
func (*Assistant) ResetTokens ¶
func (a *Assistant) ResetTokens()
ResetTokens clears cached token counts, forcing Status() to re-estimate.
func (*Assistant) ResizeContext ¶
ResizeContext sets the context window size.
func (*Assistant) ResolveAgent ¶
func (a *Assistant) ResolveAgent(ctx context.Context, cfg FeatureAgentConfig) (FeatureResolution, error)
ResolveAgent determines which provider, model, and system prompt to use for a feature agent call.
Resolution order:
- promptName set → self-use: current agent's model + named prompt from prompts/
- agentName set → create dedicated agent on demand
- Error: neither set → "no agent available"
func (*Assistant) ResolveCompaction ¶
func (a *Assistant) ResolveCompaction(ctx context.Context) (FeatureResolution, error)
ResolveCompaction determines which provider, model, and system prompt to use for compaction. Short-circuits with errNoSummarizationAgent when no agent/prompt is configured, then delegates to ResolveAgent and wraps errors with ErrCompactionConfig.
func (*Assistant) ResolveGuardrail ¶
ResolveGuardrail determines which provider, model, and system prompt to use for a guardrail check in the given scope. Dispatches scope-specific config then delegates to ResolveAgent.
func (*Assistant) ResolveModel ¶
func (a *Assistant) ResolveModel( ctx context.Context, label string, ag *agent.Agent, cache **model.Model, ) (model.Model, error)
ResolveModel lazily resolves and caches a model for an agent. On first call (*cache == nil), it fetches the model from the provider and stores it. Subsequent calls return the cached value.
func (*Assistant) ResolvedModel ¶
ResolvedModel returns the resolved model metadata.
func (*Assistant) ResumeSession ¶
ResumeSession restores the assistant state from a saved session. Returns any non-fatal warnings encountered during restoration.
func (*Assistant) RewriteThinking ¶
RewriteThinking finds the single message that just crossed the keepLast boundary and has a thinking block exceeding tokenThreshold, then rewrites it via one LLM call. Mutates the builder directly. At most one block qualifies per turn.
func (*Assistant) RunSubagent ¶
func (a *Assistant) RunSubagent(ctx context.Context, agentName, prompt string) (subagent.Result, error)
RunSubagent spawns a one-shot subagent with isolated context and returns its result. When agentName is empty it resolves to Features.Subagent.DefaultAgent, then falls back to the parent's agent name. A fresh agent is always created via agent.New() so parallel Task calls never share provider or tool state.
func (*Assistant) SandboxDisplay ¶
SandboxDisplay returns a human-readable summary of sandbox state and restrictions.
func (*Assistant) SandboxEnabled ¶
SandboxEnabled returns current sandbox enforcement state.
func (*Assistant) SandboxRequested ¶
SandboxRequested returns whether the user wants sandbox, independent of kernel support.
func (*Assistant) Send ¶
Send emits a UI event. Public wrapper for use by external callbacks (e.g. ask tool).
func (*Assistant) SessionManager ¶
SessionManager returns the session persistence manager.
func (*Assistant) SessionMeta ¶
SessionMeta builds a complete session.Meta snapshot including all runtime toggles and session-scoped state. Used by AutoSave, /save, and /fork.
func (*Assistant) SessionStats ¶
SessionStats returns the session metrics tracker.
func (*Assistant) SetDone ¶
SetDone sets the Done tool to the given state. Delegates to rebuildState so the tool respects agent+mode filtering.
func (*Assistant) SetNoop ¶
SetNoop enables noop mode — all agent providers are replaced with the noop provider. Future agent rebuilds (SetAgent, Reload) and on-demand feature agents (via ResolveAgent) also use this provider.
func (*Assistant) SetReadBeforePolicy ¶
func (a *Assistant) SetReadBeforePolicy(p tool.ReadBeforePolicy) error
SetReadBeforePolicy sets the read-before enforcement policy (records as runtime override) and rebuilds state so the system prompt reflects the change.
func (*Assistant) SetSandbox ¶
SetSandbox sets the sandbox state explicitly.
func (*Assistant) SetVerbose ¶
SetVerbose sets the UI thinking display preference.
func (*Assistant) SetWorkDir ¶
SetWorkDir overrides the effective working directory for task workdir: support. Rebuilds system prompt and sandbox to reflect the new directory.
func (*Assistant) ShouldCheck ¶
ShouldCheck returns whether a tool should be checked by the guardrail. Uses wildcard.MatchAny with the configured enabled/disabled lists.
func (*Assistant) ShouldCompact ¶
ShouldCompact checks if context usage exceeds the compaction threshold. When MaxTokens is set, uses absolute token comparison (no context length needed). Otherwise falls back to percentage of context window.
func (*Assistant) ShouldContinue ¶
ShouldContinue returns true when auto mode should force another iteration. This happens when Auto is enabled, there are incomplete TODOs, and the iteration cap has not been reached.
func (*Assistant) ShouldTrim ¶
ShouldTrim checks if context usage exceeds the synthetic trim threshold. When TrimMaxTokens is set, uses absolute token comparison (no context length needed). Otherwise falls back to percentage of context window.
func (*Assistant) SnapshotManager ¶
SnapshotManager returns the snapshot manager (nil if not in a git repo).
func (*Assistant) StripThinking ¶
StripThinking clears .Thinking on messages older than keepLast that exceed tokenThreshold. Mutates the builder directly. No LLM call.
func (*Assistant) SwitchAgent ¶
SwitchAgent switches to a different agent (preserves conversation). If the new agent changes MCP filter rules, MCP sessions are closed and reconnected so the correct set of tools is active.
func (*Assistant) SwitchMode ¶
SwitchMode switches to a different mode (preserves conversation). Empty string clears the mode (no mode prompt or mode-specific tools).
func (*Assistant) SwitchModel ¶
SwitchModel switches the model and provider mid-session (preserves conversation).
func (*Assistant) TemplateData ¶
func (a *Assistant) TemplateData() config.TemplateData
TemplateData builds a full TemplateData from the current assistant state. Used by rebuildState and feature resolve methods to avoid partial construction.
func (*Assistant) TemplateVars ¶
TemplateVars returns the session-wide --set template variables.
func (*Assistant) ToggleAuto ¶
func (a *Assistant) ToggleAuto()
ToggleAuto toggles Auto mode on/off.
func (*Assistant) ToggleSandbox ¶
ToggleSandbox toggles sandbox enforcement for tool execution.
func (*Assistant) ToggleThink ¶
ToggleThink toggles thinking false <-> true.
func (*Assistant) ToggleVerbose ¶
func (a *Assistant) ToggleVerbose()
ToggleVerbose toggles the UI display of thinking content.
func (*Assistant) Tokens ¶
Tokens returns the best available token count for context usage checks. Prefers the actual input tokens from the last API call; falls back to a rough client-side estimate when no API call has been made yet.
func (*Assistant) ToolPolicy ¶
func (a *Assistant) ToolPolicy() *config.ToolPolicy
ToolPolicy returns the effective tool policy (includes persisted approval rules).
func (*Assistant) Track ¶
func (a *Assistant) Track(name string, args map[string]any, result, toolErr string, duration time.Duration)
Track records a tool invocation for injector state.
func (*Assistant) TrimSynthetics ¶
func (a *Assistant) TrimSynthetics()
TrimSynthetics removes duplicate synthetic messages from history.
func (*Assistant) WireEstimation ¶
func (a *Assistant) WireEstimation()
WireEstimation registers the provider's Estimate endpoint as the native estimation function on the Estimator. Idempotent — safe to call on every chat() turn. Before model resolution, native falls back to local (correct for construction-time estimates).
type FeatureAgentConfig ¶
type FeatureAgentConfig struct {
// contains filtered or unexported fields
}
FeatureAgentConfig holds the inputs for resolving a feature agent.
type FeatureResolution ¶
type FeatureResolution struct {
// contains filtered or unexported fields
}
FeatureResolution holds the resolved provider/model/prompt for a secondary LLM call (compaction, thinking rewrite, guardrail check).
type Params ¶
type Params struct {
Config config.Config
Paths config.Paths
Runtime *config.Runtime
Agent *agent.Agent
Events chan<- ui.Event
Sessions *session.Manager
Todo *todo.List
Plugins *plugins.Cache
LSP *lsp.Manager
Slash SlashHandler
Auto bool
SetVars map[string]string
ConfigOpts config.Options
CLIOverrides agent.Overrides
// Task tool (nil if no subagent agents).
TaskTool tool.Tool
// Batch tool (always present).
BatchTool tool.Tool
}
Params holds all dependencies for constructing an Assistant.