assistant

package
v0.0.0-beta Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 60 Imported by: 0

Documentation

Overview

Package assistant manages AI conversations with configurable models, providers, and tool execution.

Index

Constants

This section is empty.

Variables

View Source
var ErrCompactionConfig = errors.New("compaction misconfigured")

ErrCompactionConfig indicates a configuration error that will never succeed on retry.

View Source
var ErrCompactionExhausted = errors.New("compaction recovery exhausted")

ErrCompactionExhausted indicates all compaction recovery attempts failed.

View Source
var ErrMaxSteps = errors.New("maximum steps exceeded")

ErrMaxSteps indicates the assistant exceeded its configured step limit.

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

func New(p Params) (*Assistant, error)

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

func (a *Assistant) AutoEnabled() bool

AutoEnabled returns whether auto mode is active.

func (*Assistant) AutoSave

func (a *Assistant) AutoSave() error

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) Cfg

func (a *Assistant) Cfg() config.Config

Cfg returns the runtime configuration.

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

func (a *Assistant) CheckInput(ctx context.Context, text string) (est int, msg string)

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

func (a *Assistant) CheckPaths(read, write []string) error

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

func (a *Assistant) Compact(ctx context.Context, force bool) error

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

func (a *Assistant) CompactWith(ctx context.Context, force bool, keepLast int) error

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

func (a *Assistant) CompactWithKeepLast(ctx context.Context, keepLast int) error

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

func (a *Assistant) CycleThink() error

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

func (a *Assistant) DoneEnabled() bool

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

func (a *Assistant) EnableAsk(cb func(context.Context, ask.Request) (string, error)) error

EnableAsk registers the Ask tool callback. Delegates to rebuildState so the tool respects agent+mode filtering.

func (*Assistant) EstimateTokens

func (a *Assistant) EstimateTokens(_ context.Context) int

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) EventChan

func (a *Assistant) EventChan() chan<- ui.Event

EventChan returns the UI event channel for sending events.

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

func (a *Assistant) FilterTools(filter tool.Filter) error

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

func (a *Assistant) GenerateTitle(ctx context.Context) (string, error)

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

func (a *Assistant) HasCompactor() bool

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

func (a *Assistant) InjectorRegistry() *injector.Registry

InjectorRegistry returns the synthetic message injection registry.

func (*Assistant) InjectorState

func (a *Assistant) InjectorState() *injector.State

InjectorState creates a State snapshot for injectors.

func (*Assistant) IsToolParallel

func (a *Assistant) IsToolParallel(name string) bool

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

func (a *Assistant) MCPSessions() []*mcp.Session

MCPSessions returns the connected MCP server sessions.

func (*Assistant) MaxSteps

func (a *Assistant) MaxSteps() int

MaxSteps returns the configured iteration cap.

func (*Assistant) MergeFeatures

func (a *Assistant) MergeFeatures(overlay config.Features) error

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) NextAgent

func (a *Assistant) NextAgent() error

NextAgent cycles to the next available agent.

func (*Assistant) NextMode

func (a *Assistant) NextMode() error

NextMode cycles to the next available mode.

func (*Assistant) PathChecker

func (a *Assistant) PathChecker() subagent.PathChecker

PathChecker wraps CheckPaths for the Runner's PathChecker signature.

func (*Assistant) Paths

func (a *Assistant) Paths() config.Paths

Paths returns the filesystem paths context (immutable after construction).

func (*Assistant) PluginSummary

func (a *Assistant) PluginSummary() string

PluginSummary returns a formatted display of all loaded plugins and their capabilities.

func (*Assistant) ProcessInput

func (a *Assistant) ProcessInput(ctx context.Context, input string) error

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

func (a *Assistant) RecoverCompaction(ctx context.Context, keepLast int) error

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

func (a *Assistant) RegisterMCPSession(s *mcp.Session) error

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

func (a *Assistant) RegisterMCPTools(sessions []*mcp.Session)

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

func (a *Assistant) Reload(ctx context.Context) error

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

func (a *Assistant) ResizeContext(size int) error

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:

  1. promptName set → self-use: current agent's model + named prompt from prompts/
  2. agentName set → create dedicated agent on demand
  3. 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

func (a *Assistant) ResolveGuardrail(ctx context.Context, scope string) (FeatureResolution, error)

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

func (a *Assistant) ResolvedModel() model.Model

ResolvedModel returns the resolved model metadata.

func (*Assistant) ResumeSession

func (a *Assistant) ResumeSession(ctx context.Context, sess *session.Session) []string

ResumeSession restores the assistant state from a saved session. Returns any non-fatal warnings encountered during restoration.

func (*Assistant) RewriteThinking

func (a *Assistant) RewriteThinking(ctx context.Context, keepLast, tokenThreshold int) error

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) Runtime

func (a *Assistant) Runtime() *config.Runtime

Runtime returns the mutable runtime state that persists across reloads.

