Documentation
¶
Index ¶
- func BuildAgentMessagesFromEntries(entries []domain.ConversationEntry) []sdk.Message
- type Options
- type Runner
- func (r *Runner) HandleChatChunk(msg domain.ChatChunkEvent) tea.Cmd
- func (r *Runner) HandleChatComplete(msg domain.ChatCompleteEvent) tea.Cmd
- func (r *Runner) HandleChatError(msg domain.ChatErrorEvent) tea.Cmd
- func (r *Runner) HandleChatStart(_ domain.ChatStartEvent) tea.Cmd
- func (r *Runner) HandleOptimizationStatus(event domain.OptimizationStatusEvent) tea.Cmd
- func (r *Runner) SetPendingRestoration(originalModel string)
- func (r *Runner) Start(holder domain.BashDetachChannelHolder) tea.Cmd
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildAgentMessagesFromEntries ¶
func BuildAgentMessagesFromEntries(entries []domain.ConversationEntry) []sdk.Message
BuildAgentMessagesFromEntries converts conversation entries into the flat slice of SDK messages sent to the model.
Three classes of entries are filtered:
- Plan-mode entries (entry.IsPlan): synthesized assistant messages used for UI rendering only; their content duplicates the args of the preceding RequestPlanApproval tool call.
- User-initiated bash entries: synthetic assistant + tool pairs created when the user types `!command` directly in chat. Their assistant side has tool_calls but no reasoning_content (the user, not the model, generated them).
- Pending-approval placeholders (entry.PendingToolCall != nil): UI-only empty assistant entries added while a tool awaits approval. On rejection they stay in the repo; serializing one between an assistant tool_calls message and its tool response breaks the provider's adjacency requirement ("Messages with role 'tool' must be a response to a preceding message with 'tool_calls'", issue #786). SaveConversation applies the same filter for disk persistence.
Sending the first two to a thinking-mode provider (DeepSeek, etc.) produces an assistant turn lacking `reasoning_content`, which is rejected with HTTP 400 ("The reasoning_content in the thinking mode must be passed back to the API.").
Types ¶
type Options ¶
type Options struct {
AgentService domain.AgentService
ConversationRepo domain.ConversationRepository
ModelService domain.ModelService
StateManager stateManager
Listener domain.ChatEventListener
}
Options bundles the dependencies needed to construct a Runner.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
func (*Runner) HandleChatChunk ¶
func (r *Runner) HandleChatChunk(msg domain.ChatChunkEvent) tea.Cmd
HandleChatChunk forwards a streaming content delta to the UI and adjusts chat status if the chunk indicates a thinking → generating transition (or vice versa).
func (*Runner) HandleChatComplete ¶
func (r *Runner) HandleChatComplete(msg domain.ChatCompleteEvent) tea.Cmd
HandleChatComplete restores the pending model (if any), updates chat status, refreshes history, emits tool-call previews, and signals completion.
func (*Runner) HandleChatError ¶
func (r *Runner) HandleChatError(msg domain.ChatErrorEvent) tea.Cmd
HandleChatError tears down session state and emits a sticky error event (with a friendlier message for "timed out" errors).
func (*Runner) HandleChatStart ¶
func (r *Runner) HandleChatStart(_ domain.ChatStartEvent) tea.Cmd
HandleChatStart transitions chat status to Starting and emits the initial "Starting response..." status. Clearing the orchestrator's active-tool indicator is the orchestrator's responsibility (see ChatHandler wrapper).
func (*Runner) HandleOptimizationStatus ¶
func (r *Runner) HandleOptimizationStatus(event domain.OptimizationStatusEvent) tea.Cmd
HandleOptimizationStatus surfaces the "Optimizing conversation..." status transitions emitted by the conversation optimizer.
func (*Runner) SetPendingRestoration ¶
SetPendingRestoration records that a temporary /model switch is in effect and that originalModel should be restored once the next completion ends.
func (*Runner) Start ¶
func (r *Runner) Start(holder domain.BashDetachChannelHolder) tea.Cmd
Start kicks off a streaming chat completion. The returned tea.Cmd performs the request (synchronously in the returned closure) and emits a ChatStartEvent on success or ChatErrorEvent on failure. The holder is attached to the request context so the agent core can find the BashDetachChannelHolder when launching tools that may need backgrounding.