Skip to content

fix: correct runtime_settings.json loading and add Agent Pool settings#9223

Open
AlekseyMoyseyuk wants to merge 1 commit intomudler:masterfrom
AlekseyMoyseyuk:fix/runtime-settings-agent-pool-loading
Open

fix: correct runtime_settings.json loading and add Agent Pool settings#9223
AlekseyMoyseyuk wants to merge 1 commit intomudler:masterfrom
AlekseyMoyseyuk:fix/runtime-settings-agent-pool-loading

Conversation

@AlekseyMoyseyuk
Copy link
Copy Markdown

Summary

This PR fixes a critical bug where runtime_settings.json file-based settings were not being applied correctly when the file was created or modified after application startup. It also adds missing Agent Pool configuration fields to the runtime settings system.

Bug Description

The readRuntimeSettingsJson() function in config_file_watcher.go had inverted logic: it used !envXxx conditions, which meant file settings were only applied when values had already been changed (via API), rather than when they had not been changed. This caused:

  1. Agent Pool settings ignored: agent_pool_embedding_model, agent_pool_default_model, and other Agent Pool fields from runtime_settings.json were completely ignored at startup and during file watching
  2. File created after startup ignored: If runtime_settings.json didn't exist at startup but was created later, settings were never applied
  3. Inconsistent behavior: startup.go used correct logic (== startupConfig) while config_file_watcher.go used inverted logic (!envXxx)

Changes

Bug Fixes

  • core/application/config_file_watcher.go: Fix !envXxxenvXxx in all 37 conditions, so file settings are applied when values match startup values (not changed via API)
  • core/application/startup.go: Unify env var precedence logic to use startupConfig comparison consistently

New Features

  • Added 3 missing Agent Pool fields to RuntimeSettings:
    • agent_pool_vector_engine — Vector engine type (e.g., chromem, postgres)
    • agent_pool_database_url — Database URL for PostgreSQL vector store
    • agent_pool_agent_hub_url — Custom Agent Hub URL
  • Updated ToRuntimeSettings() and ApplyRuntimeSettings() in application_config.go
  • Added corresponding UI fields in React Settings page

Files Changed

File Changes
core/application/config_file_watcher.go Fix inverted logic + add 10 Agent Pool fields
core/application/startup.go Add 10 Agent Pool fields + unify comparison logic
core/config/runtime_settings.go Add 3 new fields to struct
core/config/application_config.go Update ToRuntimeSettings and ApplyRuntimeSettings
core/http/react-ui/src/pages/Settings.jsx Add 3 UI input fields

Testing

  • All 22 RuntimeSettings tests pass (go test ./core/config/...)
  • Build verified: go build ./core/... succeeds
  • Cross-compiled and tested on Debian (linux/amd64)

Behavior After Fix

Scenario Before After
File exists at startup ✅ Applied ✅ Applied
File created after startup ❌ Ignored ✅ Applied
File modified (no API changes) ❌ Ignored ✅ Applied
Value changed via API, then file modified ❌ Overwritten ✅ Preserved (API takes priority)

How to Test

  1. Start LocalAI without runtime_settings.json
  2. Create the file with custom Agent Pool settings:
    {
      "agent_pool_embedding_model": "custom-embedding-model",
      "agent_pool_vector_engine": "postgres",
      "agent_pool_database_url": "postgres://user:pass@localhost:5432/db"
    }
  3. Verify settings are applied without restart (file watcher) or on next startup
  4. Change settings via API (POST /api/settings), then verify file changes don't override API values

Signed-off-by: Aleksey Moyseyuk <moyseuk@mail.ru>
@AlekseyMoyseyuk AlekseyMoyseyuk force-pushed the fix/runtime-settings-agent-pool-loading branch from 628ea61 to 9504343 Compare April 4, 2026 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant