@@ -189,10 +189,11 @@ func readRuntimeSettingsJson(startupAppConfig config.ApplicationConfig) fileHand
189189 handler := func (fileContent []byte , appConfig * config.ApplicationConfig ) error {
190190 xlog .Debug ("processing runtime_settings.json" )
191191
192- // Determine if settings came from env vars by comparing with startup config
193- // startupAppConfig contains the original values set from env vars at startup.
194- // If current values match startup values, they came from env vars (or defaults).
195- // We apply file settings only if current values match startup values (meaning not from env vars).
192+ // Determine if settings were changed via API after startup.
193+ // startupAppConfig contains values set from env vars at startup.
194+ // If current value matches startup value, it was NOT changed via API,
195+ // so it's safe to apply file settings. If it differs, it was changed
196+ // via API and should NOT be overwritten by the file.
196197 envWatchdogIdle := appConfig .WatchDogIdle == startupAppConfig .WatchDogIdle
197198 envWatchdogBusy := appConfig .WatchDogBusy == startupAppConfig .WatchDogBusy
198199 envWatchdogIdleTimeout := appConfig .WatchDogIdleTimeout == startupAppConfig .WatchDogIdleTimeout
@@ -219,6 +220,16 @@ func readRuntimeSettingsJson(startupAppConfig config.ApplicationConfig) fileHand
219220 envForceEvictionWhenBusy := appConfig .ForceEvictionWhenBusy == startupAppConfig .ForceEvictionWhenBusy
220221 envLRUEvictionMaxRetries := appConfig .LRUEvictionMaxRetries == startupAppConfig .LRUEvictionMaxRetries
221222 envLRUEvictionRetryInterval := appConfig .LRUEvictionRetryInterval == startupAppConfig .LRUEvictionRetryInterval
223+ envAgentPoolEnabled := appConfig .AgentPool .Enabled == startupAppConfig .AgentPool .Enabled
224+ envAgentPoolDefaultModel := appConfig .AgentPool .DefaultModel == startupAppConfig .AgentPool .DefaultModel
225+ envAgentPoolEmbeddingModel := appConfig .AgentPool .EmbeddingModel == startupAppConfig .AgentPool .EmbeddingModel
226+ envAgentPoolMaxChunkingSize := appConfig .AgentPool .MaxChunkingSize == startupAppConfig .AgentPool .MaxChunkingSize
227+ envAgentPoolChunkOverlap := appConfig .AgentPool .ChunkOverlap == startupAppConfig .AgentPool .ChunkOverlap
228+ envAgentPoolEnableLogs := appConfig .AgentPool .EnableLogs == startupAppConfig .AgentPool .EnableLogs
229+ envAgentPoolCollectionDBPath := appConfig .AgentPool .CollectionDBPath == startupAppConfig .AgentPool .CollectionDBPath
230+ envAgentPoolVectorEngine := appConfig .AgentPool .VectorEngine == startupAppConfig .AgentPool .VectorEngine
231+ envAgentPoolDatabaseURL := appConfig .AgentPool .DatabaseURL == startupAppConfig .AgentPool .DatabaseURL
232+ envAgentPoolAgentHubURL := appConfig .AgentPool .AgentHubURL == startupAppConfig .AgentPool .AgentHubURL
222233
223234 if len (fileContent ) > 0 {
224235 var settings config.RuntimeSettings
@@ -227,28 +238,28 @@ func readRuntimeSettingsJson(startupAppConfig config.ApplicationConfig) fileHand
227238 return err
228239 }
229240
230- // Apply file settings only if they don't match startup values (i.e., not from env vars )
231- if settings .WatchdogIdleEnabled != nil && ! envWatchdogIdle {
241+ // Apply file settings only if current values match startup values (i.e., not changed via API )
242+ if settings .WatchdogIdleEnabled != nil && envWatchdogIdle {
232243 appConfig .WatchDogIdle = * settings .WatchdogIdleEnabled
233244 if appConfig .WatchDogIdle {
234245 appConfig .WatchDog = true
235246 }
236247 }
237- if settings .WatchdogBusyEnabled != nil && ! envWatchdogBusy {
248+ if settings .WatchdogBusyEnabled != nil && envWatchdogBusy {
238249 appConfig .WatchDogBusy = * settings .WatchdogBusyEnabled
239250 if appConfig .WatchDogBusy {
240251 appConfig .WatchDog = true
241252 }
242253 }
243- if settings .WatchdogIdleTimeout != nil && ! envWatchdogIdleTimeout {
254+ if settings .WatchdogIdleTimeout != nil && envWatchdogIdleTimeout {
244255 dur , err := time .ParseDuration (* settings .WatchdogIdleTimeout )
245256 if err == nil {
246257 appConfig .WatchDogIdleTimeout = dur
247258 } else {
248259 xlog .Warn ("invalid watchdog idle timeout in runtime_settings.json" , "error" , err , "timeout" , * settings .WatchdogIdleTimeout )
249260 }
250261 }
251- if settings .WatchdogBusyTimeout != nil && ! envWatchdogBusyTimeout {
262+ if settings .WatchdogBusyTimeout != nil && envWatchdogBusyTimeout {
252263 dur , err := time .ParseDuration (* settings .WatchdogBusyTimeout )
253264 if err == nil {
254265 appConfig .WatchDogBusyTimeout = dur
@@ -257,11 +268,11 @@ func readRuntimeSettingsJson(startupAppConfig config.ApplicationConfig) fileHand
257268 }
258269 }
259270 // Handle MaxActiveBackends (new) and SingleBackend (deprecated)
260- if settings .MaxActiveBackends != nil && ! envMaxActiveBackends {
271+ if settings .MaxActiveBackends != nil && envMaxActiveBackends {
261272 appConfig .MaxActiveBackends = * settings .MaxActiveBackends
262273 // For backward compatibility, also set SingleBackend if MaxActiveBackends == 1
263274 appConfig .SingleBackend = (* settings .MaxActiveBackends == 1 )
264- } else if settings .SingleBackend != nil && ! envSingleBackend {
275+ } else if settings .SingleBackend != nil && envSingleBackend {
265276 // Legacy: SingleBackend maps to MaxActiveBackends = 1
266277 appConfig .SingleBackend = * settings .SingleBackend
267278 if * settings .SingleBackend {
@@ -270,69 +281,69 @@ func readRuntimeSettingsJson(startupAppConfig config.ApplicationConfig) fileHand
270281 appConfig .MaxActiveBackends = 0
271282 }
272283 }
273- if settings .MemoryReclaimerEnabled != nil && ! envMemoryReclaimerEnabled {
284+ if settings .MemoryReclaimerEnabled != nil && envMemoryReclaimerEnabled {
274285 appConfig .MemoryReclaimerEnabled = * settings .MemoryReclaimerEnabled
275286 if appConfig .MemoryReclaimerEnabled {
276287 appConfig .WatchDog = true // Memory reclaimer requires watchdog
277288 }
278289 }
279- if settings .MemoryReclaimerThreshold != nil && ! envMemoryReclaimerThreshold {
290+ if settings .MemoryReclaimerThreshold != nil && envMemoryReclaimerThreshold {
280291 appConfig .MemoryReclaimerThreshold = * settings .MemoryReclaimerThreshold
281292 }
282- if settings .ForceEvictionWhenBusy != nil && ! envForceEvictionWhenBusy {
293+ if settings .ForceEvictionWhenBusy != nil && envForceEvictionWhenBusy {
283294 appConfig .ForceEvictionWhenBusy = * settings .ForceEvictionWhenBusy
284295 }
285- if settings .LRUEvictionMaxRetries != nil && ! envLRUEvictionMaxRetries {
296+ if settings .LRUEvictionMaxRetries != nil && envLRUEvictionMaxRetries {
286297 appConfig .LRUEvictionMaxRetries = * settings .LRUEvictionMaxRetries
287298 }
288- if settings .LRUEvictionRetryInterval != nil && ! envLRUEvictionRetryInterval {
299+ if settings .LRUEvictionRetryInterval != nil && envLRUEvictionRetryInterval {
289300 dur , err := time .ParseDuration (* settings .LRUEvictionRetryInterval )
290301 if err == nil {
291302 appConfig .LRUEvictionRetryInterval = dur
292303 } else {
293304 xlog .Warn ("invalid LRU eviction retry interval in runtime_settings.json" , "error" , err , "interval" , * settings .LRUEvictionRetryInterval )
294305 }
295306 }
296- if settings .Threads != nil && ! envThreads {
307+ if settings .Threads != nil && envThreads {
297308 appConfig .Threads = * settings .Threads
298309 }
299- if settings .ContextSize != nil && ! envContextSize {
310+ if settings .ContextSize != nil && envContextSize {
300311 appConfig .ContextSize = * settings .ContextSize
301312 }
302- if settings .F16 != nil && ! envF16 {
313+ if settings .F16 != nil && envF16 {
303314 appConfig .F16 = * settings .F16
304315 }
305- if settings .Debug != nil && ! envDebug {
316+ if settings .Debug != nil && envDebug {
306317 appConfig .Debug = * settings .Debug
307318 }
308- if settings .CORS != nil && ! envCORS {
319+ if settings .CORS != nil && envCORS {
309320 appConfig .CORS = * settings .CORS
310321 }
311- if settings .CSRF != nil && ! envCSRF {
322+ if settings .CSRF != nil && envCSRF {
312323 appConfig .DisableCSRF = * settings .CSRF
313324 }
314- if settings .CORSAllowOrigins != nil && ! envCORSAllowOrigins {
325+ if settings .CORSAllowOrigins != nil && envCORSAllowOrigins {
315326 appConfig .CORSAllowOrigins = * settings .CORSAllowOrigins
316327 }
317- if settings .P2PToken != nil && ! envP2PToken {
328+ if settings .P2PToken != nil && envP2PToken {
318329 appConfig .P2PToken = * settings .P2PToken
319330 }
320- if settings .P2PNetworkID != nil && ! envP2PNetworkID {
331+ if settings .P2PNetworkID != nil && envP2PNetworkID {
321332 appConfig .P2PNetworkID = * settings .P2PNetworkID
322333 }
323- if settings .Federated != nil && ! envFederated {
334+ if settings .Federated != nil && envFederated {
324335 appConfig .Federated = * settings .Federated
325336 }
326- if settings .Galleries != nil && ! envGalleries {
337+ if settings .Galleries != nil && envGalleries {
327338 appConfig .Galleries = * settings .Galleries
328339 }
329- if settings .BackendGalleries != nil && ! envBackendGalleries {
340+ if settings .BackendGalleries != nil && envBackendGalleries {
330341 appConfig .BackendGalleries = * settings .BackendGalleries
331342 }
332- if settings .AutoloadGalleries != nil && ! envAutoloadGalleries {
343+ if settings .AutoloadGalleries != nil && envAutoloadGalleries {
333344 appConfig .AutoloadGalleries = * settings .AutoloadGalleries
334345 }
335- if settings .AutoloadBackendGalleries != nil && ! envAutoloadBackendGalleries {
346+ if settings .AutoloadBackendGalleries != nil && envAutoloadBackendGalleries {
336347 appConfig .AutoloadBackendGalleries = * settings .AutoloadBackendGalleries
337348 }
338349 if settings .ApiKeys != nil {
@@ -344,12 +355,42 @@ func readRuntimeSettingsJson(startupAppConfig config.ApplicationConfig) fileHand
344355 // Replace all runtime keys with what's in runtime_settings.json
345356 appConfig .ApiKeys = append (envKeys , runtimeKeys ... )
346357 }
347- if settings .AgentJobRetentionDays != nil && ! envAgentJobRetentionDays {
358+ if settings .AgentJobRetentionDays != nil && envAgentJobRetentionDays {
348359 appConfig .AgentJobRetentionDays = * settings .AgentJobRetentionDays
349360 }
361+ if settings .AgentPoolEnabled != nil && envAgentPoolEnabled {
362+ appConfig .AgentPool .Enabled = * settings .AgentPoolEnabled
363+ }
364+ if settings .AgentPoolDefaultModel != nil && envAgentPoolDefaultModel {
365+ appConfig .AgentPool .DefaultModel = * settings .AgentPoolDefaultModel
366+ }
367+ if settings .AgentPoolEmbeddingModel != nil && envAgentPoolEmbeddingModel {
368+ appConfig .AgentPool .EmbeddingModel = * settings .AgentPoolEmbeddingModel
369+ }
370+ if settings .AgentPoolMaxChunkingSize != nil && envAgentPoolMaxChunkingSize {
371+ appConfig .AgentPool .MaxChunkingSize = * settings .AgentPoolMaxChunkingSize
372+ }
373+ if settings .AgentPoolChunkOverlap != nil && envAgentPoolChunkOverlap {
374+ appConfig .AgentPool .ChunkOverlap = * settings .AgentPoolChunkOverlap
375+ }
376+ if settings .AgentPoolEnableLogs != nil && envAgentPoolEnableLogs {
377+ appConfig .AgentPool .EnableLogs = * settings .AgentPoolEnableLogs
378+ }
379+ if settings .AgentPoolCollectionDBPath != nil && envAgentPoolCollectionDBPath {
380+ appConfig .AgentPool .CollectionDBPath = * settings .AgentPoolCollectionDBPath
381+ }
382+ if settings .AgentPoolVectorEngine != nil && envAgentPoolVectorEngine {
383+ appConfig .AgentPool .VectorEngine = * settings .AgentPoolVectorEngine
384+ }
385+ if settings .AgentPoolDatabaseURL != nil && envAgentPoolDatabaseURL {
386+ appConfig .AgentPool .DatabaseURL = * settings .AgentPoolDatabaseURL
387+ }
388+ if settings .AgentPoolAgentHubURL != nil && envAgentPoolAgentHubURL {
389+ appConfig .AgentPool .AgentHubURL = * settings .AgentPoolAgentHubURL
390+ }
350391
351392 // If watchdog is enabled via file but not via env, ensure WatchDog flag is set
352- if ! envWatchdogIdle && ! envWatchdogBusy {
393+ if envWatchdogIdle && envWatchdogBusy {
353394 if settings .WatchdogEnabled != nil && * settings .WatchdogEnabled {
354395 appConfig .WatchDog = true
355396 }
0 commit comments