Documentation
¶
Index ¶
- Variables
- type Agent
- func (a *Agent) Clone() (optimize.OptimizableAgent, error)
- func (a *Agent) Execute(ctx context.Context, input map[string]interface{}) (map[string]interface{}, error)
- func (a *Agent) ForkActiveSession(ctx context.Context, sessionID, name string, setActive bool) (*sessionevent.SessionBranch, error)
- func (a *Agent) GetArtifacts() optimize.AgentArtifacts
- func (a *Agent) GetCapabilities() []core.Tool
- func (a *Agent) GetMemory() agents.Memory
- func (a *Agent) GetSessionState(ctx context.Context, sessionID string) (*SessionState, error)
- func (a *Agent) LastExecutionTrace() *agents.ExecutionTrace
- func (a *Agent) LastNativeTrace() *Trace
- func (a *Agent) RegisterTool(tool core.Tool) error
- func (a *Agent) SetArtifacts(artifacts optimize.AgentArtifacts) error
- func (a *Agent) SwitchSessionBranch(ctx context.Context, sessionID, branchID string) error
- type Config
- type SessionState
- type TokenUsage
- type Trace
- type TraceStep
Constants ¶
This section is empty.
Variables ¶
var ( ErrSessionEventStoreUnavailable = errors.New("session event store is not configured") // ErrSessionIDRequired indicates that a session control call needs either an explicit session ID or Config.SessionID. ErrSessionIDRequired = errors.New("session id is required") // ErrSessionBranchIDRequired indicates that a branch switch was requested without a target branch ID. ErrSessionBranchIDRequired = errors.New("session branch id is required") )
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
Agent executes tasks using provider-native tool calling with a shared dspy-go harness.
func (*Agent) Clone ¶
func (a *Agent) Clone() (optimize.OptimizableAgent, error)
Clone creates a fresh agent with the same LLM, config, and registered tools.
func (*Agent) Execute ¶
func (a *Agent) Execute(ctx context.Context, input map[string]interface{}) (map[string]interface{}, error)
Execute runs one native tool-calling task.
func (*Agent) ForkActiveSession ¶ added in v0.82.0
func (a *Agent) ForkActiveSession(ctx context.Context, sessionID, name string, setActive bool) (*sessionevent.SessionBranch, error)
ForkActiveSession creates a branch from the current active head. When setActive is true, the new branch becomes the session's active branch immediately.
func (*Agent) GetArtifacts ¶
func (a *Agent) GetArtifacts() optimize.AgentArtifacts
GetArtifacts returns prompt/config backed artifacts.
func (*Agent) GetCapabilities ¶
GetCapabilities returns the currently registered tools.
func (*Agent) GetSessionState ¶ added in v0.82.0
GetSessionState returns the active branch and branch list for a stored session.
func (*Agent) LastExecutionTrace ¶
func (a *Agent) LastExecutionTrace() *agents.ExecutionTrace
LastExecutionTrace returns the most recent execution trace.
func (*Agent) LastNativeTrace ¶
LastNativeTrace returns the richer native-tool trace from the most recent run.
func (*Agent) RegisterTool ¶
RegisterTool adds a tool to the shared registry.
func (*Agent) SetArtifacts ¶
func (a *Agent) SetArtifacts(artifacts optimize.AgentArtifacts) error
SetArtifacts updates the prompt/config backed artifacts.
type Config ¶
type Config struct {
MaxTurns int
MaxTokens int
Temperature float64
SystemPrompt string
ToolPolicy string
FinishToolText string
Memory agents.Memory
SessionID string
SessionBranchID string
SessionRecallLimit int
SessionRecallMaxChars int
SessionEventStore sessionevent.SessionEventStore
MaxConsecutiveNoCallResponses int
ToolInterceptors []core.ToolInterceptor
OnEvent func(agents.AgentEvent)
}
Config controls the shared native tool-calling agent behavior.
type SessionState ¶ added in v0.82.0
type SessionState struct {
Session *sessionevent.Session
Branches []sessionevent.SessionBranch
ActiveBranch *sessionevent.SessionBranch
HeadEntry *sessionevent.SessionEntry
}
SessionState captures the current persisted state of a session in the event store.
type TokenUsage ¶
type TokenUsage struct {
PromptTokens int64 `json:"prompt_tokens"`
CompletionTokens int64 `json:"completion_tokens"`
TotalTokens int64 `json:"total_tokens"`
}
TokenUsage captures aggregate token usage for one tool-calling run.
type Trace ¶
type Trace struct {
TaskID string `json:"task_id,omitempty"`
Model string `json:"model"`
Provider string `json:"provider"`
Task string `json:"task"`
StartedAt time.Time `json:"started_at"`
Duration time.Duration `json:"duration"`
Completed bool `json:"completed"`
FinalAnswer string `json:"final_answer,omitempty"`
Error string `json:"error,omitempty"`
TokenUsage TokenUsage `json:"token_usage"`
Steps []TraceStep `json:"steps"`
}
Trace captures a native tool-calling run with step-level detail.
type TraceStep ¶
type TraceStep struct {
Index int `json:"index"`
AssistantText string `json:"assistant_text,omitempty"`
ToolName string `json:"tool_name,omitempty"`
Arguments map[string]any `json:"arguments,omitempty"`
Observation string `json:"observation,omitempty"`
ObservationDisplay string `json:"observation_display,omitempty"`
ObservationDetails map[string]any `json:"observation_details,omitempty"`
IsError bool `json:"is_error,omitempty"`
Synthetic bool `json:"synthetic,omitempty"`
Redacted bool `json:"redacted,omitempty"`
Truncated bool `json:"truncated,omitempty"`
Usage TokenUsage `json:"usage,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
}
TraceStep captures one model/tool turn.