local

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentLoopInput

type AgentLoopInput struct {
	UserPrompt       string
	ConversationID   string
	StreamingEnabled bool
	// ChannelName is the eventbus channel events are published to during this run.
	// Sub-agents receive the parent's ChannelName so their events go directly to the parent stream.
	// Empty = no event fanout.
	ChannelName string
	// ApprovalHandler is called when a tool requires human approval. May be nil (approval → unavailable).
	ApprovalHandler types.ApprovalHandler
	// SubAgentRoutes maps sub-agent tool name → local route. Built by the local runtime from
	// ExecuteRequest.SubAgents before RunAgentLoop is called. Mirrors AgentWorkflowInput.SubAgentRoutes.
	SubAgentRoutes map[string]subAgentRoute
	// SubAgentDepth is the current nesting depth (0 = top-level, 1 = direct sub-agent, etc.).
	SubAgentDepth int
	// MaxSubAgentDepth caps recursive delegation. Mirrors AgentWorkflowInput.MaxSubAgentDepth.
	MaxSubAgentDepth int
}

AgentLoopInput holds per-run execution inputs for one local agent run. Mirrors AgentWorkflowInput (Temporal) for in-process execution — same fields, same semantics. Agent-level configuration (ToolExecutionMode, LLM, tools, limits) lives on the runtime itself.

type AgentLoopResult

type AgentLoopResult struct {
	Content string
	Usage   *interfaces.LLMUsage
}

AgentLoopResult is the outcome of a completed local agent run.

type LocalRuntime

type LocalRuntime struct {
	base.Runtime
	// contains filtered or unexported fields
}

LocalRuntime executes the agent loop in-process, embedding base.Runtime for shared core methods and holding local-specific fields (logger, eventbus).

func NewLocalRuntime

func NewLocalRuntime(opts ...Option) (*LocalRuntime, error)

NewLocalRuntime constructs a LocalRuntime from functional options.

func (*LocalRuntime) Approve

func (rt *LocalRuntime) Approve(_ context.Context, approvalToken string, status types.ApprovalStatus) error

Approve resolves a pending tool approval registered during a streaming run. When a tool requires approval, executeSingleTool registers a token and blocks; the caller receives a CUSTOM event on the stream with that token and calls Approve to unblock.

func (*LocalRuntime) Close

func (rt *LocalRuntime) Close()

Close releases runtime resources.

func (*LocalRuntime) Execute

Execute runs the agent loop synchronously and returns the final result. Approval is handled inline via req.ApprovalHandler (no out-of-band tokens).

func (*LocalRuntime) ExecuteStream

func (rt *LocalRuntime) ExecuteStream(ctx context.Context, req *sdkruntime.ExecuteRequest) (<-chan events.AgentEvent, error)

ExecuteStream starts the agent loop in a goroutine and returns a channel of AgentEvent. RUN_STARTED is emitted before the loop begins; RUN_FINISHED or RUN_ERROR closes the channel.

func (*LocalRuntime) GetEventBus

func (rt *LocalRuntime) GetEventBus() eventbus.EventBus

GetEventBus returns the runtime's in-process event bus so pkg/agent can wire sub-agents to the same bus for streaming fan-in and delegation events.

func (*LocalRuntime) RunAgentLoop

func (rt *LocalRuntime) RunAgentLoop(ctx context.Context, input AgentLoopInput) (*AgentLoopResult, error)

RunAgentLoop executes the full agent loop in-process using base.Runtime core methods. It mirrors the orchestration logic of AgentWorkflow but calls base methods directly instead of dispatching to Temporal activities. Events are published to rt.eventbus on input.ChannelName; callers subscribe to that channel.

func (*LocalRuntime) SetEventBus

func (rt *LocalRuntime) SetEventBus(bus eventbus.EventBus)

SetEventBus replaces the runtime's event bus. Called by pkg/agent when wiring a sub-agent tree so all agents in the tree share the parent's bus.

type Option

type Option func(*LocalRuntime)

func WithAgentExecution

func WithAgentExecution(execution sdkruntime.AgentExecution) Option

func WithAgentSpec

func WithAgentSpec(spec sdkruntime.AgentSpec) Option

func WithLogger

func WithLogger(l logger.Logger) Option

func WithMetrics

func WithMetrics(metrics interfaces.Metrics) Option

func WithToolExecutionMode

func WithToolExecutionMode(mode types.AgentToolExecutionMode) Option

func WithTracer

func WithTracer(tracer interfaces.Tracer) Option

Jump to

Keyboard shortcuts

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