agentrun

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package agentrun orchestrates the coding-agent stages inside the Job pod: render the prompts, drive the classification harness, decide whether to continue, drive the remediation harness under a token-budget kill switch, verify and package the resulting changeset, and report every stage as an envelope event on stdout.

The runner trusts the repository over the agent: a remediation report claiming success is downgraded unless commit.sh ran cleanly and left real commits on the branch. It never talks to GitHub — the pod has no GitHub credentials by design; the remediation-controller owns every side effect.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

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

Agent drives the stages.

func New

func New(cfg Config, exec Executor) *Agent

New builds an Agent.

func (*Agent) Run

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

Run executes the configured phase. It returns an error only for fatal, before-any-stage failures (also emitted as a fatal event); stage outcomes — including failed stages — are envelope events with a nil return, so the controller, not the Job status, routes the issue.

type Config

type Config struct {
	Workspace string
	Repo      string
	Issue     int
	Phase     Phase

	ClassifyHarness  string
	RemediateHarness string
	ClassifyModel    string
	// RemediateModel is the model the remediation stage runs on when the
	// classification's suggestion is missing or not allowlisted.
	RemediateModel string
	ModelAllowlist []string

	// The classification stage's limits are absolute: it runs on exactly
	// these. The remediation stage's are ceilings — the classification
	// requests its own max_turns and token_budget, and Agent.clamp holds
	// those requests to these bounds.
	ClassifyMaxTurns     int
	ClassifyTokenBudget  int
	RemediateMaxTurns    int
	RemediateTokenBudget int
	ClassifyTimeout      time.Duration
	RemediateTimeout     time.Duration

	ConfidenceThreshold float64
	// DefaultBranch is the clone's base branch (bundle base).
	DefaultBranch  string
	BundleMaxBytes int

	// Out receives the envelope events (stdout in the pod).
	Out io.Writer
	Log *slog.Logger
}

Config is the runner's configuration; in the pod every field arrives as PATCHY_* environment (see FromEnv).

func FromEnv

func FromEnv(getenv func(string) string) (Config, error)

FromEnv builds the pod configuration from PATCHY_* environment variables, applying defaults.

type Executor

type Executor interface {
	Run(ctx context.Context, spec runner.CommandSpec, timeout time.Duration,
		onLine func([]byte) (bool, string)) (runner.Result, error)
}

Executor runs harness command specs; *runner.Exec satisfies it, tests fake it.

type Phase

type Phase string

Phase selects which stages run.

const (
	PhaseFull      Phase = "classify+remediate"
	PhaseRemediate Phase = "remediate"
)

PhaseFull runs classification and (on a qualifying verdict) remediation; PhaseRemediate runs remediation only, from a controller-provided classification — the /approve re-run.

Jump to

Keyboard shortcuts

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