iteragent

package
v1.5.0 Latest Latest
Warning

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

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

Documentation

Overview

Package iteragent provides iterative agent framework integration for TokMan

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	Type       string
	Tool       string
	Parameters map[string]interface{}
	Result     interface{}
	Error      error
}

Action represents an action taken by the agent

type Agent

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

Agent represents an iterative agent capable of multi-step reasoning

func NewAgent

func NewAgent(config AgentConfig) *Agent

NewAgent creates a new iterative agent

func (*Agent) ClearMemory

func (a *Agent) ClearMemory()

ClearMemory clears agent memory

func (*Agent) Execute

func (a *Agent) Execute(ctx context.Context, goal string) (*Result, error)

Execute runs the agent on a goal

func (*Agent) GetIterations

func (a *Agent) GetIterations() []Iteration

GetIterations returns all iterations

func (*Agent) GetState

func (a *Agent) GetState() AgentState

GetState returns current agent state

func (*Agent) GetTool

func (a *Agent) GetTool(name string) (Tool, bool)

GetTool returns a tool by name

func (*Agent) ID

func (a *Agent) ID() string

ID returns the agent ID

func (*Agent) Name

func (a *Agent) Name() string

Name returns the agent name

func (*Agent) Pause

func (a *Agent) Pause() error

func (*Agent) RegisterTool

func (a *Agent) RegisterTool(tool Tool)

RegisterTool registers a tool for the agent

func (*Agent) Resume

func (a *Agent) Resume(ctx context.Context) error

Resume resumes agent execution

func (*Agent) SetEventHandler

func (a *Agent) SetEventHandler(handler EventHandler)

SetEventHandler sets the event handler

type AgentConfig

type AgentConfig struct {
	Name             string
	Description      string
	MaxIterations    int
	Timeout          time.Duration
	Temperature      float64
	SystemPrompt     string
	AllowedTools     []string
	RequireApproval  bool
	EnableReflection bool
}

AgentConfig holds agent configuration

type AgentState

type AgentState struct {
	Status      AgentStatus
	CurrentGoal string
	Context     map[string]interface{}
	Variables   map[string]string
	StartTime   time.Time
	EndTime     *time.Time
}

AgentState represents the agent's current state

type AgentStatus

type AgentStatus string

AgentStatus represents agent status

const (
	StatusIdle      AgentStatus = "idle"
	StatusRunning   AgentStatus = "running"
	StatusPaused    AgentStatus = "paused"
	StatusCompleted AgentStatus = "completed"
	StatusFailed    AgentStatus = "failed"
	StatusAborted   AgentStatus = "aborted"
)

type Event

type Event struct {
	Type      EventType
	Timestamp time.Time
	AgentID   string
	Iteration int
	Message   string
	Data      interface{}
}

Event represents an agent event

type EventHandler

type EventHandler func(event Event)

EventHandler handles agent events

type EventType

type EventType string

EventType represents event types

const (
	EventStarted     EventType = "started"
	EventIteration   EventType = "iteration"
	EventThinking    EventType = "thinking"
	EventAction      EventType = "action"
	EventObservation EventType = "observation"
	EventReflection  EventType = "reflection"
	EventCompleted   EventType = "completed"
	EventFailed      EventType = "failed"
	EventAborted     EventType = "aborted"
)

type Iteration

type Iteration struct {
	Number      int
	Timestamp   time.Time
	Thought     string
	Action      Action
	Observation string
	Reflection  string
	Duration    time.Duration
}

Iteration represents a single iteration of the agent

type Manager

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

Manager manages multiple agents

func NewManager

func NewManager() *Manager

NewManager creates an agent manager

func (*Manager) CreateAgent

func (m *Manager) CreateAgent(config AgentConfig) *Agent

CreateAgent creates a new agent

func (*Manager) DeleteAgent

func (m *Manager) DeleteAgent(id string) error

DeleteAgent deletes an agent

func (*Manager) GetAgent

func (m *Manager) GetAgent(id string) (*Agent, error)

GetAgent returns an agent by ID

func (*Manager) ListAgents

func (m *Manager) ListAgents() []*Agent

ListAgents returns all agents

type Memory

type Memory struct {
	ShortTerm []MemoryEntry
	LongTerm  []MemoryEntry
	Working   map[string]interface{}
	// contains filtered or unexported fields
}

Memory provides agent memory capabilities

type MemoryEntry

type MemoryEntry struct {
	Timestamp  time.Time
	Type       string
	Content    string
	Importance float64
	Metadata   map[string]string
}

MemoryEntry represents a memory entry

type Parameter

type Parameter struct {
	Type        string
	Description string
	Required    bool
	Default     interface{}
}

Parameter represents a tool parameter

type Result

type Result struct {
	Success    bool
	Output     string
	Iterations int
	Duration   time.Duration
	ToolsUsed  []string
	TokenUsage TokenUsage
	FinalState map[string]interface{}
}

Result holds the final result of agent execution

type TokenUsage

type TokenUsage struct {
	Input  int
	Output int
	Total  int
}

TokenUsage tracks token consumption

type Tool

type Tool struct {
	Name        string
	Description string
	Parameters  map[string]Parameter
	Execute     func(ctx context.Context, params map[string]interface{}) (interface{}, error)
}

Tool represents a tool the agent can use

Jump to

Keyboard shortcuts

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