Documentation
¶
Overview ¶
Package agent sets up the ADK Go agent loop with tools, system prompt, and runner for the pi-go coding agent.
Index ¶
- Constants
- func LoadInstruction(baseInstruction string) string
- func WithRetry(cfg RetryConfig, runFn func() iter.Seq2[*session.Event, error]) iter.Seq2[*session.Event, error]
- type AfterToolCallback
- type Agent
- func (a *Agent) CreateSession(ctx context.Context) (string, error)
- func (a *Agent) RebuildWithInstruction(instruction string) error
- func (a *Agent) Run(ctx context.Context, sessionID string, userMessage string) iter.Seq2[*session.Event, error]
- func (a *Agent) RunStreaming(ctx context.Context, sessionID string, userMessage string) iter.Seq2[*session.Event, error]
- type BeforeToolCallback
- type Config
- type RetryConfig
Constants ¶
const ( // AppName is the ADK application name used for session management. AppName = "pi-go" // DefaultUserID is the default user ID for local single-user sessions. DefaultUserID = "local" )
const SystemInstruction = `` /* 5446-byte string literal not displayed */
SystemInstruction is the default system prompt for the coding agent.
Variables ¶
This section is empty.
Functions ¶
func LoadInstruction ¶
LoadInstruction attempts to load an AGENTS.md file from the working directory and appends its content to the base instruction.
func WithRetry ¶
func WithRetry(cfg RetryConfig, runFn func() iter.Seq2[*session.Event, error]) iter.Seq2[*session.Event, error]
WithRetry wraps an agent run function with retry logic for transient errors. If the iterator yields a transient error, it sleeps and retries the entire run. Non-transient errors are yielded immediately without retry.
Types ¶
type AfterToolCallback ¶
type AfterToolCallback = llmagent.AfterToolCallback
re-export callback types for use by CLI without importing llmagent directly.
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
Agent wraps an ADK Runner and session management for the coding agent.
func (*Agent) CreateSession ¶
CreateSession creates a new session and returns its ID.
func (*Agent) RebuildWithInstruction ¶
RebuildWithInstruction recreates the agent's internal runner with a new system instruction while preserving all other configuration (tools, callbacks, etc.). The session service is reused so existing sessions remain accessible.
type BeforeToolCallback ¶
type BeforeToolCallback = llmagent.BeforeToolCallback
re-export callback types for use by CLI without importing llmagent directly.
type Config ¶
type Config struct {
// Model is the LLM provider to use (implements model.LLM).
Model model.LLM
// Tools are the tools available to the agent.
Tools []tool.Tool
// Toolsets are additional tool providers (e.g. MCP toolsets).
Toolsets []tool.Toolset
// Instruction overrides the default system instruction.
// If empty, SystemInstruction is used.
Instruction string
// SessionService overrides the default in-memory session service.
// If nil, an in-memory service is created.
SessionService session.Service
// BeforeToolCallbacks run before each tool execution.
BeforeToolCallbacks []BeforeToolCallback
// AfterToolCallbacks run after each tool execution.
AfterToolCallbacks []AfterToolCallback
}
Config holds configuration for creating a new Agent.
type RetryConfig ¶
type RetryConfig struct {
// MaxRetries is the maximum number of retry attempts (default 3).
MaxRetries int
// InitialDelay is the base delay before the first retry (default 1s).
InitialDelay time.Duration
// MaxDelay caps the exponential backoff delay (default 30s).
MaxDelay time.Duration
}
RetryConfig controls retry behavior for transient LLM errors.
func DefaultRetryConfig ¶
func DefaultRetryConfig() RetryConfig
DefaultRetryConfig returns sensible defaults for retry behavior.