agents

package
v0.1.0-alpha.39 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package agents is the public Go authoring surface for GoBeyond agents.

An agent is authored in agents/<id>/agent.go as an exported package var:

var Agent = agents.Define(agents.Config{Durable: true}, Run, agents.Slots{...})

The project compiler reads that declaration without executing it. Direct execution is the zero-value default; Durable opts the agent into a durable run and requires the generated workflow wiring supplied by the compiler.

Index

Constants

View Source
const LoopbackDevActorID = "dev-loopback"

LoopbackDevActorID identifies the development-only loopback actor.

Variables

This section is empty.

Functions

func ToolTaskQueue

func ToolTaskQueue(tool AITool) string

ToolTaskQueue returns the logical task queue embedded by DefineTool. It is used by compiler-generated durable dispatch and never interpreted by model providers.

Types

type AIConfig

type AIConfig struct {
	TaskQueue string
	Durable   bool
	Realtime  bool
	Public    bool

	Model        string
	MaxSteps     int
	Tools        map[string]ai.Tool
	Provider     ai.Provider
	Instructions string
	Revision     string

	DurableUpdates             DurableUpdateStore
	OnReviewPublicationFailure func(context.Context, updates.UpdateEvent, error)
}

AIConfig declares a framework-owned model/tool loop. Model uses provider/model syntax for the built-in providers (anthropic, openrouter, bedrock, and vertex). Provider may be supplied for a custom provider; its credentials and mutable configuration remain runtime-only.

type AIDefinition

type AIDefinition struct {
	Config Config
	AI     AIConfig
	Slots  Slots
}

AIDefinition is the fixed conversational agent definition produced by DefineAI. The compiler fills Instructions and Revision from instructions.md and the compiled filesystem definition.

func DefineAI

func DefineAI(config AIConfig, slots ...Slots) AIDefinition

DefineAI declares a framework-owned conversational AI agent. The authored folder must also contain instructions.md; the project compiler embeds it in the generated registration.

func (AIDefinition) Invoke

func (definition AIDefinition) Invoke(ctx context.Context, actor Actor, input AIInput) (AIOutput, error)

Invoke runs the Go AI SDK tool loop without exposing provider construction, prompt conversion, or callback plumbing to authored agents.

func (AIDefinition) LanguageModel

func (definition AIDefinition) LanguageModel() (ai.LanguageModel, error)

LanguageModel resolves the authored model reference. Built-in providers read their normal environment credentials; no secret is copied into manifests or Temporal workflow input.

func (AIDefinition) RuntimeProvider

func (definition AIDefinition) RuntimeProvider() ai.Provider

RuntimeProvider binds Temporal activity lookups to this process-local definition. Provider values are never serialized into workflow input.

func (AIDefinition) Stream

func (definition AIDefinition) Stream(ctx context.Context, actor Actor, input AIInput) (*ai.StreamTextResult, error)

Stream starts the Go AI SDK streaming tool loop. The caller owns consuming the returned stream before reading its final result fields.

func (AIDefinition) ValidateRegistration

func (definition AIDefinition) ValidateRegistration() error

ValidateRegistration rejects capabilities that the native GoBeyond agent transport cannot complete safely yet. Approval-gated tools must not enter either direct or durable registries until pending interactions are delivered through the native session event contract.

type AIInput

type AIInput struct {
	Prompt   string      `json:"prompt,omitempty"`
	Message  string      `json:"message,omitempty"`
	Text     string      `json:"text,omitempty"`
	Messages []AIMessage `json:"messages,omitempty"`
}

AIInput accepts both prompt-oriented callers and AI SDK chat transports. Prompt wins over the Message/Text convenience aliases when more than one is provided.

func (AIInput) PromptText

func (input AIInput) PromptText() string

PromptText and ToAIMessages expose the canonical conversion to framework runtimes while keeping transport-specific UI message parsing in one place.

func (AIInput) ToAIMessages

