Documentation
¶
Index ¶
- func NewApprovingToolsState(ctx *domain.StateContext) domain.StateHandler
- func NewBlockingToolsState(ctx *domain.StateContext) domain.StateHandler
- func NewCancelledState(ctx *domain.StateContext) domain.StateHandler
- func NewCheckingQueueState(ctx *domain.StateContext) domain.StateHandler
- func NewCompletingState(ctx *domain.StateContext) domain.StateHandler
- func NewErrorState(ctx *domain.StateContext) domain.StateHandler
- func NewEvaluatingToolsState(ctx *domain.StateContext) domain.StateHandler
- func NewExecutingToolsState(ctx *domain.StateContext) domain.StateHandler
- func NewIdleState(ctx *domain.StateContext) domain.StateHandler
- func NewPostStreamState(ctx *domain.StateContext) domain.StateHandler
- func NewPostToolExecutionState(ctx *domain.StateContext) domain.StateHandler
- func NewStoppedState(ctx *domain.StateContext) domain.StateHandler
- func NewStreamingLLMState(ctx *domain.StateContext) domain.StateHandler
- type ApprovingToolsState
- type BlockingToolsState
- type CancelledState
- type CheckingQueueState
- type CompletingState
- type ErrorState
- type EvaluatingToolsState
- type ExecutingToolsState
- type IdleState
- type PostStreamState
- type PostToolExecutionState
- type StoppedState
- type StreamingLLMState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewApprovingToolsState ¶
func NewApprovingToolsState(ctx *domain.StateContext) domain.StateHandler
NewApprovingToolsState creates a new ApprovingTools state handler
func NewBlockingToolsState ¶ added in v0.121.0
func NewBlockingToolsState(ctx *domain.StateContext) domain.StateHandler
NewBlockingToolsState creates a new BlockingTools state handler
func NewCancelledState ¶
func NewCancelledState(ctx *domain.StateContext) domain.StateHandler
NewCancelledState creates a new Cancelled state handler
func NewCheckingQueueState ¶
func NewCheckingQueueState(ctx *domain.StateContext) domain.StateHandler
NewCheckingQueueState creates a new CheckingQueue state handler
func NewCompletingState ¶
func NewCompletingState(ctx *domain.StateContext) domain.StateHandler
NewCompletingState creates a new Completing state handler
func NewErrorState ¶
func NewErrorState(ctx *domain.StateContext) domain.StateHandler
NewErrorState creates a new Error state handler
func NewEvaluatingToolsState ¶
func NewEvaluatingToolsState(ctx *domain.StateContext) domain.StateHandler
NewEvaluatingToolsState creates a new EvaluatingTools state handler
func NewExecutingToolsState ¶
func NewExecutingToolsState(ctx *domain.StateContext) domain.StateHandler
NewExecutingToolsState creates a new ExecutingTools state handler
func NewIdleState ¶
func NewIdleState(ctx *domain.StateContext) domain.StateHandler
NewIdleState creates a new Idle state handler
func NewPostStreamState ¶
func NewPostStreamState(ctx *domain.StateContext) domain.StateHandler
NewPostStreamState creates a new PostStream state handler
func NewPostToolExecutionState ¶
func NewPostToolExecutionState(ctx *domain.StateContext) domain.StateHandler
NewPostToolExecutionState creates a new PostToolExecution state handler
func NewStoppedState ¶
func NewStoppedState(ctx *domain.StateContext) domain.StateHandler
NewStoppedState creates a new Stopped state handler
func NewStreamingLLMState ¶
func NewStreamingLLMState(ctx *domain.StateContext) domain.StateHandler
NewStreamingLLMState creates a new StreamingLLM state handler
Types ¶
type ApprovingToolsState ¶
type ApprovingToolsState struct {
// contains filtered or unexported fields
}
ApprovingToolsState handles events in the ApprovingTools state.
This state manages sequential tool approval with overlapping execution:
- MessageReceivedEvent → initializes the tool round, starts sequential approval
- AllToolsProcessedEvent → transitions to PostToolExecution
- ApprovalFailedEvent → handles approval failures
func (*ApprovingToolsState) Handle ¶
func (s *ApprovingToolsState) Handle(event domain.AgentEvent) error
Handle processes events in ApprovingTools state
func (*ApprovingToolsState) Name ¶
func (s *ApprovingToolsState) Name() domain.AgentExecutionState
Name returns the state this handler manages
type BlockingToolsState ¶ added in v0.121.0
type BlockingToolsState struct {
// contains filtered or unexported fields
}
BlockingToolsState handles events in the BlockingTools state.
This state is entered (from EvaluatingTools) when at least one tool call requires approval but that approval cannot be delivered in the current session (approval_behaviour resolves to block - e.g. approval_behaviour=block, or =ipc with no broker attached). There is no approver to prompt, so each gated tool is rejected with an actionable reason instead of being executed. Tool calls in the same batch that do NOT require approval (e.g. read-only tools, allow-listed Bash) still run, preserving tool-call order.
- MessageReceivedEvent → processes the batch, then emits AllToolsProcessedEvent
- AllToolsProcessedEvent → transitions to PostToolExecution
func (*BlockingToolsState) Handle ¶ added in v0.121.0
func (s *BlockingToolsState) Handle(event domain.AgentEvent) error
Handle processes events in BlockingTools state
func (*BlockingToolsState) Name ¶ added in v0.121.0
func (s *BlockingToolsState) Name() domain.AgentExecutionState
Name returns the state this handler manages
type CancelledState ¶
type CancelledState struct {
// contains filtered or unexported fields
}
CancelledState handles events in the Cancelled state.
The Cancelled state is a terminal state reached when the agent is cancelled by the user. The event loop will exit when this state is reached.
func (*CancelledState) Handle ¶
func (s *CancelledState) Handle(event domain.AgentEvent) error
Handle processes events in Cancelled state This is a terminal state, so no events are expected
func (*CancelledState) Name ¶
func (s *CancelledState) Name() domain.AgentExecutionState
Name returns the state this handler manages
type CheckingQueueState ¶
type CheckingQueueState struct {
// contains filtered or unexported fields
}
CheckingQueueState handles events in the CheckingQueue state.
This state evaluates conditions to determine the next action:
- Tool results pending → must respond to tools first (StreamingLLM)
- Messages queued → drain queue into conversation
- Can complete → transition to Completing
- Otherwise → continue agent loop (StreamingLLM)
In chat mode the turn does NOT wait in-state for background work (the UI ticker starts fresh turns that drain completion notes here). Headless runs wait at the completion boundary via WaitForBackgroundTasks so a run never exits with orphaned background tasks.
func (*CheckingQueueState) Handle ¶
func (s *CheckingQueueState) Handle(event domain.AgentEvent) error
Handle processes events in CheckingQueue state
func (*CheckingQueueState) Name ¶
func (s *CheckingQueueState) Name() domain.AgentExecutionState
Name returns the state this handler manages
type CompletingState ¶
type CompletingState struct {
// contains filtered or unexported fields
}
CompletingState handles events in the Completing state.
This state finalizes the agent execution:
- Performs a final 20ms queue check
- If messages queued → restart agent (CheckingQueue)
- Otherwise → publish completion event and transition to Idle
func (*CompletingState) Handle ¶
func (s *CompletingState) Handle(event domain.AgentEvent) error
Handle processes events in Completing state. Completion is driven solely by CompletionRequestedEvent (emitted right after the transition into Completing); any other event is ignored so a stray wake-up cannot finalize the agent.
func (*CompletingState) Name ¶
func (s *CompletingState) Name() domain.AgentExecutionState
Name returns the state this handler manages
type ErrorState ¶
type ErrorState struct {
// contains filtered or unexported fields
}
ErrorState handles events in the Error state.
The Error state is a terminal state reached when unrecoverable errors occur. The event loop will exit when this state is reached.
func (*ErrorState) Handle ¶
func (s *ErrorState) Handle(event domain.AgentEvent) error
Handle processes events in Error state This is a terminal state, so no events are expected
func (*ErrorState) Name ¶
func (s *ErrorState) Name() domain.AgentExecutionState
Name returns the state this handler manages
type EvaluatingToolsState ¶
type EvaluatingToolsState struct {
// contains filtered or unexported fields
}
EvaluatingToolsState handles events in the EvaluatingTools state.
This state:
- Publishes chat complete event with tool calls
- Checks if any tool requires approval
- If approval needed → ApprovingTools
- Otherwise → ExecutingTools (starts background execution)
func (*EvaluatingToolsState) Handle ¶
func (s *EvaluatingToolsState) Handle(event domain.AgentEvent) error
Handle processes events in EvaluatingTools state
func (*EvaluatingToolsState) Name ¶
func (s *EvaluatingToolsState) Name() domain.AgentExecutionState
Name returns the state this handler manages
type ExecutingToolsState ¶
type ExecutingToolsState struct {
// contains filtered or unexported fields
}
ExecutingToolsState handles events in the ExecutingTools state.
This state processes tool execution completion:
- ToolsCompletedEvent (Stop=false) → transitions to PostToolExecution
- ToolsCompletedEvent (Stop=true) → transitions to the Stopped terminal (a rejected tool or a successful RequestPlanApproval ended the loop)
func (*ExecutingToolsState) Handle ¶
func (s *ExecutingToolsState) Handle(event domain.AgentEvent) error
Handle processes events in ExecutingTools state
func (*ExecutingToolsState) Name ¶
func (s *ExecutingToolsState) Name() domain.AgentExecutionState
Name returns the state this handler manages
type IdleState ¶
type IdleState struct {
// contains filtered or unexported fields
}
IdleState handles events in the Idle state.
The Idle state is the initial and final resting state of the agent. When a MessageReceivedEvent arrives, it transitions to CheckingQueue to begin processing.
func (*IdleState) Handle ¶
func (s *IdleState) Handle(event domain.AgentEvent) error
Handle processes events in Idle state
func (*IdleState) Name ¶
func (s *IdleState) Name() domain.AgentExecutionState
Name returns the state this handler manages
type PostStreamState ¶
type PostStreamState struct {
// contains filtered or unexported fields
}
PostStreamState handles events in the PostStream state.
This state:
- Stores assistant message to conversation
- Checks if messages were queued during stream → CheckingQueue
- If tool calls exist → EvaluatingTools
- If no tools and can complete → Completing
- Otherwise → CheckingQueue
func (*PostStreamState) Handle ¶
func (s *PostStreamState) Handle(event domain.AgentEvent) error
Handle processes events in PostStream state
func (*PostStreamState) Name ¶
func (s *PostStreamState) Name() domain.AgentExecutionState
Name returns the state this handler manages
type PostToolExecutionState ¶
type PostToolExecutionState struct {
// contains filtered or unexported fields
}
PostToolExecutionState handles events in the PostToolExecution state.
This state:
- Checks if messages were queued during tool execution → drains and goes to CheckingQueue
- Checks if can complete → Completing
- Otherwise → CheckingQueue for next turn
func (*PostToolExecutionState) Handle ¶
func (s *PostToolExecutionState) Handle(event domain.AgentEvent) error
Handle processes events in PostToolExecution state
func (*PostToolExecutionState) Name ¶
func (s *PostToolExecutionState) Name() domain.AgentExecutionState
Name returns the state this handler manages
type StoppedState ¶
type StoppedState struct {
// contains filtered or unexported fields
}
StoppedState handles events in the Stopped state.
The Stopped state is a terminal state reached when the agent stops execution (e.g., due to tool rejection or other stop conditions). The event loop will exit when this state is reached.
func (*StoppedState) Handle ¶
func (s *StoppedState) Handle(event domain.AgentEvent) error
Handle processes events in Stopped state This is a terminal state, so no events are expected
func (*StoppedState) Name ¶
func (s *StoppedState) Name() domain.AgentExecutionState
Name returns the state this handler manages
type StreamingLLMState ¶
type StreamingLLMState struct {
// contains filtered or unexported fields
}
StreamingLLMState handles events in the StreamingLLM state.
This state manages LLM streaming:
- StartStreamingEvent → launches background streaming goroutine
- StreamCompletedEvent → processes completed stream, stores data, transitions to PostStream
func (*StreamingLLMState) Handle ¶
func (s *StreamingLLMState) Handle(event domain.AgentEvent) error
Handle processes events in StreamingLLM state
func (*StreamingLLMState) Name ¶
func (s *StreamingLLMState) Name() domain.AgentExecutionState
Name returns the state this handler manages