errorwatch

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package errorwatch provides error detection and automatic follow-up for agent errors.

Index

Constants

This section is empty.

Variables

View Source
var ErrorPatterns = []string{
	"context deadline exceeded",
	"context canceled",
	"timeout",
	"connection refused",
	"connection reset",
}

ErrorPatterns defines the patterns to detect recoverable agent errors.

Functions

func FollowUpMessage

func FollowUpMessage(agentName string) string

FollowUpMessage generates a follow-up message for an agent that encountered an error.

func IsRecoverableError

func IsRecoverableError(errMsg string) bool

IsRecoverableError checks if the error message matches known recoverable patterns.

Types

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

func NewDetector(cooldownPeriod time.Duration) *Detector

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.

func (*Detector) RecordFollowUp

func (d *Detector) RecordFollowUp(agentName string)

RecordFollowUp records that a follow-up was sent to the agent.

func (*Detector) Reset

func (d *Detector) Reset(agentName string)

Reset clears the follow-up history for an agent.

func (*Detector) ResetAll

func (d *Detector) ResetAll()

ResetAll clears all follow-up history.

func (*Detector) ShouldFollowUp

func (d *Detector) ShouldFollowUp(agentName string, errMsg string) bool

ShouldFollowUp checks if a follow-up should be sent to the agent. Returns true if the error is recoverable and cooldown has passed.

type FollowUpResult

type FollowUpResult struct {
	ShouldSend bool
	AgentName  string
	Message    string
}

FollowUpResult contains the result of checking whether to send a follow-up.

Jump to

Keyboard shortcuts

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