func (input AIInput) ToAIMessages() ([]ai.Message, error)

type AIMessage

type AIMessage struct {
	Role    string          `json:"role"`
	Content string          `json:"content,omitempty"`
	Parts   []AIMessagePart `json:"parts,omitempty"`
}

AIMessage is the text-message subset shared by the native HTTP client and AI SDK chat transports. Content supports simple clients; Parts supports AI SDK UIMessage text parts.

type AIMessagePart

type AIMessagePart struct {
	Type string `json:"type"`
	Text string `json:"text,omitempty"`
}

type AIOutput

type AIOutput struct {
	Text            string `json:"text"`
	FinishReason    string `json:"finishReason,omitempty"`
	RawFinishReason string `json:"rawFinishReason,omitempty"`
	Model           string `json:"model,omitempty"`
}

AIOutput is the stable native agent.output payload for both direct and durable AI agents.

type AITool

type AITool = ai.Tool

AITool is the Go AI SDK tool definition used by a filesystem agent. Keeping the alias here lets authored agents define tools without importing framework runtime packages.

func DefineTool

func DefineTool[Input any, Output any](config ToolConfig, handler ToolHandler[Input, Output]) AITool

DefineTool adapts a typed, actor-aware application function to the Go AI SDK tool contract. Model input is schema-validated by go-ai before this decoder runs; the authenticated actor comes from framework-owned runtime context.

type Actor

type Actor struct {
	ID       string            `json:"id"`
	Kind     string            `json:"kind"`
	Metadata map[string]string `json:"metadata,omitempty"`
}

Actor is the authenticated principal that invoked an agent. Identity is explicit so direct and durable invocations have the same author-facing type.

func DevLoopbackActor

func DevLoopbackActor() Actor

DevLoopbackActor is an alias for LoopbackDevActor kept for call sites that read the environment qualifier first.

func LoopbackDevActor

func LoopbackDevActor() Actor

LoopbackDevActor returns the typed actor used by local development when no external identity provider is configured. Hosted runtimes must supply their authenticated actor explicitly.

func (Actor) Validate

func (actor Actor) Validate() error

Validate rejects incomplete actor identities before an agent is invoked.

type Channel

type Channel struct {
	ID string
}

type Config

type Config struct {
	TaskQueue string
	Durable   bool
	// Realtime keeps the agent durable while selecting a compiler-owned,
	// agent-unique task queue and local model/tool activity boundaries. It is
	// intentionally an execution hint rather than a persistence mode.
	Realtime bool
	Public   bool
}

Config is compiler-visible agent metadata. TaskQueue is a logical queue name; generated durable workers append the active environment suffix.

func (Config) Mode

func (config Config) Mode() Mode

Mode resolves the configured execution model. The zero value is direct.

type Definition

type Definition[Input any, Output any] struct {
	Config  Config
	Handler Handler[Input, Output]
	Slots   Slots
}

Definition associates compiler-visible metadata with a typed handler.

func Define

func Define[Input any, Output any](config Config, handler Handler[Input, Output], slots ...Slots) Definition[Input, Output]

Define declares an agent. Omitting slots is equivalent to Slots{}.

func (Definition[Input, Output]) Invoke

func (definition Definition[Input, Output]) Invoke(ctx context.Context, actor Actor, input Input) (Output, error)

Invoke runs the typed handler after validating the actor. Durable dispatch is intentionally compiler/runtime-owned; this method remains useful for direct agents and loopback development tests.

type DurableRunInput

type DurableRunInput struct {
	Session Session         `json:"session"`
	Run     Run             `json:"run"`
	Actor   Actor           `json:"actor"`
	Input   json.RawMessage `json:"input"`
}

DurableRunInput is the serialization contract shared by the HTTP Temporal dispatcher and compiler-generated durable agent workflows. Generated workflows pass Input to the typed agent activity after decoding it there.

type DurableRunOutput

type DurableRunOutput struct {
	Output json.RawMessage `json:"output"`
}

