Documentation
¶
Index ¶
- Variables
- func EvaluateCondition(conditionStr string, state map[string]interface{}) (bool, error)
- func EvaluateExpression(expr string, state map[string]interface{}) (interface{}, error)
- type AstonishAgent
- type ErrorContext
- type ErrorRecoveryNode
- type FilteredToolset
- type LiveSession
- type ProtectedTool
- type ProtectedToolset
- type RecoveryDecision
- type RunnableTool
- type ScopedContext
- type ScopedSession
- type ScopedState
- type ToolWithDeclaration
Constants ¶
This section is empty.
Variables ¶
var ( // EnableEventFiltering controls whether LLM nodes see filtered events (per-node history) // or full session history. Set to true for node isolation, false for full context. // TODO: Make this configurable per agent flow in the future EnableEventFiltering = true )
Package-level map for session event tracking (persists across LiveSession instances)
var ErrWaitingForApproval = fmt.Errorf("interrupt: waiting for user approval")
ErrWaitingForApproval is returned when a tool needs user approval
Functions ¶
func EvaluateCondition ¶
EvaluateCondition evaluates a Python-style condition using Starlark
func EvaluateExpression ¶
EvaluateExpression evaluates a Python-style expression using Starlark and returns the result
Types ¶
type AstonishAgent ¶
type AstonishAgent struct {
Config *config.AgentConfig
LLM model.LLM
Tools []tool.Tool
Toolsets []tool.Toolset
DebugMode bool
IsWebMode bool // If true, avoids ANSI codes in output
SessionService session.Service
}
AstonishAgent implements the logic for running Astonish agents.
func NewAstonishAgent ¶
func NewAstonishAgent(cfg *config.AgentConfig, llm model.LLM, tools []tool.Tool) *AstonishAgent
NewAstonishAgent creates a new AstonishAgent.
func NewAstonishAgentWithToolsets ¶
func NewAstonishAgentWithToolsets(cfg *config.AgentConfig, llm model.LLM, tools []tool.Tool, toolsets []tool.Toolset) *AstonishAgent
NewAstonishAgentWithToolsets creates a new AstonishAgent with both tools and toolsets.
func (*AstonishAgent) Run ¶
func (a *AstonishAgent) Run(ctx agent.InvocationContext) iter.Seq2[*session.Event, error]
Run executes the agent flow with stateful workflow management.
type ErrorContext ¶
type ErrorContext struct {
NodeName string `json:"node_name"`
NodeType string `json:"node_type"` // "llm", "tool", etc.
ErrorType string `json:"error_type"` // "tool_error", "parse_error", "llm_error", etc.
ErrorMessage string `json:"error_message"` // The actual error message
AttemptCount int `json:"attempt_count"` // Current retry attempt (1-indexed)
MaxRetries int `json:"max_retries"` // Configured maximum retries
PreviousErrors []string `json:"previous_errors"` // History of error messages
ToolName string `json:"tool_name,omitempty"` // If tool error
ToolArgs map[string]any `json:"tool_args,omitempty"` // If tool error
OriginalInput map[string]any `json:"original_input,omitempty"` // Original node inputs
}
ErrorContext captures the context of an error for recovery analysis
type ErrorRecoveryNode ¶
ErrorRecoveryNode analyzes errors and decides whether to retry or abort
func NewErrorRecoveryNode ¶
func NewErrorRecoveryNode(llm model.LLM, debugMode bool) *ErrorRecoveryNode
NewErrorRecoveryNode creates a new error recovery analyzer
func (*ErrorRecoveryNode) Decide ¶
func (e *ErrorRecoveryNode) Decide(ctx context.Context, errCtx ErrorContext) (*RecoveryDecision, error)
Decide analyzes an error and decides whether to retry or abort
type FilteredToolset ¶
type FilteredToolset struct {
// contains filtered or unexported fields
}
FilteredToolset wraps a toolset and filters tools based on allowed list
func (*FilteredToolset) Name ¶
func (f *FilteredToolset) Name() string
Name returns the name of the underlying toolset
func (*FilteredToolset) Tools ¶
func (f *FilteredToolset) Tools(ctx agent.ReadonlyContext) ([]tool.Tool, error)
Tools returns only the tools that are in the allowed list
type LiveSession ¶
type LiveSession struct {
// contains filtered or unexported fields
}
LiveSession wraps a session and fetches fresh data from the service on access It also tracks node boundaries for filtering events by current node
func (*LiveSession) AppName ¶
func (s *LiveSession) AppName() string
func (*LiveSession) Events ¶
func (s *LiveSession) Events() session.Events
func (*LiveSession) ID ¶
func (s *LiveSession) ID() string
func (*LiveSession) LastUpdateTime ¶
func (s *LiveSession) LastUpdateTime() time.Time
func (*LiveSession) State ¶
func (s *LiveSession) State() session.State
func (*LiveSession) UserID ¶
func (s *LiveSession) UserID() string
type ProtectedTool ¶
type ProtectedTool struct {
tool.Tool // Embed the underlying tool
State session.State // Access to session state
Agent *AstonishAgent // Access to helper methods
YieldFunc func(*session.Event, error) bool // For emitting events
}
ProtectedTool wraps a standard tool and adds an approval gate.
func (*ProtectedTool) Declaration ¶
func (p *ProtectedTool) Declaration() *genai.FunctionDeclaration
Declaration forwards the call to the underlying tool if it supports it
func (*ProtectedTool) ProcessRequest ¶
func (p *ProtectedTool) ProcessRequest(ctx tool.Context, req *model.LLMRequest) error
ProcessRequest always delegates to underlying tool to register it with the LLM Approval is checked later during Run(), not during ProcessRequest()
type ProtectedToolset ¶
type ProtectedToolset struct {
// contains filtered or unexported fields
}
ProtectedToolset wraps a toolset and returns tools wrapped with ProtectedTool
func (*ProtectedToolset) Name ¶
func (p *ProtectedToolset) Name() string
Name returns the name of the underlying toolset
func (*ProtectedToolset) Tools ¶
func (p *ProtectedToolset) Tools(ctx agent.ReadonlyContext) ([]tool.Tool, error)
Tools returns the underlying toolset's tools, wrapped with ProtectedTool
type RecoveryDecision ¶
type RecoveryDecision struct {
ShouldRetry bool `json:"should_retry"` // true = retry, false = abort
Title string `json:"title"` // Short, clear summary of the error (max 100 chars)
OneLiner string `json:"one_liner"` // Ultra-short summary for badges (max 60 chars)
Reason string `json:"reason"` // Explanation of the decision
Suggestion string `json:"suggestion"` // What to fix or try differently (if retry)
}
RecoveryDecision represents the decision made by the error recovery system
type RunnableTool ¶
RunnableTool defines an interface for tools that can be executed. This matches the signature of Run method in adk-go's internal tool implementations.
type ScopedContext ¶
type ScopedContext struct {
agent.InvocationContext
// contains filtered or unexported fields
}
ScopedContext wraps an InvocationContext and overrides the state
func (*ScopedContext) Agent ¶
func (s *ScopedContext) Agent() agent.Agent
func (*ScopedContext) Session ¶
func (s *ScopedContext) Session() session.Session
func (*ScopedContext) SessionID ¶
func (s *ScopedContext) SessionID() string
func (*ScopedContext) State ¶
func (s *ScopedContext) State() session.State
type ScopedSession ¶
ScopedSession wraps a Session and overrides the state
func (*ScopedSession) State ¶
func (s *ScopedSession) State() session.State
type ScopedState ¶
ScopedState wraps a parent state and allows local overrides
func (*ScopedState) Delete ¶
func (s *ScopedState) Delete(key string) error
type ToolWithDeclaration ¶
type ToolWithDeclaration interface {
Declaration() *genai.FunctionDeclaration
}
ToolWithDeclaration allows inspecting the tool's schema