fix(startup): auto-initialize tool servers from TOOL_SERVER_CONNECTIONS env var#20914
fix(startup): auto-initialize tool servers from TOOL_SERVER_CONNECTIONS env var#20914SpootyMcSpoot wants to merge 13 commits intoopen-webui:devfrom
Conversation
chore: format
* refac * fix: python pip install dep issue * Merge pull request open-webui#20085 from joaoback/patch-19 Update translation.json (pt-BR) * fix/refac: stt default content type * fix/refac: temp chat image handling * fix/refac: image action button * chore: bump --------- Co-authored-by: joaoback <[email protected]>
…NS env var - Add set_tool_servers call during application startup when TOOL_SERVER_CONNECTIONS is configured via environment variable - This ensures tool servers are available immediately without requiring manual save in Admin Panel > Settings > External Tools Fixes open-webui#18140
🚫 STOP@SpootyMcSpoot, you are trying to merge to the This repository does not allow direct merges to the 🚫 STOP: MISSING CLA@SpootyMcSpoot, your PR description is missing the Contributor License Agreement confirmation. 👋 Welcome and Thank You for Contributing!We appreciate you taking the time to submit a pull request to Open WebUI!
|
|
I've updated the PR, docs and addressed requirements. |
|
I hope it will be integrated since we cannot use tools due to this missing feature as we are using kubernetes |
|
Addressed with f20cc6d! |
Pull Request Checklist
Before submitting, make sure you've checked the following:
devbranch.Changelog Entry
Description
Fix the issue where
TOOL_SERVER_CONNECTIONSenvironment variable is set but tool servers are not actually initialized until the user manually visits the Admin Panel and clicks Save.Problem:
TOOL_SERVER_CONNECTIONSis aPersistentConfigthat only pre-populates the Admin Panel settings. The tools don't become available untilset_tool_servers()is called, which currently only happens when a user manually saves the config.Solution: Call
set_tool_servers()during application startup (in thelifespan()function) whenTOOL_SERVER_CONNECTIONShas entries. This makes tools available immediately without requiring manual intervention.Added
lifespan()function to callset_tool_servers()whenTOOL_SERVER_CONNECTIONSis configuredset_tool_serversfromopen_webui.utils.toolsChanged
Deprecated
Removed
Fixed
TOOL_SERVER_CONNECTIONSenvironment variable now initialize automatically on startup without requiring manual Admin Panel save (Fixes issue: tools does not appear on chat Window when configure with TOOL_SERVER_CONNECTIONS env #18140)Security
Breaking Changes
Additional Information
Use Case: Users deploying Open-WebUI in Kubernetes/containerized environments want to pre-configure tool servers via environment variables for GitOps/IaC workflows. Currently this requires:
TOOL_SERVER_CONNECTIONSenv varWith this fix, steps 3-6 are eliminated - tools work immediately on startup.
Code Pattern: The implementation follows the exact same pattern used for
ENABLE_BASE_MODELS_CACHEinitialization at lines 628-647 in main.py, using a mock Request object.Comprehensive Testing Documentation
Unit Tests (10/10 Passed)
Created standalone unit test suite (
test_tool_server_startup_standalone.py) covering:initialization_called_when_connections_existset_tool_servers()is called when TOOL_SERVER_CONNECTIONS has entriesinitialization_skipped_when_no_connectionsset_tool_servers()is NOT called when emptyerror_handling_on_initialization_failuremultiple_tool_servers_counttool_servers_populated_in_app_stateopenapi_server_config_formatmcp_server_config_formatauthenticated_server_config_formatlogging_message_formatempty_list_vs_none_handlingIntegration Testing in Kubernetes
Environment:
Test Configuration:
Test Results:
Startup Initialization Test
Health Check Test
curl http://localhost:8080/health{"status":true}{"status":true}Pod Stability Test
open-webui-xxx 1/1 Running 0 12mRegression Test - Manual Save
Empty Configuration Test
Error Handling Test
ERROR | Failed to initialize tool servers: ..., app continuedCode Review Checklist
Screenshots or Videos
Startup logs showing auto-initialization:
Health endpoint confirms service running:
Pod status (stable, no restarts):
Unit test results:
Testing Confirmation
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.