agents

package
v0.83.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2026 License: MIT Imports: 18 Imported by: 0

README

Agents Package

pkg/agents contains the runtime building blocks for long-lived assistants, specialized worker agents, and orchestration layers.

The package now has three distinct roles:

  • native: provider-native tool-calling agents for modern models
  • react: ReAct-based agents for compatibility, research, and benchmarking
  • orchestrator: control-plane decomposition and task execution across bounded processors

It also includes shared infrastructure:

  • sessionevent: persistent branchable session storage
  • memory: memory backends and helpers
  • communication: cross-agent/subagent execution patterns
  • ace: trajectory recording and self-improvement hooks
  • rlm: recursive context-processing strategy components
  • shared traces, events, message types, and tool-observation normalization

Choosing The Right Abstraction

native.Agent

Use the native agent when you want one model to directly drive tools.

Best for:

  • interactive assistants
  • coding agents
  • session-based Q&A
  • Pi-style minimal tool packs
  • modern tool-calling models

Key properties:

  • provider-native tool calling
  • tool interceptors
  • structured lifecycle events
  • session recall and branch-aware resume
  • detailed execution traces

Relevant code:

react.ReActAgent

Use ReAct when you explicitly want a text-mediated reasoning loop.

Best for:

  • weaker or non-native-tool-calling models
  • experimentation
  • benchmarking against classic agent patterns
  • research on reasoning styles

ReAct is still useful, but it is no longer the default mental model for modern agents in this repo.

Relevant code:

FlexibleOrchestrator

Use the orchestrator when the top-level problem is not “let one agent figure it out,” but “split work, route bounded tasks, and enforce policy.”

Best for:

  • batch workflows
  • multi-stage pipelines
  • parallel task execution
  • review/control planes that supervise specialized workers

The orchestrator should own:

  • task decomposition
  • routing
  • dependency management
  • retries and fallbacks
  • validation gates
  • final decision authority

It should not be treated as just “another smart agent.”

Relevant code:

Agent vs Subagent vs Orchestrator

These are different roles.

Main Agent

The main agent owns an end-user task directly.

Example:

  • “answer this repository question”
  • “edit this file”
  • “complete this coding task”

In dspy-go, that is usually a native.Agent.

Dedicated Subagent

A subagent is a bounded specialist invoked by something else.

Example:

  • a review assistant that inspects one PR chunk
  • a reply assistant that drafts one thread response
  • a verifier that checks one candidate finding

The important point is not “smaller model” vs “bigger model.”
The important point is scope:

  • narrow input
  • narrow tool surface
  • strict budgets
  • structured result

You can build dedicated subagents with native.Agent, react.ReActAgent, or the communication package.

Orchestrator

An orchestrator supervises work instead of doing the whole reasoning job itself.

Example:

  • split a PR into chunk-review tasks
  • invoke a dedicated review subagent per chunk
  • dedupe results
  • decide what survives to final output

That is why an orchestrator is a control plane, not just a bigger agent.

General Interactive Assistant

Use:

  • native.Agent
  • a small tool pack
  • sessionevent for persistence

This is the default direction for modern assistants in this repo.

Specialized Worker Agent

Use:

  • native.Agent or react.ReActAgent
  • a restricted tool pack
  • low turn/tool budgets
  • structured outputs

This is the right pattern for things like code review assistants, verification workers, or bounded repo analyzers.

Supervisory Workflow

Use:

  • FlexibleOrchestrator
  • task processors
  • dedicated worker agents underneath

This is the right pattern when global policy matters more than open-ended autonomy.

Runtime Strategy vs Optimization

Not every agent concept belongs at the same layer.

Execution Shape

These define who is responsible for doing work:

  • main agent
  • dedicated subagent
  • orchestrator

This README is primarily about that layer.

Runtime Strategy

These define how work is executed once you have chosen an agent shape:

  • native tool calling
  • ReAct
  • session recall
  • tool policies
  • RLM / recursive context reduction

RLM is not an alternative to an agent or orchestrator.
It is a strategy for handling large context efficiently.

Use RLM when the hard problem is:

  • too much context
  • recursive summarization
  • cost reduction under large inputs
  • bounded context windows for specialized workers
Optimization Layer

These define how an agent or workflow improves over time:

  • GEPA
  • ACE
  • trajectory recording
  • artifact and prompt tuning