DurableRunOutput is returned by compiler-generated durable agent workflows. Output must contain one complete JSON value so the transport can publish the same agent.output event shape used by direct agents.

type DurableUpdateStore

type DurableUpdateStore interface {
	updates.PreviewStore
	updates.RecordStore
}

DurableUpdateStore is the customer-owned durable half of a hosted agent conversation connector. GoBeyond never receives its credentials. Hosted workers compose it with the slot-private host review publisher; local workers keep using the durable store without requiring platform services.

type Handler

type Handler[Input any, Output any] func(context.Context, Actor, Input) (Output, error)

Handler is the type-safe authoring signature for an agent run.

type Mode

type Mode string

Mode describes how a run is executed.

const (
	// DirectMode executes in the request/runtime process. It is the default.
	DirectMode Mode = "direct"
	// DurableMode executes through the generated durable workflow runtime.
	DurableMode Mode = "durable"
)

type ModelMetadata

type ModelMetadata struct {
	Provider string `json:"provider,omitempty"`
	Model    string `json:"model,omitempty"`
}

ModelMetadata identifies the model selected for a run without leaking provider credentials or mutable runtime configuration into authored code.

type Run

type Run struct {
	ID        string        `json:"id"`
	SessionID string        `json:"sessionId"`
	AgentID   string        `json:"agentId"`
	Mode      Mode          `json:"mode"`
	TaskQueue string        `json:"taskQueue,omitempty"`
	Model     ModelMetadata `json:"model,omitempty"`
	Status    string        `json:"status"`
	CreatedAt time.Time     `json:"createdAt"`
	UpdatedAt time.Time     `json:"updatedAt"`
}

Run is one execution attempt in a session. TaskQueue is empty for direct runs unless the host records a selected logical queue for observability.

type Schedule

type Schedule struct {
	ID   string
	Cron string
}

type Session

type Session struct {
	ID        string            `json:"id"`
	AgentID   string            `json:"agentId"`
	Actor     Actor             `json:"actor"`
	Model     ModelMetadata     `json:"model,omitempty"`
	CreatedAt time.Time         `json:"createdAt"`
	UpdatedAt time.Time         `json:"updatedAt"`
	Metadata  map[string]string `json:"metadata,omitempty"`
}

Session is the durable conversation identity shared by one or more runs.

type Skill

type Skill struct {
	ID string
}

type Slots

type Slots struct {
	Tools     []Tool
	Skills    []Skill
	Subagents []Subagent
	Schedules []Schedule
	Channels  []Channel
}

Slots declares every extensibility slot on an agent in one compiler-visible literal. Empty slots are valid and do not change the direct default.

type Subagent

type Subagent struct {
	ID string
}

type Tool

type Tool struct {
	ID string
}

Tool, Skill, Subagent, Schedule, and Channel are compiler-visible slots. IDs are stable authored references; their provider-specific implementations are deliberately kept outside this initial package boundary.

type ToolConfig

type ToolConfig struct {
	Name        string
	Title       string
	Description string
	// TaskQueue is a logical Temporal queue. Durable agents inherit their own
	// resolved queue when this is empty. Realtime agents reject explicit tool
	// queues because their tools execute as local activities.
	TaskQueue        string
	InputSchema      any
	OutputSchema     any
	RequiresApproval bool
}

ToolConfig is the provider-neutral authoring surface for a model-callable function. Schemas use ordinary JSON Schema values (usually map[string]any).

type ToolHandler

type ToolHandler[Input any, Output any] func(context.Context, Actor, Input) (Output, error)

Directories

Path Synopsis
Package httpruntime provides the local HTTP transport for GoBeyond agents.
Package httpruntime provides the local HTTP transport for GoBeyond agents.
Package temporalruntime dispatches durable agent runs to compiler-generated Temporal workflows.
Package temporalruntime dispatches durable agent runs to compiler-generated Temporal workflows.

Jump to

Keyboard shortcuts

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