Documentation
¶
Overview ¶
Package agent provides a unified interface for all LLM agents in the system.
Index ¶
- func WithContext(ctx context.Context, shared *SharedContext) context.Context
- type Agent
- type AgentType
- type AgenticOptions
- type Capabilities
- type CapableAgent
- type ContextService
- type Executor
- func (e *Executor) AgentLogger() *agentlog.Logger
- func (e *Executor) Client() openrouter.Client
- func (e *Executor) ExecuteAgentic(ctx context.Context, req SingleShotRequest, opts AgenticOptions) (*Response, error)
- func (e *Executor) ExecuteSingleShot(ctx context.Context, req SingleShotRequest) (*Response, error)
- type MediaPart
- type Message
- type Registry
- type Request
- type Response
- type SharedContext
- type SingleShotRequest
- type TokenUsage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithContext ¶
func WithContext(ctx context.Context, shared *SharedContext) context.Context
WithContext injects SharedContext into context.Context.
Types ¶
type Agent ¶
type Agent interface {
// Type returns the agent's type identifier.
Type() AgentType
// Execute runs the agent with the given request.
Execute(ctx context.Context, req *Request) (*Response, error)
}
Agent is the core interface all agents implement.
type AgenticOptions ¶
type AgenticOptions struct {
MaxTurns int
Tools []openrouter.Tool
ToolHandler func(ctx context.Context, calls []openrouter.ToolCall) []openrouter.Message
Timeout time.Duration
TurnTimeout time.Duration
Reasoning *openrouter.ReasoningConfig
Plugins []openrouter.Plugin
ToolChoice any // "auto", "none", "required", or specific tool
}
AgenticOptions for multi-turn agents.
type Capabilities ¶
type Capabilities struct {
// Execution model
IsAgentic bool // Uses tool calls (multi-turn)
SupportsStreaming bool // Can stream responses
// Input capabilities
SupportedMedia []string // ["image", "audio", "pdf"]
MaxInputTokens int // Context limit
// Output format
OutputFormat string // "text", "json", "structured"
}
Capabilities describes what an agent can do.
type CapableAgent ¶
type CapableAgent interface {
Agent
// Capabilities returns the agent's capabilities.
Capabilities() Capabilities
// Description returns a human-readable description for tool use.
Description() string
}
CapableAgent extends Agent with metadata for discovery.
type ContextService ¶
type ContextService struct {
// contains filtered or unexported fields
}
ContextService loads and manages SharedContext.
func NewContextService ¶
func NewContextService( factRepo storage.FactRepository, topicRepo storage.TopicRepository, cfg *config.Config, logger *slog.Logger, ) *ContextService
NewContextService creates a new ContextService.
func (*ContextService) Load ¶
func (c *ContextService) Load(ctx context.Context, userID int64) *SharedContext
Load creates SharedContext for a user. Call once per request at the beginning of processing.
func (*ContextService) SetPeopleRepository ¶ added in v0.5.1
func (c *ContextService) SetPeopleRepository(repo storage.PeopleRepository)
SetPeopleRepository sets the people repository for loading inner circle.
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor provides common execution logic for agents.
func NewExecutor ¶
func NewExecutor( client openrouter.Client, agentLogger *agentlog.Logger, logger *slog.Logger, ) *Executor
NewExecutor creates a new Executor.
func (*Executor) AgentLogger ¶
AgentLogger returns the agent logger.
func (*Executor) Client ¶
func (e *Executor) Client() openrouter.Client
Client returns the underlying OpenRouter client. Useful for agents that need custom request handling.
func (*Executor) ExecuteAgentic ¶
func (e *Executor) ExecuteAgentic(ctx context.Context, req SingleShotRequest, opts AgenticOptions) (*Response, error)
ExecuteAgentic runs a multi-turn agent loop with tool calls.
func (*Executor) ExecuteSingleShot ¶
ExecuteSingleShot runs a single LLM call with logging.
type MediaPart ¶
type MediaPart struct {
Type string // "image", "audio", "file"
MimeType string
Data []byte
URL string // Alternative to Data
}
MediaPart represents multimodal input.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds all registered agents.
type Request ¶
type Request struct {
Shared *SharedContext
// Query
Query string // Main query/content to process
Messages []Message // Conversation history (for chat agents)
// Multimodal
Media []MediaPart // Images, audio, files
// Agent-specific
Params map[string]any // Custom parameters
}
Request is the unified input for all agents.
type Response ¶
type Response struct {
// Content
Content string // Text response
Structured any // Parsed result (for JSON agents)
// Metadata
Tokens TokenUsage
Duration time.Duration
Reasoning string // Chain-of-thought (if available)
// Agent-specific
Metadata map[string]any
}
Response is the unified output from all agents.
type SharedContext ¶
type SharedContext struct {
// Profile (always loaded)
RecentTopics string // Formatted <recent_topics>
InnerCircle string // Formatted <inner_circle> (Work_Inner + Family)
// Metadata
}
SharedContext holds user data shared across all agents. Loaded once per request to ensure all agents see the same data.
func FromContext ¶
func FromContext(ctx context.Context) *SharedContext
FromContext extracts SharedContext from context.Context. Returns nil if not found.
func MustFromContext ¶
func MustFromContext(ctx context.Context) *SharedContext
MustFromContext extracts SharedContext from context.Context. Panics if not found.
type SingleShotRequest ¶
type SingleShotRequest struct {
AgentType AgentType
UserID int64
Model string
SystemPrompt string
UserPrompt string
Messages []openrouter.Message // Alternative to SystemPrompt+UserPrompt
Temperature *float64
JSONMode bool
JSONSchema *openrouter.JSONSchema // Optional: strict JSON schema validation
}
SingleShotRequest for simple one-turn agents.
type TokenUsage ¶
TokenUsage tracks token consumption.
func (TokenUsage) TotalTokens ¶
func (t TokenUsage) TotalTokens() int
TotalTokens returns the total token count. If Total is set, returns it; otherwise computes Prompt + Completion.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package archivist provides the Archivist agent that extracts and manages facts and people from conversations for long-term memory.
|
Package archivist provides the Archivist agent that extracts and manages facts and people from conversations for long-term memory. |
|
Package enricher provides the Enricher agent that expands user queries for better vector retrieval in the RAG pipeline.
|
Package enricher provides the Enricher agent that expands user queries for better vector retrieval in the RAG pipeline. |
|
Package merger provides the Merger agent that evaluates whether two topics should be merged and generates a combined summary.
|
Package merger provides the Merger agent that evaluates whether two topics should be merged and generates a combined summary. |
|
Package prompts provides typed parameter structs for agent prompt templates.
|
Package prompts provides typed parameter structs for agent prompt templates. |
|
Package reranker provides the Reranker agent that uses tool calls to select the most relevant topics from vector search candidates.
|
Package reranker provides the Reranker agent that uses tool calls to select the most relevant topics from vector search candidates. |
|
Package splitter provides the Splitter agent that segments conversation logs into distinct topics for storage and retrieval.
|
Package splitter provides the Splitter agent that segments conversation logs into distinct topics for storage and retrieval. |
|
Package testing provides test utilities for the agent package.
|
Package testing provides test utilities for the agent package. |