GEPA is not the execution model.
It is the optimization loop that can improve:

  • a native interactive agent
  • a specialized review subagent
  • a verifier
  • an orchestrator prompt or decomposition strategy

ACE is similar in that it augments learning and trajectory capture rather than replacing the runtime shape.

Sessions And Continuity

sessionevent provides the persistent session model for native agents.

It supports:

  • session creation
  • active branches
  • forked branches
  • lineage loading
  • out-of-band summaries

Relevant code:

This is the right base for:

  • long-lived assistants
  • branchable agent sessions
  • recall across runs

Current Direction

The current architectural direction in dspy-go is:

  1. native tool-calling first
  2. session-aware runtimes
  3. small default tool packs
  4. orchestrators for supervision, not as the default answer to every agent problem
  5. ReAct as compatibility and research infrastructure, not the center of the product architecture
  6. RLM as a context-processing strategy where scale demands it
  7. GEPA and ACE as optimization layers on top of the runtime, not substitutes for agent design

Practical Rule Of Thumb

If you are deciding what to build:

  • Start with native.Agent for one modern interactive agent.
  • Add sessionevent if the agent needs continuity.
  • Introduce a dedicated subagent when one bounded task needs a different prompt, budget, or tool surface.
  • Introduce FlexibleOrchestrator only when you need a real control plane across multiple bounded tasks.
  • Add RLM when context size, recursion, or cost becomes the bottleneck.
  • Add GEPA when the runtime shape is stable enough to optimize systematically.

That usually produces a cleaner system than starting with a giant autonomous agent or forcing orchestration too early.

Documentation

Index

Constants

View Source
const (
	EventRunStarted       = "run_started"
	EventRunFinished      = "run_finished"
	EventRunFailed        = "run_failed"
	EventSessionLoaded    = "session_loaded"
	EventSessionPersisted = "session_persisted"
	EventLLMTurnStarted   = "llm_turn_started"
	EventLLMTurnFinished  = "llm_turn_finished"
	EventToolCallProposed = "tool_call_proposed"
	EventToolCallStarted  = "tool_call_started"
	EventToolCallBlocked  = "tool_call_blocked"
	EventToolCallFinished = "tool_call_finished"
)
View Source
const (
	StopReasonFinish           = "finish"
	StopReasonMaxIterations    = "max_iterations"
	StopReasonError            = "error"
	StopReasonAborted          = "aborted"
	StopReasonBudgetExhausted  = "budget_exhausted"
	StopReasonFinishOverBudget = "finish_over_budget"
)

Variables

View Source
var (
	// ErrAgentFinished indicates the agent has completed execution.
	ErrAgentFinished = errors.New("agent has finished execution")

	// ErrMaxIterations indicates the agent hit the iteration limit.
	ErrMaxIterations = errors.New("max iterations reached")

	// ErrContextOverflow indicates the context window was exceeded.
	ErrContextOverflow = errors.New("context window overflow")

	// ErrAborted indicates the agent execution was aborted.
	ErrAborted = errors.New("agent execution aborted")
)

Functions

func EmitEvent added in v0.82.0

func EmitEvent(onEvent func(AgentEvent), eventType string, data map[string]any)

EmitEvent safely emits an agent event to an optional callback.

func IsContextOverflow added in v0.76.0

func IsContextOverflow(err error) bool

IsContextOverflow checks if an error is or wraps ErrContextOverflow.

Types

type Agent

type Agent interface {
	// Execute runs the agent's task with given input and returns output
	Execute(ctx context.Context, input map[string]interface{}) (map[string]interface{}, error)

	// GetCapabilities returns the tools/capabilities available to this agent
	GetCapabilities() []core.Tool

	// GetMemory returns the agent's memory store
	GetMemory() Memory
}

type AgentEvent added in v0.76.0

type AgentEvent struct {
	Type      string
	Data      map[string]any
	Timestamp time.Time
}

AgentEvent represents an event emitted during agent execution. This is intentionally minimal and will be extended by streaming/event work.

type AnalyzerConfig added in v0.12.0

type AnalyzerConfig struct {
	// The base instruction for task analysis
	BaseInstruction string
	// Additional formatting instructions specific to the implementation
	FormatInstructions string
	// Any extra considerations for task analysis
	Considerations []string
}

New type to encapsulate analyzer-specific configuration.

type DefaultPlanCreator added in v0.11.0

type DefaultPlanCreator struct{}

DefaultPlanCreator provides a simple implementation for testing.

