react

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Overview

Package react is the tool-calling agent loop, written as an agentkit Strategy: generate, run the tool calls the model asked for, feed the results back, repeat until it answers without asking for a tool.

It splits that loop finer than a conventional implementation would: one transition is either ONE LLM call or ONE tool call, never both and never several. Every transition is checkpointed before the next starts, so a crash costs at most one call, and a run can move between instances at any point.

The bundled agentkit strategy/simple is deliberately not used. It fixes the system prompt at registration time (this application's prompts are built per case), and it runs every pending tool call inside one transition (which is the opposite of the split above).

It lives under pkg/agent rather than pkg/usecase because it is runtime machinery the kernel drives: it holds no business rule, reaches no repository, and its method set is fixed by agentkit.Strategy — Init, Step, EncodeState and the rest take what the library passes them, not a request context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(reg *agentkit.Registry, name agentkit.AgentName, version int,
	limiter agentkit.Limiter, opts ...agentkit.RegisterOption[Output],
) (agentkit.Agent[Input], error)

Register registers the strategy under name and returns the typed handle.

limiter is the budget this agent answers Limit with; it is required, because a run with no ceiling is a run that can spend without bound.

func RegisterWithOptions

func RegisterWithOptions(reg *agentkit.Registry, name agentkit.AgentName, version int,
	limiter agentkit.Limiter, strategyOpts []Option, opts ...agentkit.RegisterOption[Output],
) (agentkit.Agent[Input], error)

RegisterWithOptions is Register plus strategy options.

Types

type Input

type Input struct {
	// SystemPrompt is the agent's persistent context.
	SystemPrompt string `json:"system_prompt"`
	// Prompt is the first user message.
	Prompt string `json:"prompt"`
}

Input is the launch input. Both fields are required: this strategy knows nothing about cases or workspaces, so the host supplies the finished prompts.

type Option

type Option func(*config)

Option configures the strategy.

func WithRole

func WithRole(r agentkit.ModelRole) Option

WithRole selects the model role every Generate runs under. Omitting it uses the Kernel's default model.

type Output

type Output struct {
	// Texts is every text block the model emitted across the run, in order.
	Texts []string `json:"texts"`
}

Output is what a finished run produces.

func DecodeOutput

func DecodeOutput(raw []byte) (Output, error)

DecodeOutput reads back the bytes a finished Process stored. agentkit hands a parent only its child's raw output, so a caller collecting sub-agent results needs this; the kernel itself never calls it.

func (Output) Text

func (o Output) Text() string

Text joins the emitted blocks into the single reply a host posts.

Jump to

Keyboard shortcuts

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