Documentation
¶
Index ¶
- Variables
- func DegenerateReasoningStopReason() string
- func LoadAgentsMD(dir string) string
- func LoopWithRetry(ctx context.Context, adapter model.Adapter, modelName string, maxTokens int, ...) ([]model.Message, string, error)
- func MergeSkills(baseSystem, baseInitial string, skills []Skill) (system, initial string)
- func RunLoop(ctx context.Context, adapter model.Adapter, modelName string, maxTokens int, ...) ([]model.Message, string, error)
- func SetCompactionTaskPrompt(prompt string)
- func SetCompactionThreshold(bytes int)
- func SetGlobalConfig(cfg *Config)
- func SetGlobalProfiles(defaultAgent string, profiles map[string]Config)
- type ApprovalChecker
- type Config
- type FileReadConfig
- type LoopRunState
- type OrchestratorExecutor
- type PonyConfig
- type Profile
- type Provider
- func (p *Provider) AnswerPermission(ctx context.Context, sessionID string, requestID string, ...) error
- func (p *Provider) Cancel(ctx context.Context, sessionID string) error
- func (p *Provider) Capabilities(ctx context.Context) (runtime.Capabilities, error)
- func (p *Provider) Events(ctx context.Context, sessionID string) (<-chan events.Event, error)
- func (p *Provider) Prompt(ctx context.Context, sessionID string, prompt string) error
- func (p *Provider) Resume(ctx context.Context, sessionID string) (runtime.Session, error)
- func (p *Provider) Start(ctx context.Context, opts runtime.StartOptions) (runtime.Session, error)
- type ShellConfig
- type Skill
- type StopCondition
- type ToolApproval
- type ToolGate
Constants ¶
This section is empty.
Variables ¶
var RuntimeIDKey = &runtimeIDKey{}
Functions ¶
func DegenerateReasoningStopReason ¶
func DegenerateReasoningStopReason() string
DegenerateReasoningStopReason exposes the canonical stop reason for tests and other packages that need to recognise or forward it.
func LoadAgentsMD ¶
LoadAgentsMD walks up from dir to find an AGENTS.md file. Returns the content if found, or empty string if not found (not an error).
func LoopWithRetry ¶
func LoopWithRetry( ctx context.Context, adapter model.Adapter, modelName string, maxTokens int, history []model.Message, reg *tools.Registry, workingDir string, eventCh chan<- events.Event, stopConditions []StopCondition, approval ApprovalChecker, ) ([]model.Message, string, error)
LoopWithRetry wraps RunLoop with exponential backoff retry. Retries on error only if no tool calls were dispatched (retrying after tool execution is unsafe because side effects would replay). Max 4 attempts total. Backoff: 1s, 2s, 4s.
func MergeSkills ¶
MergeSkills merges skill prompts into a profile's system_prompt and initial_prompt. Later skills' prompts are appended with section headers.
func RunLoop ¶
func RunLoop( ctx context.Context, adapter model.Adapter, modelName string, maxTokens int, history []model.Message, reg *tools.Registry, workingDir string, eventCh chan<- events.Event, stopConditions []StopCondition, approval ApprovalChecker, ) ([]model.Message, string, error)
RunLoop drives the multi-turn loop until a stop condition or terminal condition.
It sends the history + tool defs to the adapter each turn, processes streamed chunks, accumulates tool calls, dispatches them through the registry, and appends results to history.
If approval is non-nil, it is called before each tool to check for permission. Events are emitted on eventCh as the loop runs for subscribers.
Returns the final conversation history (including all assistant and tool turns) and the final stop reason.
func SetCompactionTaskPrompt ¶
func SetCompactionTaskPrompt(prompt string)
SetCompactionTaskPrompt overrides the task prompt for LLM compaction. Empty string resets to the default. Safe to call concurrently with RunLoop.
func SetCompactionThreshold ¶
func SetCompactionThreshold(bytes int)
SetCompactionThreshold overrides the byte threshold for compactForRequest. Values <= 0 reset to the default (80 KB). Called from New() which derives the byte value from the profile's Context field (tokens × bytesPerToken).
func SetGlobalConfig ¶
func SetGlobalConfig(cfg *Config)
SetGlobalConfig stores the pony config for the factory path.
func SetGlobalProfiles ¶
SetGlobalProfiles stores pony profile configs for per-attempt agent resolution.
Types ¶
type ApprovalChecker ¶
type ApprovalChecker func(ctx context.Context, toolName string, eventCh chan<- events.Event) (bool, error)
ApprovalChecker is called before a tool executes. It blocks until the permission is granted or denied. Returns true if approved, false if denied.
type Config ¶
type Config struct {
Adapter model.Adapter
Model string
MaxTokens int
SystemPrompt string
InitialPrompt string
Executor OrchestratorExecutor // nil when OrchTools is false
LocalTools bool
OrchTools bool
WorkingDir string // for AGENTS.md discovery
InjectAgentsMD bool
AllowedReadDirs []string // additional directories read tools may access (e.g. skills)
AllowedWriteDirs []string // additional directories write tools may access
ToolApproval map[string]bool // tool name → requires approval
ShellConfig *ShellConfig // overrides for shell tool
FileReadConfig *FileReadConfig // overrides for file_read tool
Context int // model context window in tokens; 0 = use default compaction
CompactionPrompt string // override LLM compaction task prompt
// StopConditions for the loop.
StopConditions []StopCondition
// contains filtered or unexported fields
}
Config configures the pony provider.
type FileReadConfig ¶
type FileReadConfig = tools.FileReadConfig
FileReadConfig overrides file_read tool defaults per-profile.
type LoopRunState ¶
LoopRunState tracks the state across loop iterations for stop conditions.
type OrchestratorExecutor ¶
type OrchestratorExecutor interface {
SpawnAgent(ctx context.Context, params map[string]any) (sessionID string, err error)
SendPrompt(ctx context.Context, sessionID, prompt, requestID string) error
GetStatus(ctx context.Context, sessionID string) (map[string]any, error)
WaitForDone(ctx context.Context, sessionID string) (*runtime.AgentResult, error)
SendToParent(ctx context.Context, runtimeID, message string) error
}
OrchestratorExecutor wraps the control-socket client for orchestration tools.
func NewControlSocketExecutor ¶
func NewControlSocketExecutor(socketPath string) (OrchestratorExecutor, error)
NewControlSocketExecutor creates an OrchestratorExecutor backed by a control socket client. This is used by the CLI to wire orchestration tools.
type PonyConfig ¶
type PonyConfig struct {
BaseURL string `json:"base_url"`
APIKeyEnv string `json:"api_key_env"`
DefaultAgent string `json:"default_agent"`
Profiles map[string]Profile `json:"profiles"`
}
PonyConfig is the top-level pony configuration loaded from the JSON config file.
func LoadPonyConfig ¶
func LoadPonyConfig(path string) (*PonyConfig, error)
LoadPonyConfig reads and parses a JSON pony config file.
func (*PonyConfig) ResolveProfile ¶
func (c *PonyConfig) ResolveProfile(name string) (*Profile, error)
ResolveProfile looks up a profile by name, falling back to default_agent.
type Profile ¶
type Profile struct {
Model string `json:"model"`
SystemPrompt string `json:"system_prompt,omitempty"`
InitialPrompt string `json:"initial_prompt,omitempty"`
InjectAgentsMD bool `json:"inject_agents_md,omitempty"`
Tools ToolGate `json:"tools"`
MaxTokens int `json:"max_tokens,omitempty"`
ToolApproval ToolApproval `json:"tool_approval,omitempty"`
ShellConfig *ShellConfig `json:"shell_config,omitempty"`
FileReadConfig *FileReadConfig `json:"file_read_config,omitempty"`
BaseURL string `json:"base_url,omitempty"`
APIKeyEnv string `json:"api_key_env,omitempty"`
Skills []string `json:"skills,omitempty"` // skill names to load
Context int `json:"context,omitempty"` // model context window in tokens; 0 = use default compaction (80 KB)
CompactionPrompt string `json:"compaction_prompt,omitempty"` // override LLM compaction task prompt
}
Profile defines a named agent profile with its own model, prompts, and tool gating.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider implements runtime.Provider for the pony backend.
func NewWithOptions ¶
func NewWithOptions(opts runtime.StartOptions) *Provider
func (*Provider) AnswerPermission ¶
func (*Provider) Capabilities ¶
type ShellConfig ¶
type ShellConfig = tools.ShellConfig
ShellConfig overrides shell tool defaults per-profile. This is a reference to the tools.ShellConfig type, aliased for convenience.
type Skill ¶
type Skill struct {
Name string `json:"name"`
SystemPrompt string `json:"system_prompt,omitempty"`
InitialPrompt string `json:"initial_prompt,omitempty"`
}
Skill is a reusable prompt component loaded from a skill file.
func LoadSkills ¶
LoadSkills discovers and loads skills referenced by a profile. Discovery order:
- $PONY_SKILLS_DIR env var
- .pony/skills/ next to the config file
- ~/.config/avenor/skills/
Skill files can be JSON (.json) or Markdown (.md). JSON format: {"system_prompt": "...", "initial_prompt": "..."} MD format: first section after frontmatter is system_prompt, second section (after ---) is initial_prompt.
type StopCondition ¶
type StopCondition func(state LoopRunState) bool
StopCondition is a function that returns true when the loop should stop. Called after each turn (including tool execution).
func StepCountIs ¶
func StepCountIs(n int) StopCondition
StepCountIs returns a stop condition that triggers after n steps (loop turns).
type ToolApproval ¶
ToolApproval maps tool names to whether they require approval before execution.