func (*DefaultPlanCreator) CreatePlan added in v0.11.0

func (p *DefaultPlanCreator) CreatePlan(tasks []Task) ([][]Task, error)

type DefaultTaskParser added in v0.11.0

type DefaultTaskParser struct{}

DefaultTaskParser provides a simple implementation for testing.

func (*DefaultTaskParser) Parse added in v0.11.0

func (p *DefaultTaskParser) Parse(analyzerOutput map[string]interface{}) ([]Task, error)

type DependencyPlanCreator added in v0.14.0

type DependencyPlanCreator struct {
	// Optional configuration for planning
	MaxTasksPerPhase int
}

DependencyPlanCreator creates execution plans based on task dependencies.

func NewDependencyPlanCreator added in v0.14.0

func NewDependencyPlanCreator(maxTasksPerPhase int) *DependencyPlanCreator

func (*DependencyPlanCreator) CreatePlan added in v0.14.0

func (p *DependencyPlanCreator) CreatePlan(tasks []Task) ([][]Task, error)

type ErrorCode added in v0.16.1

type ErrorCode int

ErrorCode represents specific error conditions.

const (
	ErrNoTasksSection ErrorCode = iota
	ErrInvalidXML
	ErrMalformedTasks
)

type ExecutionTrace added in v0.80.0

type ExecutionTrace struct {
	AgentID          string
	AgentType        string
	Task             string
	Input            map[string]interface{}
	Output           map[string]interface{}
	Steps            []TraceStep
	Status           TraceStatus
	Error            string
	StartedAt        time.Time
	CompletedAt      time.Time
	ProcessingTime   time.Duration
	TokenUsage       map[string]int64
	ToolUsageCount   map[string]int
	ContextMetadata  map[string]interface{}
	TerminationCause string
}

ExecutionTrace captures an agent execution with step-level detail.

func (*ExecutionTrace) Clone added in v0.80.0

func (t *ExecutionTrace) Clone() *ExecutionTrace

Clone returns a deep copy of the execution trace.

type FlexibleOrchestrator added in v0.11.0

type FlexibleOrchestrator struct {
	// contains filtered or unexported fields
}

FlexibleOrchestrator coordinates intelligent task decomposition and execution.

func NewFlexibleOrchestrator added in v0.11.0

func NewFlexibleOrchestrator(memory Memory, config OrchestrationConfig) *FlexibleOrchestrator

NewFlexibleOrchestrator creates a new orchestrator instance.

func (*FlexibleOrchestrator) GetProcessor added in v0.16.2

func (f *FlexibleOrchestrator) GetProcessor(processorType string) (TaskProcessor, error)

getProcessor returns the registered processor for a task type.

func (*FlexibleOrchestrator) Process added in v0.11.0

func (f *FlexibleOrchestrator) Process(ctx context.Context, task string, context map[string]interface{}) (*OrchestratorResult, error)

Process handles complete orchestration workflow.

func (*FlexibleOrchestrator) RegisterProcessor added in v0.11.0

func (f *FlexibleOrchestrator) RegisterProcessor(processorType string, processor TaskProcessor)

RegisterProcessor adds a new task processor.

type InMemoryStore

type InMemoryStore struct {
	// contains filtered or unexported fields
}

Simple in-memory implementation.

func NewInMemoryStore

func NewInMemoryStore() *InMemoryStore

func (*InMemoryStore) Clear

func (s *InMemoryStore) Clear() error

func (*InMemoryStore) Delete added in v0.52.0

func (s *InMemoryStore) Delete(key string) error

func (*InMemoryStore) List

func (s *InMemoryStore) List() ([]string, error)

func (*InMemoryStore) Retrieve

func (s *InMemoryStore) Retrieve(key string) (interface{}, error)

func (*InMemoryStore) Store

func (s *InMemoryStore) Store(key string, value interface{}) error

type InterceptableAgent added in v0.47.0

type InterceptableAgent interface {
	Agent

	// ExecuteWithInterceptors runs the agent's task with interceptor support
	ExecuteWithInterceptors(ctx context.Context, input map[string]interface{}, interceptors []core.AgentInterceptor) (map[string]interface{}, error)

	// SetInterceptors sets the default interceptors for this agent instance
	SetInterceptors(interceptors []core.AgentInterceptor)

	// GetInterceptors returns the current interceptors for this agent
	GetInterceptors() []core.AgentInterceptor

	// ClearInterceptors removes all interceptors from this agent
	ClearInterceptors()

	// GetAgentID returns the unique identifier for this agent instance
	GetAgentID() string

	// GetAgentType returns the category/type of this agent
	GetAgentType() string
}

