agent

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package agent runs one turn. The model proposes, policy decides, and the follow-up pack goes back to the caller.

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyPack = errors.New("empty context pack")

Functions

This section is empty.

Types

type Call

type Call = runtime.Result

Call is the invoke outcome. The loop does not reshape it.

type Completer

type Completer interface {
	Complete(ctx context.Context, req Request) (Response, error)
}

type Executor

type Executor = runtime.Executor

Executor performs the HTTP call. The loop does not build the request.

type Loop

type Loop struct {
	Catalog   *catalog.Catalog
	Semantics semantics.Notes
	Model     Completer
	Policy    policy.Hook

	State  *policy.State
	Exec   Executor
	Notify policy.Notifier
	Memory Memory
	Flows  map[string]*flow.Definition
	Packs  *runctx.Builder

	JSON    jsonopts.Set
	Pages   int
	MaxBody int64
	// contains filtered or unexported fields
}

The follow-up pack is returned. The model is not called again.

func New

func New(cat *catalog.Catalog, sem semantics.Notes, exec Executor) (*Loop, error)

func (*Loop) Follow

func (l *Loop) Follow(ctx context.Context, operationID string, params map[string]string, approvalID string) ([]Call, error)

Follow runs operationID through Invoke, then each declared relation or link that names a value. A link with no parameter mapping is not called. A missing response field is an error.

func (*Loop) Invoke

func (l *Loop) Invoke(ctx context.Context, operationID string, params map[string]string, approvalID string) (Call, error)

func (*Loop) Run

func (l *Loop) Run(ctx context.Context, userText string) (Outcome, error)

func (*Loop) Runtime

func (l *Loop) Runtime() runtime.Runtime

Runtime is the invoke sequence this loop uses. Policy and state are the loop's current values. The snapshot copies exported fields. The shared runtime, including its gate lock, stays on RuntimePtr.

func (*Loop) RuntimePtr added in v0.1.8

func (l *Loop) RuntimePtr() *runtime.Runtime

RuntimePtr is the runtime Invoke uses. A shared runtime is that pointer.

func (*Loop) SetFloor

func (l *Loop) SetFloor(hook policy.Hook)

func (*Loop) SetGate added in v0.1.6

func (l *Loop) SetGate(gate *runtime.InvokeGate)

SetGate shares one limiter with another Runtime.

func (*Loop) SetInvokeLimit added in v0.1.1

func (l *Loop) SetInvokeLimit(n int)

SetInvokeLimit sets calls per second per caller. Zero keeps 16.

func (*Loop) SetPolicy

func (l *Loop) SetPolicy(hook policy.Hook)

func (*Loop) SetRuntime added in v0.1.8

func (l *Loop) SetRuntime(rt *runtime.Runtime)

SetRuntime uses rt for invoke. The loop still owns the model, memory, and context pack.

func (*Loop) WrapPolicy

func (l *Loop) WrapPolicy(around policy.Around)

type Memory

type Memory interface {
	Store(ctx context.Context, item memory.Item) error
	Search(ctx context.Context, query string) ([]memory.Item, error)
	Recent(ctx context.Context, n int) ([]memory.Item, error)
}

type Outcome

type Outcome struct {
	OperationID string
	Status      string
	ApprovalID  string
	Text        string
	Pack        runctx.Pack
	Result      runtime.Result
}

type Request

type Request struct {
	UserMessage string
	Context     string
}

type Response

type Response struct {
	OperationID string
	Params      map[string]string
	FlowName    string
}

type Scripted

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

func NewScripted

func NewScripted() *Scripted

func (*Scripted) Complete

func (s *Scripted) Complete(ctx context.Context, req Request) (Response, error)

func (*Scripted) WithOperation

func (s *Scripted) WithOperation(operationID string) *Scripted

Directories

Path Synopsis
Package openai calls the OpenAI HTTP API for the openai provider key.
Package openai calls the OpenAI HTTP API for the openai provider key.

Jump to

Keyboard shortcuts

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