agent

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package agent provides the agent runtime pool and runner for processing tasks as goroutines with session lifecycle management and cost recording.

Index

Constants

This section is empty.

Variables

View Source
var ErrPoolShutdown = errors.New("pool is shut down")

ErrPoolShutdown is returned when Submit is called on a shut-down pool.

Functions

This section is empty.

Types

type Pool

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

Pool manages a fixed set of worker goroutines that process agent tasks.

func NewPool

func NewPool(registry *provider.Registry, tracker forge.IssueTracker, st store.Store, costs *cost.Tracker, workers int) *Pool

NewPool creates a pool with the given number of worker goroutines and starts them immediately. If workers is <= 0, it defaults to 3.

func (*Pool) Done

func (p *Pool) Done() <-chan struct{}

Done returns a channel that is closed after Shutdown completes.

func (*Pool) Shutdown

func (p *Pool) Shutdown()

Shutdown signals all workers to stop and waits for in-flight tasks to complete. After Shutdown returns, Submit will return ErrPoolShutdown.

func (*Pool) Submit

func (p *Pool) Submit(task Task) error

Submit enqueues a task for processing. Returns ErrPoolShutdown if the pool has been shut down.

type Runner

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

Runner executes a single agent task: sends the issue to an AI provider, records cost, and posts the response as an issue comment.

func NewRunner

func NewRunner(p provider.Provider, model string, tracker forge.IssueTracker, st store.Store, costs *cost.Tracker) *Runner

NewRunner creates a runner bound to a specific provider and model.

func (*Runner) Run

func (r *Runner) Run(ctx context.Context, task Task) error

Run processes a single task through the AI provider pipeline.

Steps:

  1. Update session status to "active"
  2. Check budget -- if exceeded, mark "failed" and return
  3. Build system prompt and chat request
  4. Call provider.Chat
  5. Record cost via cost tracker
  6. Post response as issue comment
  7. Mark session "completed"

On any error, the session is marked "failed" and an error comment is posted.

type Task

type Task struct {
	Issue     *forge.Issue
	AgentType models.AgentType
	SessionID string
}

Task represents a unit of work to be processed by the agent pool.

Jump to

Keyboard shortcuts

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