states

package
v0.100.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

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 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:

  1. MessageReceivedEvent → initializes tool processing queue, starts sequential approval
  2. AllToolsProcessedEvent → transitions to PostToolExecution
  3. ApprovalFailedEvent → handles approval failures

func (*ApprovingToolsState) Handle

func (s *ApprovingToolsState) Handle(event domain.AgentEvent) error

Handle processes events in ApprovingTools state

func (*ApprovingToolsState) Name

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

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 multiple conditions to determine the next action:

  1. Tool results pending → must respond to tools first (StreamingLLM)
  2. Messages queued → drain queue into conversation
  3. Background tasks pending → wait for completion
  4. Can complete → transition to Completing
  5. Otherwise → continue agent loop (StreamingLLM)

func (*CheckingQueueState) Handle

func (s *CheckingQueueState) Handle(event domain.AgentEvent) error

Handle processes events in CheckingQueue state

func (*CheckingQueueState) Name

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:

  1. Performs a final 100ms queue check
  2. If messages queued → restart agent (CheckingQueue)
  3. 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

func (*CompletingState) Name

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

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:

  1. Publishes chat complete event with tool calls
  2. Checks if any tool requires approval
  3. If approval needed → ApprovingTools
  4. 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

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:

  1. ToolsCompletedEvent → transitions to PostToolExecution

func (*ExecutingToolsState) Handle

func (s *ExecutingToolsState) Handle(event domain.AgentEvent) error

Handle processes events in ExecutingTools state

func (*ExecutingToolsState) Name

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

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:

  1. Stores assistant message to conversation
  2. Checks if messages were queued during stream → CheckingQueue
  3. If tool calls exist → EvaluatingTools
  4. If no tools and can complete → Completing
  5. Otherwise → CheckingQueue

func (*PostStreamState) Handle

func (s *PostStreamState) Handle(event domain.AgentEvent) error

Handle processes events in PostStream state

func (*PostStreamState) Name

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:

  1. Checks if messages were queued during tool execution → drains and goes to CheckingQueue
  2. Checks if can complete → Completing
  3. 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

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

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:

  1. StartStreamingEvent → launches background streaming goroutine
  2. 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

Name returns the state this handler manages

Jump to

Keyboard shortcuts

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