InterceptableAgent extends Agent with interceptor support. This interface provides backward-compatible enhancement for agents that support interceptors.

func WrapAgentWithInterceptors added in v0.47.0

func WrapAgentWithInterceptors(agent Agent, agentID, agentType string, interceptors ...core.AgentInterceptor) InterceptableAgent

WrapAgentWithInterceptors is a convenience function to wrap any agent with interceptor support.

type InterceptorAgentAdapter added in v0.47.0

type InterceptorAgentAdapter struct {
	// contains filtered or unexported fields
}

InterceptorAgentAdapter wraps an existing Agent to provide interceptor support. This allows any existing agent to be used with interceptors without modifying its implementation.

func NewInterceptorAgentAdapter added in v0.47.0

func NewInterceptorAgentAdapter(agent Agent, agentID, agentType string) *InterceptorAgentAdapter

NewInterceptorAgentAdapter creates a new adapter that wraps an existing agent with interceptor support.

func (*InterceptorAgentAdapter) ClearInterceptors added in v0.47.0

func (iaa *InterceptorAgentAdapter) ClearInterceptors()

ClearInterceptors removes all interceptors from this adapter.

func (*InterceptorAgentAdapter) Execute added in v0.47.0

func (iaa *InterceptorAgentAdapter) Execute(ctx context.Context, input map[string]interface{}) (map[string]interface{}, error)

Execute implements the basic Agent interface by calling the wrapped agent.

func (*InterceptorAgentAdapter) ExecuteWithInterceptors added in v0.47.0

func (iaa *InterceptorAgentAdapter) ExecuteWithInterceptors(ctx context.Context, input map[string]interface{}, interceptors []core.AgentInterceptor) (map[string]interface{}, error)

ExecuteWithInterceptors runs the agent's task with interceptor support.

func (*InterceptorAgentAdapter) GetAgentID added in v0.47.0

func (iaa *InterceptorAgentAdapter) GetAgentID() string

GetAgentID returns the unique identifier for this agent instance.

func (*InterceptorAgentAdapter) GetAgentType added in v0.47.0

func (iaa *InterceptorAgentAdapter) GetAgentType() string

GetAgentType returns the category/type of this agent.

func (*InterceptorAgentAdapter) GetCapabilities added in v0.47.0

func (iaa *InterceptorAgentAdapter) GetCapabilities() []core.Tool

GetCapabilities returns the tools/capabilities from the wrapped agent.

func (*InterceptorAgentAdapter) GetInterceptors added in v0.47.0

func (iaa *InterceptorAgentAdapter) GetInterceptors() []core.AgentInterceptor

GetInterceptors returns the current interceptors for this adapter.

func (*InterceptorAgentAdapter) GetMemory added in v0.47.0

func (iaa *InterceptorAgentAdapter) GetMemory() Memory

GetMemory returns the memory store from the wrapped agent.

func (*InterceptorAgentAdapter) SetInterceptors added in v0.47.0

func (iaa *InterceptorAgentAdapter) SetInterceptors(interceptors []core.AgentInterceptor)

SetInterceptors sets the default interceptors for this adapter.

type LLMRequest added in v0.76.0

type LLMRequest struct {
	Prompt       string
	Content      []core.ContentBlock
	Functions    []map[string]interface{}
	ChatMessages []core.ChatMessage
	Options      []core.GenerateOption
}

LLMRequest is built by PrepareRequest for the strategy's CallLLM.

type LLMResult added in v0.76.0

type LLMResult struct {
	TextResponse     *core.LLMResponse
	FunctionResponse map[string]interface{}
	ModuleResponse   map[string]any
}

LLMResult is returned by CallLLM and consumed by ParseResponse.

type LoopAction added in v0.76.0

type LoopAction struct {
	ToolCalls  []core.ToolCall
	Thought    string
	Result     map[string]any
	StopReason string
}

LoopAction represents parsed LLM output — what the loop should do next.

type LoopConfig added in v0.76.0

