planexec

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package planexec provides a plan/execute/replan strategy: an LLM planner decomposes the prompt into parallel tasks, each task runs as a child Process (any Agent[T], adapted via makeInput), the results are collected, and the planner decides to iterate or finalize. A summarizer produces the final answer. It does at most one LLM Generate per transition (checkpointing between phases via the Phase field), which keeps replay cheap and avoids relying on intra-transition determinism (agentkit is at-least-once, D44).

The one deliberate exception is E24: when a plan response is not valid JSON, the plan transition issues a single in-transition correction Generate before giving up, rather than failing the whole transition and relying on backoff.

Index

Constants

This section is empty.

Variables

View Source
var (
	RolePlanner    = agentkit.DefineModelRole("planexec.planner")
	RoleSummarizer = agentkit.DefineModelRole("planexec.summarizer")
)

Roles are exported as package variables (identity binding, D32). Unbound roles fall back to the default model.

Functions

func Register

func Register[T any](r *agentkit.Registry, name agentkit.AgentName, version int,
	taskAgent agentkit.Agent[T], makeInput func(TaskSpec) (T, error),
	opts ...Option) (agentkit.Agent[Input], error)

Register builds and registers the planexec strategy. It is generic over the task agent's input type T: makeInput adapts each planned TaskSpec into the child input T, so any Agent[T] can be a task (D50). taskAgent's zero value or a nil makeInput is rejected (ErrInvalidAgentDef).

Types

type Input

type Input struct {
	Prompt string `json:"prompt"`
}

Input is planexec's own launch input (required; empty prompt is rejected by Init).

type Option

type Option func(*config)

Option configures the strategy.

func WithLimiter

func WithLimiter(f agentkit.Limiter) Option

WithLimiter sets this agent's execution budget, which Strategy.Limit answers with. Default: none, i.e. LimitPass at every check.

This is a different question from WithMaxRounds: that one is an algorithm parameter the planner is even told about, while a limiter sees the kernel's counters. Those include every terminated child, so on a planexec parent one limiter is a budget for the whole fan-out.

func WithMaxParallelTasks

func WithMaxParallelTasks(n int) Option

WithMaxParallelTasks caps tasks per round (reflected as the plan schema maxItems). Default: 5.

func WithMaxRounds

func WithMaxRounds(n int) Option

WithMaxRounds caps the plan/replan rounds. Default: 3. Reaching it forces finalize.

func WithOnFinish

func WithOnFinish(h agentkit.FinishHandler[Output]) Option

WithOnFinish wires a completion handler for this agent. Delivery is best-effort; see agentkit.WithOnFinish.

func WithSystemPrompt

func WithSystemPrompt(p string) Option

WithSystemPrompt sets the system prompt for planner/summarizer Generates. Default: "".

type Output

type Output struct {
	Summary []string     `json:"summary"`
	Tasks   []TaskResult `json:"tasks"`
}

Output is the Done output.

type TaskResult

type TaskResult struct {
	Title     string                 `json:"title"`
	Status    agentkit.ProcessStatus `json:"status"`
	ProcessID agentkit.ProcessID     `json:"process_id"`
	Output    []byte                 `json:"output,omitempty"`
}

TaskResult is one task's outcome. Output carries the child's Output verbatim on success (its interpretation is the caller's, D40).

type TaskSpec

type TaskSpec struct {
	Title  string `json:"title"`
	Prompt string `json:"prompt"`
}

TaskSpec is one task the planner emits (planexec public type).

Jump to

Keyboard shortcuts

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