func (*Assistant) SandboxDisplay

func (a *Assistant) SandboxDisplay() string

SandboxDisplay returns a human-readable summary of sandbox state and restrictions.

func (*Assistant) SandboxEnabled

func (a *Assistant) SandboxEnabled() bool

SandboxEnabled returns current sandbox enforcement state.

func (*Assistant) SandboxRequested

func (a *Assistant) SandboxRequested() bool

SandboxRequested returns whether the user wants sandbox, independent of kernel support.

func (*Assistant) Send

func (a *Assistant) Send(event ui.Event)

Send emits a UI event. Public wrapper for use by external callbacks (e.g. ask tool).

func (*Assistant) SessionManager

func (a *Assistant) SessionManager() *session.Manager

SessionManager returns the session persistence manager.

func (*Assistant) SessionMeta

func (a *Assistant) SessionMeta() session.Meta

SessionMeta builds a complete session.Meta snapshot including all runtime toggles and session-scoped state. Used by AutoSave, /save, and /fork.

func (*Assistant) SessionStats

func (a *Assistant) SessionStats() *stats.Stats

SessionStats returns the session metrics tracker.

func (*Assistant) SetAuto

func (a *Assistant) SetAuto(val bool)

SetAuto sets Auto mode to the given value.

func (*Assistant) SetDone

func (a *Assistant) SetDone(val bool) error

SetDone sets the Done tool to the given state. Delegates to rebuildState so the tool respects agent+mode filtering.

func (*Assistant) SetNoop

func (a *Assistant) SetNoop(p providers.Provider)

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

func (a *Assistant) SetSandbox(enabled bool) error

SetSandbox sets the sandbox state explicitly.

func (*Assistant) SetThink

func (a *Assistant) SetThink(t thinking.Value) error

SetThink sets the thinking mode.

func (*Assistant) SetVerbose

func (a *Assistant) SetVerbose(val bool)

SetVerbose sets the UI thinking display preference.

func (*Assistant) SetWorkDir

func (a *Assistant) SetWorkDir(wd string) error

SetWorkDir overrides the effective working directory for task workdir: support. Rebuilds system prompt and sandbox to reflect the new directory.

func (*Assistant) ShouldCheck

func (a *Assistant) ShouldCheck(toolName string) bool

ShouldCheck returns whether a tool should be checked by the guardrail. Uses wildcard.MatchAny with the configured enabled/disabled lists.

func (*Assistant) ShouldCompact

func (a *Assistant) ShouldCompact() bool

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

func (a *Assistant) ShouldContinue() bool

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

func (a *Assistant) ShouldTrim() bool

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

func (a *Assistant) SnapshotManager() *snapshot.Manager

SnapshotManager returns the snapshot manager (nil if not in a git repo).

func (*Assistant) Status

func (a *Assistant) Status() ui.Status

Status returns the current status for the UI.

func (*Assistant) StripThinking

func (a *Assistant) StripThinking(ctx context.Context, keepLast, tokenThreshold int)

StripThinking clears .Thinking on messages older than keepLast that exceed tokenThreshold. Mutates the builder directly. No LLM call.

func (*Assistant) SwitchAgent

func (a *Assistant) SwitchAgent(name, reason string) error

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

func (a *Assistant) SwitchMode(mode string) error

SwitchMode switches to a different mode (preserves conversation). Empty string clears the mode (no mode prompt or mode-specific tools).

func (*Assistant) SwitchModel

func (a *Assistant) SwitchModel(ctx context.Context, providerName, modelName string) error

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

func (a *Assistant) TemplateVars() map[string]string

TemplateVars returns the session-wide --set template variables.

func (*Assistant) TodoList

func (a *Assistant) TodoList() *todo.List

TodoList returns the per-session todo list.

func (*Assistant) ToggleAuto

func (a *Assistant) ToggleAuto()

ToggleAuto toggles Auto mode on/off.

func (*Assistant) ToggleSandbox

func (a *Assistant) ToggleSandbox() error

ToggleSandbox toggles sandbox enforcement for tool execution.

func (*Assistant) ToggleThink

func (a *Assistant) ToggleThink() error

ToggleThink toggles thinking false <-> true.

func (*Assistant) ToggleVerbose

func (a *Assistant) ToggleVerbose()

ToggleVerbose toggles the UI display of thinking content.

func (*Assistant) Tokens

func (a *Assistant) Tokens() int

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) Verbose

func (a *Assistant) Verbose() bool

Verbose returns whether thinking content is displayed in the UI.

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

func (*Assistant) WorkDir

func (a *Assistant) WorkDir() string

WorkDir returns the effective working directory (post --workdir resolution).

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.

type SlashHandler

type SlashHandler func(ctx context.Context, sctx slash.Context, input string) (msg string, handled, forward bool, err error)

SlashHandler handles slash command input. When forward is true, msg should be sent to the LLM as a user message.

Jump to

Keyboard shortcuts

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