type LoopConfig struct {
	LLM                core.LLM
	Tools              core.ToolRegistry
	Strategy           LoopStrategy
	MaxIterations      int
	TransformContext   func(ctx context.Context, messages []Message) ([]Message, error)
	OnEvent            func(AgentEvent)
	GenerateOpts       []core.GenerateOption
	ModuleOpts         []core.Option
	ParallelTools      bool
	MaxToolConcurrency int
	ToolTimeout        time.Duration
}

LoopConfig holds all configuration for a RunLoop execution.

type LoopEnv added in v0.76.0

type LoopEnv struct {
	LLM          core.LLM
	Tools        core.ToolRegistry
	GenerateOpts []core.GenerateOption
	ModuleOpts   []core.Option
}

LoopEnv holds the environment available to strategies during LLM calls.

type LoopResult added in v0.76.0

type LoopResult struct {
	Messages []Message
	Output   map[string]any
	// StopReason is one of the StopReason* constants.
	StopReason string
	Iterations int
	Usage      *core.TokenInfo
}

LoopResult holds the result of a RunLoop execution.

type LoopStrategy added in v0.76.0

type LoopStrategy interface {
	PrepareRequest(ctx context.Context, messages []Message, tools []core.Tool) (*LLMRequest, error)
	CallLLM(ctx context.Context, env *LoopEnv, req *LLMRequest) (*LLMResult, error)
	ParseResponse(ctx context.Context, response *LLMResult) (*LoopAction, error)
	ShouldContinue(ctx context.Context, action *LoopAction, iteration int) bool
	ToolUsePolicy() string
}

LoopStrategy defines how to interact with the LLM within the loop. Strategy owns the LLM call (via CallLLM), not RunLoop.

type Memory

type Memory interface {
	// Store saves a value with a given key
	Store(key string, value interface{}) error

	// Retrieve gets a value by key
	Retrieve(key string) (interface{}, error)

	// Delete removes a value by key
	Delete(key string) error

	// List returns all stored keys
	List() ([]string, error)

	// Clear removes all stored values
	Clear() error
}

Memory provides storage capabilities for agents.

type Message added in v0.76.0

type Message struct {
	ID         string              `json:"id"`
	Role       MessageRole         `json:"role"`
	Content    []core.ContentBlock `json:"content"`
	ToolCalls  []core.ToolCall     `json:"tool_calls,omitempty"`
	ToolResult *MessageToolResult  `json:"tool_result,omitempty"`
	Metadata   map[string]any      `json:"metadata,omitempty"`
}

Message represents a single message in the agent's conversation. This is the agent-level message type; use ToChatMessage() to convert to core.ChatMessage at the LLM boundary.

func NewTextMessage added in v0.76.0

func NewTextMessage(role MessageRole, text string) Message

NewTextMessage creates a message with a single text content block.

func NewToolResultMessage added in v0.76.0

func NewToolResultMessage(callID, toolName string, result core.ToolResult) Message

NewToolResultMessage creates a tool result message from a core.ToolResult.

func (Message) ShouldSendToLLM added in v0.76.0

func (m Message) ShouldSendToLLM() bool

ShouldSendToLLM reports whether this message should be included in provider-facing chat history.

func (Message) TextContent added in v0.76.0

func (m Message) TextContent() string

TextContent returns the concatenated text content of all text blocks in the message.

func (Message) ToChatMessage added in v0.76.0

func (m Message) ToChatMessage() core.ChatMessage

ToChatMessage converts an agent-level Message to a core.ChatMessage for the LLM boundary. Strips metadata and normalizes internal-only messages.

type MessageRole added in v0.76.0

type MessageRole string

MessageRole defines the role of a message in the conversation.

const (
	RoleUser      MessageRole = "user"
	RoleAssistant MessageRole = "assistant"
	RoleSystem    MessageRole = "system"
	RoleTool      MessageRole = "tool"
	RoleInternal  MessageRole = "internal" // never sent to LLM
)

type MessageToolResult added in v0.76.0

type MessageToolResult struct {
	ToolCallID string              `json:"tool_call_id"`
	Name       string              `json:"name"`
	Content    []core.ContentBlock `json:"content"`
	IsError    bool                `json:"is_error,omitempty"`
	Raw        map[string]any      `json:"raw,omitempty"`
}

MessageToolResult carries the result of a tool execution at the agent message level. Richer than core.ChatToolResult — includes raw result data for trajectory capture.

type NeedsLLM added in v0.76.0

type NeedsLLM interface {
	SetLLM(llm core.LLM)
}

NeedsLLM is an optional interface for strategies that need LLM propagation. RunLoop calls SetLLM before the first iteration if the strategy implements this.

