Documentation
¶
Index ¶
- func RegisterAgent(name string, agent *Agent)
- func UnregisterAgent(name string)
- type A2A
- type Accumulator
- type Agent
- func (a *Agent) A2A(agentCard *a2a.AgentCard) *A2A
- func (e *Agent) Cancel(ctx context.Context, executor core.DurableExecutor, reason string) error
- func (e *Agent) Execute(ctx context.Context, in *AgentInput) (*AgentOutput, error)
- func (e *Agent) ExecuteWithExecutor(ctx context.Context, in *AgentInput, executor core.DurableExecutor) (*AgentOutput, error)
- func (e *Agent) PrepareTools(ctx context.Context, runContext map[string]any) ([]core.Tool, error)
- type AgentInput
- type AgentOptions
- type AgentOutput
- type AgentRuntime
- type AgentWorkflow
- type LocalRuntime
- type RestateRuntime
- type WorkflowInput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterAgent ¶
RegisterAgent registers an agent configuration in the global registry. This is called when an agent is created with a Runtime that needs to look up the agent inside a workflow (e.g., RestateRuntime).
func UnregisterAgent ¶
func UnregisterAgent(name string)
UnregisterAgent removes an agent from the registry. Useful for cleanup or testing.
Types ¶
type A2A ¶ added in v0.1.1
type A2A struct {
InvokeHandler http.Handler
AgentCardHandler http.Handler
// contains filtered or unexported fields
}
func (*A2A) Cancel ¶ added in v0.1.1
func (*A2A) Cancel(ctx context.Context, reqCtx *a2asrv.RequestContext, q eventqueue.Queue) error
func (*A2A) Execute ¶ added in v0.1.1
func (agent *A2A) Execute(ctx context.Context, reqCtx *a2asrv.RequestContext, q eventqueue.Queue) error
type Accumulator ¶
type Accumulator struct {
}
func (*Accumulator) ReadStream ¶
func (a *Accumulator) ReadStream(stream chan *responses.ResponseChunk, cb func(chunk *responses.ResponseChunk)) (*responses.Response, error)
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
func GetAgent ¶
GetAgent retrieves an agent configuration from the global registry. Returns nil if the agent is not found.
func NewAgent ¶
func NewAgent(opts *AgentOptions) *Agent
func (*Agent) Cancel ¶
Cancel signals the agent to stop execution (requires a durable executor with state).
func (*Agent) Execute ¶
func (e *Agent) Execute(ctx context.Context, in *AgentInput) (*AgentOutput, error)
func (*Agent) ExecuteWithExecutor ¶
func (e *Agent) ExecuteWithExecutor(ctx context.Context, in *AgentInput, executor core.DurableExecutor) (*AgentOutput, error)
type AgentInput ¶
type AgentInput struct {
Namespace string
PreviousMessageID string
Messages []responses.InputMessageUnion
RunContext map[string]any
Callback func(chunk *responses.ResponseChunk)
}
type AgentOptions ¶
type AgentOptions struct {
History *history.CommonConversationManager
Instruction core.SystemPromptProvider
Parameters responses.Parameters
Name string
LLM llm.Provider
Output map[string]any
Tools []core.Tool
McpServers []*mcpclient.MCPClient
Runtime AgentRuntime
MaxLoops int
}
type AgentOutput ¶
type AgentOutput struct {
RunID string `json:"run_id"`
Status core.RunStatus `json:"status"`
Output []responses.InputMessageUnion `json:"output"`
PendingApprovals []responses.FunctionCallMessage `json:"pending_approvals"`
}
AgentOutput represents the result of agent execution
type AgentRuntime ¶
type AgentRuntime interface {
Run(ctx context.Context, agent *Agent, in *AgentInput) (*AgentOutput, error)
}
AgentRuntime defines the interface for agent execution strategies. All runtimes receive the agent configuration and execute it using their specific strategy (local, Restate, Temporal, etc.).
func DefaultRuntime ¶
func DefaultRuntime() AgentRuntime
DefaultRuntime returns the default runtime (LocalRuntime). This is used when no runtime is explicitly set on an agent.
type AgentWorkflow ¶
type AgentWorkflow struct{}
AgentWorkflow is the Restate workflow that executes agents with durability.
func (AgentWorkflow) Run ¶
func (w AgentWorkflow) Run(restateCtx restate.WorkflowContext, input *WorkflowInput) (*AgentOutput, error)
Run executes the agent inside a Restate workflow context. It looks up the agent from the registry and uses ExecuteWithExecutor with RestateExecutor for crash recovery. The agent is cached in the registry, so MCP connections are reused.
type LocalRuntime ¶
type LocalRuntime struct{}
LocalRuntime executes agents in-process with no durability. It uses the agent's ExecuteWithExecutor method with NoOpExecutor, providing the same agent loop logic but without crash recovery.
func (*LocalRuntime) Run ¶
func (r *LocalRuntime) Run(ctx context.Context, agent *Agent, in *AgentInput) (*AgentOutput, error)
Run executes the agent using ExecuteWithExecutor with NoOpExecutor. This provides the agent loop without durability. The agent instance is reused across multiple runs (cached MCP connections, resolved tools).
type RestateRuntime ¶
type RestateRuntime struct {
// contains filtered or unexported fields
}
RestateRuntime executes agents via Restate workflows for durability. It registers the agent in the global registry and invokes a Restate workflow that reconstructs the agent with RestateExecutor for crash recovery.
func NewRestateRuntime ¶
func NewRestateRuntime(endpoint string) *RestateRuntime
NewRestateRuntime creates a new Restate runtime. The agentName is used to look up the agent config inside the workflow.
func (*RestateRuntime) Run ¶
func (r *RestateRuntime) Run(ctx context.Context, agent *Agent, in *AgentInput) (*AgentOutput, error)
Run registers the agent in the global registry and invokes the Restate workflow.
type WorkflowInput ¶
type WorkflowInput struct {
AgentName string `json:"agent_name"`
Namespace string
PreviousMessageID string
Messages []responses.InputMessageUnion
RunContext map[string]any
}
WorkflowInput is the input structure for the Restate workflow.