agent

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultStreamBufferSize = 32

DefaultStreamBufferSize is the default channel buffer size for streaming events.

Variables

This section is empty.

Functions

func RunStreamText

func RunStreamText(ctx context.Context, a StreamAgent, input string) (*schema.RunStream, error)

RunStreamText is a convenience function that sends a single text message and returns a streaming response. The agent must implement StreamAgent.

func RunText

func RunText(ctx context.Context, a Agent, input string) (*schema.RunResponse, error)

RunText is a convenience function that sends a single text message to an agent.

func RunToStream

func RunToStream(ctx context.Context, a Agent, req *schema.RunRequest) *schema.RunStream

RunToStream wraps a non-streaming Agent.Run call as a RunStream, emitting AgentStart and AgentEnd lifecycle events.

Types

type Agent

type Agent interface {
	Run(ctx context.Context, req *schema.RunRequest) (*schema.RunResponse, error)
	ID() string
	Name() string
	Description() string
}

Agent is the core interface for all agent types.

type Base

type Base struct {
	AgentID          string
	AgentName        string
	AgentDescription string
}

Base implements ID/Name/Description for embedding into concrete agent types.

func NewBase

func NewBase(cfg Config) Base

NewBase creates a Base from the given Config.

func (*Base) Description

func (m *Base) Description() string

func (*Base) ID

func (m *Base) ID() string

func (*Base) Name

func (m *Base) Name() string

type Config

type Config struct {
	ID          string
	Name        string
	Description string
}

Config holds the common configuration shared by all agent types.

type CustomAgent

type CustomAgent struct {
	Base
	// contains filtered or unexported fields
}

CustomAgent delegates its Run to a user-provided RunFunc.

func NewCustomAgent

func NewCustomAgent(cfg Config, fn RunFunc) *CustomAgent

NewCustomAgent creates a CustomAgent with the given RunFunc.

func (*CustomAgent) Run

Run delegates to the configured RunFunc. Returns an error if RunFunc is nil.

type RunFunc

type RunFunc func(ctx context.Context, req *schema.RunRequest) (*schema.RunResponse, error)

RunFunc is the function signature used by CustomAgent.

type StreamAgent

type StreamAgent interface {
	Agent
	RunStream(ctx context.Context, req *schema.RunRequest) (*schema.RunStream, error)
}

StreamAgent extends Agent with streaming support.

type StreamMiddleware

type StreamMiddleware func(next func(schema.Event) error) func(schema.Event) error

StreamMiddleware wraps a send function to intercept, transform, or observe events.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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