type OrchestrationConfig added in v0.11.0

type OrchestrationConfig struct {
	// MaxConcurrent controls maximum parallel task execution
	MaxConcurrent int

	// DefaultTimeout for task execution
	DefaultTimeout time.Duration

	// RetryConfig specifies retry behavior for failed tasks
	RetryConfig *RetryConfig

	// CustomProcessors maps processor types to implementations
	CustomProcessors map[string]TaskProcessor
	TaskParser       TaskParser
	PlanCreator      PlanCreator

	AnalyzerConfig AnalyzerConfig
	Options        core.Option
}

OrchestrationConfig allows customizing orchestrator behavior.

type OrchestratorResult added in v0.11.0

type OrchestratorResult struct {
	// CompletedTasks holds results from successful tasks
	CompletedTasks map[string]interface{}

	// FailedTasks contains tasks that could not be completed
	FailedTasks map[string]error

	// Analysis contains orchestrator's task breakdown reasoning
	Analysis string

	// Metadata holds additional orchestration information
	Metadata map[string]interface{}
	// contains filtered or unexported fields
}

OrchestratorResult contains orchestration outputs.

type PlanCreator added in v0.11.0

type PlanCreator interface {
	// CreatePlan organizes tasks into execution phases
	CreatePlan(tasks []Task) ([][]Task, error)
}

PlanCreator defines how to create an execution plan from tasks.

type RetryConfig added in v0.11.0

type RetryConfig struct {
	MaxAttempts       int
	BackoffMultiplier float64
}

RetryConfig specifies retry behavior.

type SessionRecord added in v0.82.0

type SessionRecord struct {
	ID          string         `json:"id"`
	SessionID   string         `json:"session_id"`
	AgentID     string         `json:"agent_id,omitempty"`
	AgentType   string         `json:"agent_type,omitempty"`
	TaskID      string         `json:"task_id,omitempty"`
	Task        string         `json:"task"`
	StartedAt   time.Time      `json:"started_at"`
	CompletedAt time.Time      `json:"completed_at"`
	Completed   bool           `json:"completed"`
	FinalAnswer string         `json:"final_answer,omitempty"`
	Error       string         `json:"error,omitempty"`
	Highlights  []string       `json:"highlights,omitempty"`
	Metadata    map[string]any `json:"metadata,omitempty"`
}

SessionRecord captures one persisted agent run inside a logical session.

func (SessionRecord) Clone added in v0.82.0

func (r SessionRecord) Clone() SessionRecord

Clone returns a deep copy of the session record.

type SessionStore added in v0.82.0

type SessionStore struct {
	// contains filtered or unexported fields
}

SessionStore persists session records on top of the generic Memory interface.

func NewSessionStore added in v0.82.0

func NewSessionStore(memory Memory) *SessionStore

NewSessionStore returns a session store using the default key prefix.

func NewSessionStoreWithPrefix added in v0.82.0

func NewSessionStoreWithPrefix(memory Memory, prefix string) *SessionStore

NewSessionStoreWithPrefix returns a session store with a custom key prefix.

func (*SessionStore) Append added in v0.82.0

func (s *SessionStore) Append(record SessionRecord) error

Append writes or replaces a session record inside the ordered session log.

func (*SessionStore) Recent added in v0.82.0

func (s *SessionStore) Recent(sessionID string, limit int) ([]SessionRecord, error)

Recent loads up to limit recent session records in chronological order.

type SignatureStrategy added in v0.76.0

type SignatureStrategy interface {
	LoopStrategy
	Signature() core.Signature
	SetSignature(sig core.Signature)
	Demos() []core.Example
	SetDemos(demos []core.Example)
}

SignatureStrategy is an optional interface for strategies that carry a signature. Optimizers use this to access and modify the signature without knowing the concrete strategy type.

type Task added in v0.11.0

type Task struct {
	// ID uniquely identifies the task
	ID string

	// Type indicates the kind of task
	Type string

	// Metadata holds task-specific information
	Metadata map[string]interface{}

	// Dependencies lists task IDs that must complete before this task
	Dependencies []string

	// Priority indicates task importance (lower number = higher priority)
	Priority int

	// ProcessorType indicates which processor should handle this task
	ProcessorType string
}

Task represents a unit of work identified by the orchestrator.

type TaskParser added in v0.11.0

