Documentation
¶
Index ¶
- type AgentLoopInput
- type AgentLoopResult
- type LocalRuntime
- func (rt *LocalRuntime) Approve(_ context.Context, approvalToken string, status types.ApprovalStatus) error
- func (rt *LocalRuntime) Close()
- func (rt *LocalRuntime) Execute(ctx context.Context, req *sdkruntime.ExecuteRequest) (*types.AgentRunResult, error)
- func (rt *LocalRuntime) ExecuteStream(ctx context.Context, req *sdkruntime.ExecuteRequest) (<-chan events.AgentEvent, error)
- func (rt *LocalRuntime) GetEventBus() eventbus.EventBus
- func (rt *LocalRuntime) RunAgentLoop(ctx context.Context, input AgentLoopInput) (*AgentLoopResult, error)
- func (rt *LocalRuntime) SetEventBus(bus eventbus.EventBus)
- type Option
- func WithAgentConfig(cfg sdkruntime.AgentConfig) Option
- func WithAgentSpec(spec sdkruntime.AgentSpec) Option
- func WithLogger(l logger.Logger) Option
- func WithMetrics(metrics interfaces.Metrics) Option
- func WithToolExecutionMode(mode types.AgentToolExecutionMode) Option
- func WithTracer(tracer interfaces.Tracer) Option
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
// Tools is the resolved tool list for this run.
Tools []interfaces.Tool
// 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
// MemoryScope is resolved before the run and used for recall/store.
MemoryScope interfaces.MemoryScope
}
AgentLoopInput holds per-run execution inputs for one local agent run. Mirrors AgentWorkflowInput (Temporal) for in-process execution — same fields, same semantics. Static agent wiring lives on the runtime base.Runtime.AgentConfig; resolved tools are per-run on Tools.
type AgentLoopResult ¶
type AgentLoopResult struct {
Content string
LLMUsage *interfaces.LLMUsage
Telemetry *types.AgentTelemetry
}
AgentLoopResult is the outcome of a completed local agent run.
type LocalRuntime ¶
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) Execute ¶
func (rt *LocalRuntime) Execute(ctx context.Context, req *sdkruntime.ExecuteRequest) (*types.AgentRunResult, error)
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 WithAgentConfig ¶ added in v0.2.2
func WithAgentConfig(cfg sdkruntime.AgentConfig) Option
func WithAgentSpec ¶
func WithAgentSpec(spec sdkruntime.AgentSpec) Option
func WithLogger ¶
func WithMetrics ¶
func WithMetrics(metrics interfaces.Metrics) Option
func WithToolExecutionMode ¶
func WithToolExecutionMode(mode types.AgentToolExecutionMode) Option
func WithTracer ¶
func WithTracer(tracer interfaces.Tracer) Option