runtime

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2025 License: AGPL-3.0 Imports: 31 Imported by: 0

Documentation

Overview

Package runtime builds and manages Hector agents from configuration.

The runtime is the bridge between declarative config and live agents. It creates LLM providers, tools, and agents based on the configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultEmbedderFactory

func DefaultEmbedderFactory(cfg *config.EmbedderConfig) (embedder.Embedder, error)

DefaultEmbedderFactory creates Embedder instances based on provider type. Uses the builder package as its foundation to ensure a single code path for both configuration-based and programmatic API usage.

func DefaultLLMFactory

func DefaultLLMFactory(cfg *config.LLMConfig) (model.LLM, error)

DefaultLLMFactory creates LLM instances based on provider type. Uses the builder package as its foundation to ensure a single code path for both configuration-based and programmatic API usage.

func DefaultToolsetFactory

func DefaultToolsetFactory(name string, cfg *config.ToolConfig) (tool.Toolset, error)

DefaultToolsetFactory creates toolset instances based on tool type. Uses the builder package as its foundation for MCP toolsets to ensure a single code path for both configuration-based and programmatic API usage.

func DefaultWorkingMemoryFactory

func DefaultWorkingMemoryFactory(opts WorkingMemoryFactoryOptions) (memory.WorkingMemoryStrategy, error)

DefaultWorkingMemoryFactory creates a working memory strategy from config. Uses the builder package as its foundation to ensure a single code path for both configuration-based and programmatic API usage. Returns nil if no context config is set or strategy is "none".

Types

type EmbedderFactory

type EmbedderFactory func(cfg *config.EmbedderConfig) (embedder.Embedder, error)

EmbedderFactory creates an Embedder from config.

type LLMFactory

type LLMFactory func(cfg *config.LLMConfig) (model.LLM, error)

LLMFactory creates an LLM from config.

type Option

type Option func(*Runtime)

Option configures the runtime.

func WithAgentTools

func WithAgentTools(agentName string, agentTools []agent.Agent) Option

WithAgentTools adds agents as tools for an agent (Pattern 2: delegation). The parent agent can call these as tools and receive structured results.

func WithCheckpointManager

func WithCheckpointManager(mgr *checkpoint.Manager) Option

WithCheckpointManager sets a custom checkpoint manager.

func WithDBPool

func WithDBPool(pool *config.DBPool) Option

WithDBPool sets the shared database pool for SQL backends. Required when SQL persistence is configured without explicit services.

func WithDirectTools

func WithDirectTools(agentName string, tools []tool.Tool) Option

WithDirectTools adds tools directly for an agent.

func WithEmbedderFactory

func WithEmbedderFactory(f EmbedderFactory) Option

WithEmbedderFactory sets a custom embedder factory.

func WithIndexService

func WithIndexService(idx memory.IndexService) Option

WithIndexService sets a custom index service.

func WithLLMFactory

func WithLLMFactory(f LLMFactory) Option

WithLLMFactory sets a custom LLM factory.

func WithObservability

func WithObservability(obs *observability.Manager) Option

WithObservability sets a custom observability manager.

func WithSessionService

func WithSessionService(s session.Service) Option

WithSessionService sets a custom session service.

func WithSubAgents

func WithSubAgents(agentName string, subAgents []agent.Agent) Option

WithSubAgents adds sub-agents for an agent (Pattern 1: transfer). Transfer tools are automatically created for each sub-agent.

func WithToolsetFactory

func WithToolsetFactory(f ToolsetFactory) Option

WithToolsetFactory sets a custom toolset factory.

type Runtime

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

Runtime manages the lifecycle of Hector agents built from config.

func New

func New(cfg *config.Config, opts ...Option) (*Runtime, error)

New creates a new Runtime from config.

func (*Runtime) CheckpointManager

func (r *Runtime) CheckpointManager() *checkpoint.Manager

