LocalRuntime manages the execution of agents
| 205 | |
| 206 | // LocalRuntime manages the execution of agents |
| 207 | type LocalRuntime struct { |
| 208 | ctx func() context.Context |
| 209 | toolMap map[string]ToolHandlerFunc |
| 210 | team *team.Team |
| 211 | agents *agentRouter |
| 212 | resumeChan chan ResumeRequest |
| 213 | tracer trace.Tracer |
| 214 | modelsStore ModelStore |
| 215 | sessionCompaction bool |
| 216 | managedOAuth bool |
| 217 | unmanagedOAuthRedirectURI string |
| 218 | nonInteractive bool |
| 219 | startupInfoEmitted bool // Track if startup info has been emitted to avoid unnecessary duplication |
| 220 | elicitationRequestCh chan ElicitationResult // Channel for receiving elicitation responses |
| 221 | elicitation elicitationBridge // Owns the per-stream events channel for outbound elicitation requests |
| 222 | sessionStore session.Store |
| 223 | workingDir string // Working directory for hooks execution |
| 224 | env []string // Environment variables for hooks execution |
| 225 | modelSwitcherCfg *ModelSwitcherConfig |
| 226 | providerRegistry *provider.Registry |
| 227 | gatewayModels gatewayModelsCache |
| 228 | dmrModels dmrModelsCache |
| 229 | |
| 230 | // hooksRegistry is the runtime-private hooks.Registry used to build |
| 231 | // every Executor. It carries the runtime-owned builtin hooks |
| 232 | // (add_date, add_environment_info) registered once during |
| 233 | // NewLocalRuntime, so they're available to every agent without |
| 234 | // touching any process-wide state. |
| 235 | hooksRegistry *hooks.Registry |
| 236 | |
| 237 | // autoInjectors run on every per-agent hook config during |
| 238 | // [buildHooksExecutors] so embedders can plug in builtins (today |
| 239 | // snapshot via [builtins.SnapshotController]) without the runtime |
| 240 | // hard-coding their wiring. Set via [WithAutoInjector]. |
| 241 | autoInjectors []builtins.AutoInjector |
| 242 | |
| 243 | // hooksExecByAgent holds the per-agent [hooks.Executor], keyed by |
| 244 | // agent name. Built once in [NewLocalRuntime.buildHooksExecutors] |
| 245 | // after team and runtime config are finalized; agents with no hooks |
| 246 | // have no entry, so [hooksExec] returns nil for them. Read-only after |
| 247 | // construction, so no locking is needed. |
| 248 | hooksExecByAgent map[string]*hooks.Executor |
| 249 | |
| 250 | // transforms is the runtime's [MessageTransform] chain, applied to |
| 251 | // every LLM call in registration order. Populated by |
| 252 | // [NewLocalRuntime] (for the runtime-shipped strip transform) and by |
| 253 | // [WithMessageTransform] (for embedder-supplied transforms). |
| 254 | // Read-only after construction. |
| 255 | transforms []registeredTransform |
| 256 | |
| 257 | fallback *fallbackExecutor |
| 258 | |
| 259 | // observers receive every event the runtime produces, in |
| 260 | // registration order. Built up via [WithEventObserver] during |
| 261 | // construction; read-only afterwards. Always contains at least one |
| 262 | // entry: the auto-registered [PersistenceObserver] for the |
| 263 | // configured session store. See [EventObserver] for the contract. |
| 264 | observers []EventObserver |
nothing calls this directly
no outgoing calls
no test coverage detected