Documentation
¶
Index ¶
- Variables
- type Agent
- func (a *Agent) A2ACard() *a2a.AgentCard
- func (a *Agent) A2AClient() *a2a.A2AClient
- func (a *Agent) A2AServer() *a2a.A2AServer
- func (a *Agent) AddKnowledgeSources(sources ...knowledge.KnowledgeSource)
- func (a *Agent) CacheHitCount() int64
- func (a *Agent) CacheMissCount() int64
- func (a *Agent) ClearToolCache()
- func (a *Agent) Clone() *Agent
- func (a *Agent) CloneWithBackstory(backstory string) *Agent
- func (a *Agent) Close(ctx context.Context)
- func (a *Agent) DelegateTo(ctx context.Context, role, request string) (*a2a.DelegationFuture, error)
- func (a *Agent) EmitFrame(f stream.Frame)
- func (a *Agent) Equip(t ...tools.Tool)
- func (a *Agent) Execute(ctx context.Context, taskDesc, expectedOutput string, ctxTasks []string) (string, error)
- func (a *Agent) FrameChannel() <-chan stream.Frame
- func (a *Agent) GetBackstory() string
- func (a *Agent) GetGoal() string
- func (a *Agent) GetMaxIter() int
- func (a *Agent) GetPlan() string
- func (a *Agent) GetPlanning() bool
- func (a *Agent) GetRole() string
- func (a *Agent) GetSkills() []skill.Skill
- func (a *Agent) GetTools() []tools.Tool
- func (a *Agent) GetUsageMetrics() map[string]int
- func (a *Agent) HandleA2AMessage(ctx context.Context, msg *a2a.A2AMessage) (*a2a.A2AMessage, error)
- func (a *Agent) LoadSkills() error
- func (a *Agent) MCPServer() *mcp.MCPServer
- func (a *Agent) Sandbox() sandbox.Provider
- func (a *Agent) SetCrewSkills(skills []skill.Skill)
- func (a *Agent) SetPlanning(enabled bool)
- func (a *Agent) SetPlanningLLM(llmClient llm.Client)
- func (a *Agent) SetToolCache(tc cache.ToolCache)
- func (a *Agent) SetUnifiedMemory(m *memory.UnifiedMemory)
- func (a *Agent) StartMCPServer(ctx context.Context, port string) error
- func (a *Agent) StartMCPStdioServer(ctx context.Context) error
- type Config
Constants ¶
This section is empty.
Variables ¶
var ErrMCPStdioDisabled = errors.New("agent: mcp stdio disabled; set Config.MCPStdioEnabled=true")
ErrMCPStdioDisabled is returned when StartMCPStdioServer is called with MCPStdioEnabled=false.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
Agent represents an AI agent with a role, goal, tools, and memory.
func (*Agent) A2ACard ¶ added in v0.2.0
A2ACard returns the agent's A2A agent card, or nil if not registered.
func (*Agent) A2AClient ¶ added in v0.2.0
A2AClient returns the agent's A2A client, or nil if not enabled.
func (*Agent) A2AServer ¶ added in v0.2.0
A2AServer returns the agent's A2A server, or nil if not enabled.
func (*Agent) AddKnowledgeSources ¶ added in v0.4.0
func (a *Agent) AddKnowledgeSources(sources ...knowledge.KnowledgeSource)
AddKnowledgeSources appends shared knowledge sources.
func (*Agent) CacheHitCount ¶ added in v0.8.0
CacheHitCount returns the number of cache hits across all wrapped tools.
func (*Agent) CacheMissCount ¶ added in v0.8.0
CacheMissCount returns the number of cache misses across all wrapped tools.
func (*Agent) ClearToolCache ¶ added in v0.8.0
func (a *Agent) ClearToolCache()
ClearToolCache clears all cached tool results.
func (*Agent) Clone ¶ added in v0.8.1
Clone creates a lightweight copy of the Agent for parallel execution. The clone shares read-only infrastructure (LLM, tools, A2A, MCP, sandbox, knowledge pipeline, frame buffer, tool cache) but has its own mutable execution state (plan, lastToolErr, usage metrics, frame sequence). This is used by Crew.KickoffForEachAsync to avoid data races on agent state.
@sk-task database-tools#T1.RACE: Clone method for agent isolation in parallel crew execution
func (*Agent) CloneWithBackstory ¶ added in v0.8.0
CloneWithBackstory returns a new Agent with the given backstory, sharing the same LLM client, tools, and other config. Used by ForEach placeholder substitution.
func (*Agent) Close ¶ added in v0.2.0
Close shuts down the A2A server and unregisters the agent card.
func (*Agent) DelegateTo ¶ added in v0.2.0
func (a *Agent) DelegateTo(ctx context.Context, role, request string) (*a2a.DelegationFuture, error)
DelegateTo delegates a task to another agent by role and returns a DelegationFuture.
func (*Agent) EmitFrame ¶ added in v0.7.0
EmitFrame sends a streaming frame. No-op if frame channel is nil. Sets Source and Seq before emitting.
func (*Agent) Execute ¶
func (a *Agent) Execute(ctx context.Context, taskDesc, expectedOutput string, ctxTasks []string) (string, error)
Execute runs the agent's ReAct loop to complete a given task and returns the output.
func (*Agent) FrameChannel ¶ added in v0.7.0
FrameChannel returns the agent's frame channel, creating it lazily.
func (*Agent) GetBackstory ¶
GetBackstory returns the agent's backstory.
func (*Agent) GetMaxIter ¶
GetMaxIter returns the maximum number of iterations for the agent's ReAct loop.
func (*Agent) GetPlan ¶ added in v0.8.0
@sk-task planner#T3.1: GetPlan returns the current plan text (AC-009)
func (*Agent) GetPlanning ¶ added in v0.8.0
@sk-task planner#T3.2: GetPlanning returns whether planning is enabled (AC-007)
func (*Agent) GetSkills ¶ added in v0.8.0
GetSkills returns the agent's loaded skills (agent-level only).
func (*Agent) GetUsageMetrics ¶
GetUsageMetrics returns a copy of the agent's token and tool usage metrics.
func (*Agent) HandleA2AMessage ¶ added in v0.2.0
func (a *Agent) HandleA2AMessage(ctx context.Context, msg *a2a.A2AMessage) (*a2a.A2AMessage, error)
HandleA2AMessage processes an incoming delegation and returns a typed response.
func (*Agent) LoadSkills ¶ added in v0.8.0
LoadSkills loads skills from Config.Skills paths and caches them on the agent. Returns an error if any skill path is invalid or SKILL.md is malformed.
func (*Agent) MCPServer ¶ added in v0.3.0
MCPServer returns the agent's MCP server, or nil if not started.
func (*Agent) Sandbox ¶ added in v0.3.0
Sandbox returns the agent's sandbox provider, or nil if not configured.
func (*Agent) SetCrewSkills ¶ added in v0.8.0
SetCrewSkills sets the crew-level skills on this agent. Crew skills are prepended before agent-level skills in the prompt.
func (*Agent) SetPlanning ¶ added in v0.8.0
@sk-task planner#T3.1: SetPlanning enables planning on this agent (AC-007)
func (*Agent) SetPlanningLLM ¶ added in v0.8.0
@sk-task planner#T3.1: SetPlanningLLM sets the planning LLM for this agent (AC-008)
func (*Agent) SetToolCache ¶ added in v0.8.0
SetToolCache sets the agent's tool cache backend (used by crew propagateCache). Wraps from the original (unwrapped) tools to avoid double-wrapping.
func (*Agent) SetUnifiedMemory ¶ added in v0.7.0
func (a *Agent) SetUnifiedMemory(m *memory.UnifiedMemory)
SetUnifiedMemory sets the agent's UnifiedMemory, auto-wrapping as memory.Store.
func (*Agent) StartMCPServer ¶ added in v0.3.0
StartMCPServer starts an MCP server exposing the agent's tools.
type Config ¶
type Config struct {
Role string
Goal string
Backstory string
LLM llm.Client
Tools []tools.Tool
Memory memory.Store
MaxIter int
MaxRPM int
MaxRetries int
MaxExecutionTime time.Duration
Verbose bool
AllowDelegation bool
StepCallback callback.Callback
// @sk-task a2a#T3.2: A2A protocol fields (AC-006)
A2APort int
A2AAuthToken string
A2ACapabilities []string
// @sk-task mcp-sandbox#T2.3, T3.1: sandbox type ("wasm"/"docker"/"") (AC-007)
SandboxType string
// @sk-task knowledge-sources#T2.2: knowledge sources and pipeline (AC-007)
KnowledgeSources []knowledge.KnowledgeSource
// @sk-task guardrails#T3.1: agent-level guardrails validated before final return (AC-009)
Guardrails []guardrail.Guardrail
// @sk-task training#T3.1: training directory for advice injection (AC-009, AC-010, AC-015)
TrainingDir string
// @sk-task mcp-stdio-server#T1.1: MCPStdioEnabled config guard (AC-004)
MCPStdioEnabled bool
// @sk-task unified-memory#T3.1: UnifiedMemory field (AC-003, AC-008, DEC-003)
UnifiedMemory *memory.UnifiedMemory
// @sk-task tool-caching#T2.2: tool cache config fields (AC-004)
Cache bool
CacheTTL time.Duration
MaxCacheSize int
// @sk-task skills-system#T2.1: skill paths for domain expertise injection (AC-004, AC-011)
Skills []string
// @sk-task planner#T1.1: plan generation config (AC-001, AC-002, AC-003, AC-004)
Planning bool
PlanningLLM llm.Client
}
Config defines the configuration for an Agent.