agent

package
v0.31.27 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuditEntry

type AuditEntry struct {
	Time         time.Time `json:"time"`
	Type         EventType `json:"type"`
	Iteration    int       `json:"iteration,omitempty"`
	MessageCount int       `json:"message_count,omitempty"`
	ToolName     string    `json:"tool_name,omitempty"`
	ToolCallID   string    `json:"tool_call_id,omitempty"`
	Error        string    `json:"error,omitempty"`
}

type AuditHook

type AuditHook struct {
	// contains filtered or unexported fields
}

func NewAuditHook

func NewAuditHook(maxEntries int) *AuditHook

func (*AuditHook) Entries

func (h *AuditHook) Entries() []AuditEntry

func (*AuditHook) OnEvent

func (h *AuditHook) OnEvent(_ context.Context, evt Event)

type CounterHook

type CounterHook struct {
	// contains filtered or unexported fields
}

func NewCounterHook

func NewCounterHook() *CounterHook

func (*CounterHook) OnEvent

func (h *CounterHook) OnEvent(_ context.Context, evt Event)

func (*CounterHook) Snapshot

func (h *CounterHook) Snapshot() map[EventType]int

type Event

type Event struct {
	Type         EventType
	Iteration    int
	MessageCount int
	ToolName     string
	ToolCallID   string
	ToolArgs     string
	ToolResult   string
	ToolIsError  bool
	Err          error
}

type EventType

type EventType string
const (
	EventLoopStart      EventType = "loop_start"
	EventBeforeLLM      EventType = "before_llm"
	EventAfterLLM       EventType = "after_llm"
	EventBeforeTool     EventType = "before_tool_call"
	EventAfterTool      EventType = "after_tool_call"
	EventLoopEnd        EventType = "loop_end"
	EventLoopError      EventType = "error"
	DefaultMaxLoopIters           = 8
)

type Hook

type Hook interface {
	OnEvent(ctx context.Context, evt Event)
}

type HookFunc

type HookFunc func(ctx context.Context, evt Event)

func (HookFunc) OnEvent

func (f HookFunc) OnEvent(ctx context.Context, evt Event)

type Loop

type Loop struct {
	// contains filtered or unexported fields
}

func NewLoop

func NewLoop(client llm.Client, registry *tool.Registry, hooks ...Hook) *Loop

func (*Loop) Run

func (l *Loop) Run(ctx context.Context, initial []llm.ChatMessage, opts RunOptions) (llm.ChatResponse, error)

type RunOptions

type RunOptions struct {
	MaxIterations  int
	OnDelta        func(text string)
	Tools          []llm.ToolSchema
	BlockedTools   map[string]tool.BlockedToolError
	ToolChoice     *llm.ToolChoice
	ResponseFormat *llm.ResponseFormat
	AutoExpandOnce bool
}

Jump to

Keyboard shortcuts

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