agent

package
v0.0.0-...-1872f57 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package agent provides agent pool management with rate limiting and concurrency control for scalable AI agent operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	*iteragent.Agent
	Events chan Event
}

func New

func New(p Provider, tools []Tool, logger *slog.Logger) *Agent

type Event

type Event = iteragent.Event

type Message

type Message = iteragent.Message

type Pool

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

Pool manages a pool of agents with rate limiting and concurrency control. Safe for spawning 100+ concurrent agents with controlled API rate.

func NewPool

func NewPool(provider iteragent.Provider, tools []iteragent.Tool, logger *slog.Logger, maxAgents, rps int) *Pool

NewPool creates an agent pool with rate limiting. maxAgents: maximum concurrent agents (e.g., 10) rps: API requests per second limit (e.g., 5)

func (*Pool) Acquire

func (p *Pool) Acquire(ctx context.Context) (*iteragent.Agent, error)

Acquire gets an agent from the pool, waiting for rate limit if needed.

func (*Pool) Close

func (p *Pool) Close()

Close releases all pool resources.

func (*Pool) Release

func (p *Pool) Release(agent *iteragent.Agent)

Release returns an agent to the pool for reuse.

func (*Pool) Spawn

func (p *Pool) Spawn(ctx context.Context, task string, handler func(*iteragent.Agent) error) error

Spawn executes a task with a pooled agent.

func (*Pool) SpawnAll

func (p *Pool) SpawnAll(ctx context.Context, tasks []string, handler func(*iteragent.Agent, string) error) []error

SpawnAll executes multiple tasks concurrently with rate limiting. Returns errors for each task (nil if successful).

type Provider

type Provider = iteragent.Provider

type RateLimiter

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

RateLimiter controls API call frequency using token bucket algorithm.

func NewRateLimiter

func NewRateLimiter(rps int) *RateLimiter

NewRateLimiter creates a rate limiter with the given requests per second. If rps is 0 or negative, the limiter is unbuffered (all Wait calls return immediately).

func (*RateLimiter) Stop

func (rl *RateLimiter) Stop()

Stop stops the rate limiter goroutine. Safe to call multiple times.

func (*RateLimiter) Wait

func (rl *RateLimiter) Wait(ctx context.Context) error

Wait blocks until a token is available or context is cancelled.

type Tool

type Tool = iteragent.Tool

func MutationTestTool

func MutationTestTool(repoPath string) Tool

MutationTestTool runs go-mutesting to find untested code paths. Requires: go install github.com/zimmski/go-mutesting/cmd/go-mutesting@latest

Jump to

Keyboard shortcuts

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