type TaskParser interface {
	// Parse converts analyzer output into a slice of tasks
	Parse(analyzerOutput map[string]interface{}) ([]Task, error)
}

TaskParser defines how to parse tasks from analyzer output.

type TaskProcessor added in v0.11.0

type TaskProcessor interface {
	// Process handles a single task execution
	Process(ctx context.Context, task Task, taskContext map[string]interface{}) (interface{}, error)
}

TaskProcessor defines how to process individual tasks.

type ToolObservation added in v0.82.0

type ToolObservation struct {
	ModelText   string
	DisplayText string
	Details     map[string]any
	IsError     bool
	Synthetic   bool
	Redacted    bool
	Truncated   bool
}

ToolObservation separates model-visible output from operator-visible detail.

func BlockedToolObservation added in v0.82.0

func BlockedToolObservation(toolName string, reason string) ToolObservation

BlockedToolObservation creates a synthetic error observation for blocked calls.

func NormalizeToolResult added in v0.82.0

func NormalizeToolResult(result core.ToolResult) ToolObservation

NormalizeToolResult converts a ToolResult into a dual-channel observation.

type TraceStatus added in v0.80.0

type TraceStatus string

TraceStatus captures the high-level outcome of an agent trace.

const (
	TraceStatusSuccess TraceStatus = "success"
	TraceStatusFailure TraceStatus = "failure"
	TraceStatusPartial TraceStatus = "partial"
)

type TraceStep added in v0.80.0

type TraceStep struct {
	Index              int
	Thought            string
	ActionRaw          string
	Tool               string
	Arguments          map[string]interface{}
	Observation        string
	ObservationDisplay string
	ObservationDetails map[string]any
	Duration           time.Duration
	Success            bool
	Error              string
	Synthetic          bool
	Redacted           bool
	Truncated          bool
}

TraceStep represents a structured step in an agent execution.

func (TraceStep) Clone added in v0.80.0

func (s TraceStep) Clone() TraceStep

Clone returns a deep copy of the trace step so callers can safely retain it.

type XMLError added in v0.16.1

type XMLError struct {
	Code    ErrorCode
	Message string
	Details map[string]interface{}
}

XMLError represents structured errors during XML processing.

func (*XMLError) Error added in v0.16.1

func (e *XMLError) Error() string

type XMLMetadata added in v0.14.0

type XMLMetadata struct {
	Items []XMLMetadataItem `xml:"item"`
}

type XMLMetadataItem added in v0.14.0

type XMLMetadataItem struct {
	Key   string `xml:"key,attr"`
	Value string `xml:",chardata"`
}

type XMLNormalizer added in v0.16.1

type XMLNormalizer struct {
	// contains filtered or unexported fields
}

XMLNormalizer handles cleaning and standardization of XML content.

func NewXMLNormalizer added in v0.16.1

func NewXMLNormalizer() *XMLNormalizer

NewXMLNormalizer creates a new normalizer with compiled regex patterns.

func (*XMLNormalizer) NormalizeXML added in v0.16.1

func (n *XMLNormalizer) NormalizeXML(content string) (string, error)

NormalizeXML cleans and standardizes XML content for parsing.

type XMLTask added in v0.14.0

type XMLTask struct {
	XMLName       xml.Name    `xml:"task"`
	ID            string      `xml:"id,attr"`
	Type          string      `xml:"type,attr"`      // Make sure this maps to the type attribute
	ProcessorType string      `xml:"processor,attr"` // Make sure this maps to the processor attribute
	Priority      int         `xml:"priority,attr"`
	Description   string      `xml:"description"`
	Dependencies  []string    `xml:"dependencies>dep"` // This maps to the <dependencies><dep>...</dep></dependencies> structure
	Metadata      XMLMetadata `xml:"metadata"`
}

type XMLTaskParser added in v0.14.0

type XMLTaskParser struct {
	// Configuration for XML parsing
	RequiredFields []string
}

func (*XMLTaskParser) Parse added in v0.14.0

func (p *XMLTaskParser) Parse(analyzerOutput map[string]interface{}) ([]Task, error)

Directories

Path Synopsis
Package ace implements Agentic Context Engineering (ACE) for self-improving agents.
Package ace implements Agentic Context Engineering (ACE) for self-improving agents.
Package a2a implements Google's Agent-to-Agent (a2a) protocol for dspy-go.
Package a2a implements Google's Agent-to-Agent (a2a) protocol for dspy-go.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL