Documentation
¶
Index ¶
Constants ¶
const ( ErrAbout = faults.Type("execution aborted") ErrMaxEpoch = faults.Safe1[int]("max epoch %d is reached") ErrCmdConflict = faults.Type("command already exists") ErrCmdInvalid = faults.Type("invalid command specification, missing requored attributes") )
Common agents errors
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cmd ¶
type Cmd struct {
// [Required] A unique name for the command, used as a reference by LLMs (e.g., "bash").
Cmd string
// [Required] A concise, one-line description of the command and its purpose.
// Used to define the command registry for LLMs.
Short string
// [Required] Concise instructions on the command's syntax.
// For example: "bash <command>".
Syntax string
// [Optional] A detailed, multi-line description to educate the LLM on command usage.
// Provides contextual information on how and when to use the command.
Long string
// [Optional] Specifies arguments, types, and additional context to guide
// the LLM on command syntax.
Args []string
// The actual command execution function, which can be defined statically or
// dynamically upon registration.
Run func(chatter.Reply) (float64, CmdOut, error)
}
A Command defines an external tool or utility available to the agent for task-solving. To ensure usability, each command must include a usage definition and description.
type CmdOut ¶
type CmdOut struct {
// A unique name of the command, used to getnerate output.
Cmd string
// Output of the command.
Output string
}
Container for command results.
type Decoder ¶
type Decoder[T any] interface { // The transformer "parses" reply into type T and return the confidence about // the result on the interval [0, 1]. The function should return the feedback // to LLM if reply cannot be processed. FMap(chatter.Reply) (float64, T, error) }
Used by agent to converts LLM's reply into structured object.
type Encoder ¶
type Encoder[T any] interface { // Encodes type T into LLM prompt. FMap(T) (chatter.Prompt, error) }
Used by agtent to converts structured object into LLM prompt.
type Memory ¶
type Memory interface {
// Commit new observation into memory.
Commit(*Observation)
// Builds the context window for LLM using incoming prompt.
Context(chatter.Prompt) []fmt.Stringer
}
Memory is core element of agents behaviour. It is a database that maintains a comprehensive record of an agent’s experience. It recalls observations and builds the context windows to be used for prompting.
See package `memory` that implements various algorithms
type Observation ¶
The observation made by agent, it contains LLMs prompt, reply, environment status and other metadata.
func NewObservation ¶
func NewObservation(query chatter.Prompt, reply chatter.Reply) *Observation
Create new observation
type Phase ¶
type Phase int
Execution phase of the agent
const ( // Agent is asking for new facts from LLM AGENT_ASK Phase = iota // Agent has a final result to return AGENT_RETURN // Agent should retry with the same context AGENT_RETRY // Agent should refine the prompt based on feedback AGENT_REFINE // Agent aborts processing due to unrecoverable error AGENT_ABORT )
type Reasoner ¶
type Reasoner[A, B any] interface { // Deduct new goal for the agent to pursue. Deduct(State[A, B]) (Phase, chatter.Prompt, error) }
The Reasoner serves as the goal-setting component in the architecture. It evaluates the agent's current state, performing either deterministic or non-deterministic analysis of immediate results and past experiences. Based on this assessment, it determines whether the goal has been achieved and, if not, suggests the best new goal for the agent to pursue.
type State ¶
type State[A, B any] struct { // Execution phase of the agent Phase Phase // Current epoch of execution phase Epoch int // Input to LLM Input A // Reply from LLM Reply B // Confidence level of obtained results Confidence float64 // Feedback to LLM Feedback chatter.Section }
State of the agent, maintained by the agent and used by Reasoner.