Agent represents an AI agent
| 20 | |
| 21 | // Agent represents an AI agent |
| 22 | type Agent struct { |
| 23 | name string |
| 24 | description string |
| 25 | welcomeMessage string |
| 26 | instruction string |
| 27 | toolsets []*tools.StartableToolSet |
| 28 | models []provider.Provider |
| 29 | fallbackModels []provider.Provider // Fallback models to try if primary fails |
| 30 | fallbackRetries int // Number of retries per fallback model with exponential backoff |
| 31 | fallbackCooldown time.Duration // Duration to stick with fallback after non-retryable error |
| 32 | titleModel provider.Provider // Optional dedicated model for session-title generation |
| 33 | compactionModel provider.Provider // Optional dedicated model for session compaction (summary generation) |
| 34 | modelOverrides atomic.Pointer[[]provider.Provider] // Optional model override(s) set at runtime (supports alloy) |
| 35 | subAgents []*Agent |
| 36 | handoffs []*Agent |
| 37 | forceHandoff *Agent |
| 38 | parents []*Agent |
| 39 | addDate bool |
| 40 | addEnvironmentInfo bool |
| 41 | addDescriptionParameter bool |
| 42 | redactSecrets bool |
| 43 | saferShell bool |
| 44 | maxIterations int |
| 45 | maxConsecutiveToolCalls int |
| 46 | maxOldToolCallTokens int |
| 47 | numHistoryItems int |
| 48 | addPromptFiles []string |
| 49 | tools []tools.Tool |
| 50 | commands types.Commands |
| 51 | harness *latest.HarnessConfig |
| 52 | hooks *latest.HooksConfig |
| 53 | cache *cache.Cache |
| 54 | |
| 55 | // warningsMu guards pendingWarnings. AddToolWarning and DrainWarnings |
| 56 | // may be called concurrently from the runtime loop, the MCP server, |
| 57 | // the TUI and session manager. |
| 58 | warningsMu sync.Mutex |
| 59 | pendingWarnings []string |
| 60 | |
| 61 | // collisionsMu guards reportedCollisions, the once-per-streak guard for |
| 62 | // duplicate-tool-name warnings. collectTools may run concurrently from |
| 63 | // the runtime loop and MCP notification handlers. |
| 64 | collisionsMu sync.Mutex |
| 65 | reportedCollisions map[string]bool |
| 66 | } |
| 67 | |
| 68 | // New creates a new agent |
| 69 | func New(name, prompt string, opts ...Opt) *Agent { |
nothing calls this directly
no outgoing calls
no test coverage detected