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.
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 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 ¶
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.