Documentation
¶
Overview ¶
Package errorwatch provides error detection and automatic follow-up for agent errors.
Package errorwatch provides error detection and automatic follow-up for agent errors.
Index ¶
- Variables
- func FollowUpMessage(agentName string) string
- func IsRecoverableError(errMsg string) bool
- type AgentMode
- type AgentModeManager
- func (m *AgentModeManager) AllAutoAgents() []string
- func (m *AgentModeManager) AllStates() map[string]*AgentModeState
- func (m *AgentModeManager) GetMode(agentName string) AgentMode
- func (m *AgentModeManager) GetState(agentName string) *AgentModeState
- func (m *AgentModeManager) IsAuto(agentName string) bool
- func (m *AgentModeManager) Reset(agentName string)
- func (m *AgentModeManager) ResetAll()
- func (m *AgentModeManager) SetOnModeChange(fn func(agentName string, from, to AgentMode))
- func (m *AgentModeManager) SwitchToAuto(agentName string, errorMessage string)
- func (m *AgentModeManager) SwitchToNormal(agentName string)
- type AgentModeState
- type Detector
- func (d *Detector) CheckAndGenerateFollowUp(agentName string, errMsg string) FollowUpResult
- func (d *Detector) HandleError(agentName string, errMsg string) bool
- func (d *Detector) IsAgentInAutoMode(agentName string) bool
- func (d *Detector) ModeManager() *AgentModeManager
- func (d *Detector) RecordFollowUp(agentName string)
- func (d *Detector) Reset(agentName string)
- func (d *Detector) ResetAgentMode(agentName string)
- func (d *Detector) ResetAll()
- func (d *Detector) SetModeManager(m *AgentModeManager)
- func (d *Detector) ShouldFollowUp(agentName string, errMsg string) bool
- type FollowUpResult
Constants ¶
This section is empty.
Variables ¶
var ErrorPatterns = []string{
"context deadline exceeded",
"context canceled",
"timeout",
"connection refused",
"connection reset",
"exit status 1",
}
ErrorPatterns defines the patterns to detect recoverable agent errors.
Functions ¶
func FollowUpMessage ¶
FollowUpMessage generates a follow-up message for an agent that encountered an error.
func IsRecoverableError ¶
IsRecoverableError checks if the error message matches known recoverable patterns.
Types ¶
type AgentMode ¶ added in v0.9.0
type AgentMode string
AgentMode represents the mode of an individual agent
type AgentModeManager ¶ added in v0.9.0
type AgentModeManager struct {
// contains filtered or unexported fields
}
AgentModeManager manages per-agent mode states
func NewAgentModeManager ¶ added in v0.9.0
func NewAgentModeManager() *AgentModeManager
NewAgentModeManager creates a new agent mode manager
func (*AgentModeManager) AllAutoAgents ¶ added in v0.9.0
func (m *AgentModeManager) AllAutoAgents() []string
AllAutoAgents returns a list of agents currently in auto mode
func (*AgentModeManager) AllStates ¶ added in v0.9.0
func (m *AgentModeManager) AllStates() map[string]*AgentModeState
AllStates returns all current states
func (*AgentModeManager) GetMode ¶ added in v0.9.0
func (m *AgentModeManager) GetMode(agentName string) AgentMode
GetMode returns the current mode of an agent
func (*AgentModeManager) GetState ¶ added in v0.9.0
func (m *AgentModeManager) GetState(agentName string) *AgentModeState
GetState returns the full state of an agent
func (*AgentModeManager) IsAuto ¶ added in v0.9.0
func (m *AgentModeManager) IsAuto(agentName string) bool
IsAuto returns true if the agent is in auto mode
func (*AgentModeManager) Reset ¶ added in v0.9.0
func (m *AgentModeManager) Reset(agentName string)
Reset clears the mode state for an agent
func (*AgentModeManager) ResetAll ¶ added in v0.9.0
func (m *AgentModeManager) ResetAll()
ResetAll clears all mode states
func (*AgentModeManager) SetOnModeChange ¶ added in v0.9.0
func (m *AgentModeManager) SetOnModeChange(fn func(agentName string, from, to AgentMode))
SetOnModeChange sets the callback for mode changes
func (*AgentModeManager) SwitchToAuto ¶ added in v0.9.0
func (m *AgentModeManager) SwitchToAuto(agentName string, errorMessage string)
SwitchToAuto switches an agent to auto mode
func (*AgentModeManager) SwitchToNormal ¶ added in v0.9.0
func (m *AgentModeManager) SwitchToNormal(agentName string)
SwitchToNormal switches an agent back to normal mode
type AgentModeState ¶ added in v0.9.0
type AgentModeState struct {
Mode AgentMode
SwitchedAt time.Time
ErrorMessage string // The error that triggered auto mode
}
AgentModeState tracks the mode state of an agent
type Detector ¶
type Detector struct {
// contains filtered or unexported fields
}
Detector detects error patterns and manages follow-up cooldowns.
func DefaultDetector ¶
func DefaultDetector() *Detector
DefaultDetector creates a detector with 30-second cooldown.
func NewDetector ¶
NewDetector creates a new error detector with the specified cooldown period.
func (*Detector) CheckAndGenerateFollowUp ¶
func (d *Detector) CheckAndGenerateFollowUp(agentName string, errMsg string) FollowUpResult
CheckAndGenerateFollowUp checks if a follow-up should be sent and generates the message. Also switches the agent to auto mode if the error is recoverable.
func (*Detector) HandleError ¶ added in v0.9.0
HandleError processes an error and switches to auto mode if applicable. Returns true if the agent was switched to auto mode.
func (*Detector) IsAgentInAutoMode ¶ added in v0.9.0
IsAgentInAutoMode checks if an agent is in auto mode.
func (*Detector) ModeManager ¶ added in v0.9.0
func (d *Detector) ModeManager() *AgentModeManager
ModeManager returns the agent mode manager.
func (*Detector) RecordFollowUp ¶
RecordFollowUp records that a follow-up was sent to the agent.
func (*Detector) ResetAgentMode ¶ added in v0.9.0
ResetAgentMode resets an agent to normal mode.
func (*Detector) SetModeManager ¶ added in v0.9.0
func (d *Detector) SetModeManager(m *AgentModeManager)
SetModeManager sets a custom agent mode manager.