CheckpointManager returns the checkpoint manager. Returns nil if checkpointing is not configured.

func (*Runtime) Close

func (r *Runtime) Close() error

Close shuts down the runtime and releases resources.

func (*Runtime) Config

func (r *Runtime) Config() *config.Config

Config returns the runtime's configuration.

func (*Runtime) DefaultAgent

func (r *Runtime) DefaultAgent() (agent.Agent, bool)

DefaultAgent returns the first agent (primary/default agent).

func (*Runtime) DefaultRunnerConfig

func (r *Runtime) DefaultRunnerConfig() (*runner.Config, error)

DefaultRunnerConfig creates a runner.Config for the default agent.

func (*Runtime) DocumentStores

func (r *Runtime) DocumentStores() map[string]*rag.DocumentStore

DocumentStores returns all document stores.

func (*Runtime) GetAgent

func (r *Runtime) GetAgent(name string) (agent.Agent, bool)

GetAgent returns an agent by name.

func (*Runtime) GetDocumentStore

func (r *Runtime) GetDocumentStore(name string) (*rag.DocumentStore, bool)

GetDocumentStore returns a document store by name.

func (*Runtime) GetLLM

func (r *Runtime) GetLLM(name string) (model.LLM, bool)

GetLLM returns an LLM by name.

func (*Runtime) IndexDocumentStores

func (r *Runtime) IndexDocumentStores(ctx context.Context) error

IndexDocumentStores indexes all document stores. This should be called after runtime initialization to populate the indexes. It can be called asynchronously to avoid blocking startup.

func (*Runtime) IndexService

func (r *Runtime) IndexService() memory.IndexService

IndexService returns the index service.

func (*Runtime) ListAgents

func (r *Runtime) ListAgents() []string

ListAgents returns all agent names.

func (*Runtime) Metrics

func (r *Runtime) Metrics() *observability.Metrics

Metrics returns the metrics recorder. Returns nil if metrics are not enabled.

func (*Runtime) NewAuthValidator

func (r *Runtime) NewAuthValidator() (auth.TokenValidator, error)

NewAuthValidator creates a JWT validator from the server auth config. Returns nil if authentication is not enabled.

func (*Runtime) Observability

func (r *Runtime) Observability() *observability.Manager

Observability returns the observability manager. Returns nil if observability is not configured.

func (*Runtime) Reload

func (r *Runtime) Reload(newCfg *config.Config) error

Reload rebuilds the runtime with new config (hot-reload). Sessions and memory are preserved, only LLMs/agents/tools are rebuilt.

func (*Runtime) RunnerConfig

func (r *Runtime) RunnerConfig(agentName string) (*runner.Config, error)

RunnerConfig creates a runner.Config for the given agent.

func (*Runtime) SessionService

func (r *Runtime) SessionService() session.Service

SessionService returns the session service.

func (*Runtime) StartDocumentStoreWatching

func (r *Runtime) StartDocumentStoreWatching(ctx context.Context) error

StartDocumentStoreWatching starts file watching for all document stores. This enables automatic re-indexing when documents change.

func (*Runtime) Tracer

func (r *Runtime) Tracer() *observability.Tracer

Tracer returns the tracer for distributed tracing. Returns nil if tracing is not enabled.

type ToolsetFactory

type ToolsetFactory func(name string, cfg *config.ToolConfig) (tool.Toolset, error)

ToolsetFactory creates a Toolset from config.

type WorkingMemoryFactoryOptions

type WorkingMemoryFactoryOptions struct {
	// Config is the context configuration.
	Config *config.ContextConfig

	// ModelName is the LLM model name for token counting.
	ModelName string

	// SummarizerLLM is the LLM to use for summarization (summary_buffer only).
	// If nil and strategy is summary_buffer, summarization is disabled.
	SummarizerLLM model.LLM
}

WorkingMemoryFactoryOptions contains options for creating working memory strategies.

Jump to

Keyboard shortcuts

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