agent

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: Apache-2.0 Imports: 20 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

This section is empty.

Functions

This section is empty.

Types

type Call

type Call struct {
	Status      string
	ApprovalID  string
	OperationID string
	HTTPStatus  int
	Body        string
	Code        string
	Retryable   bool
	Error       string
	Truncated   bool
	Page        *result.Page
	RetryAfter  string
}

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 Notes
	Model     Completer
	Policy    policy.Hook

	State  *policy.State
	Exec   Executor
	Notify policy.Notifier
	Memory Memory
	Flows  map[string]*flow.Definition
	Packs  *runctx.Builder
	// 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 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.

func (*Loop) SetFloor

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

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) 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 Notes

type Notes interface {
	Note(operationID string) semantics.Note
	AllSynonyms() map[string][]string
}

type Outcome

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

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