Skip to content

Conversation

Copy link

Copilot AI commented Jul 5, 2025

Problem

Changes to LLM and Embedding settings (provider, server address, API key) in advanced setup mode were not immediately applied when configuration was saved. The filter would continue using old cached configuration and ignore fresh user settings, requiring a full restart to pick up changes.

Root Cause

The inlet and outlet methods were only checking configuration persistence (reloading only when problems were detected) rather than force-reloading the latest configuration from the persistent store at the start of each request.

Solution

This PR implements hot-reloading by ensuring configuration is always refreshed from the persistent store at the start of each request:

Key Changes

  1. Force Reload in Inlet/Outlet Methods: Modified both _async_inlet_impl and _async_outlet_impl to call self._reload_configuration_safe(force_reload=True) at the start of each request

  2. Public Reload Method: Added a public reload_config() method that can be called externally to force backend configuration reload:

    def reload_config(self):
        return self._reload_configuration_safe(force_reload=True)
  3. Configuration Save Integrity: Verified that both set_valves() and _save_configuration_safe() properly update both self.valves and self.config["valves"] with proper backup/rollback functionality

Code Changes

Before:

# Only checked persistence, didn't force reload
config_check = await asyncio.wait_for(
    asyncio.to_thread(self._ensure_configuration_persistence),
    timeout=5.0
)

After:

# Felicity says: No more living in the past—your config is now as fresh as your taste in AI assistants! 💅
# Force reload configuration from persistent store to ensure latest settings are applied
reload_success = await asyncio.wait_for(
    asyncio.to_thread(self._reload_configuration_safe, True),  # force_reload=True
    timeout=5.0
)

Testing

  • ✅ All syntax validation passed
  • ✅ Force reload calls present in both inlet and outlet methods
  • ✅ Public reload_config() method exists and works
  • ✅ Configuration save methods update both valve locations
  • ✅ Backup and rollback logic preserved
  • ✅ File compiles without errors

Impact

File Modified: adaptive_memory_v4.0.py
Lines Changed: ~32 insertions, 20 deletions (minimal, surgical changes)

Result

LLM and Embedding settings changes in advanced setup mode will now be immediately applied when configuration is saved. Users no longer need to restart the system to pick up fresh configuration changes.

Fixes the issue where the filter would ignore fresh user config and continue using stale cached settings.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: donbcd <4048018+donbcd@users.noreply.github.com>
Copilot AI changed the title [WIP] [FIX] Hot-reload configuration for LLM and Embedding settings on save Fix: Implement hot-reload configuration for LLM and Embedding settings in advanced setup mode Jul 5, 2025
Copilot AI requested a review from donbcd July 5, 2025 10:25
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