Skip to content

fix(tools): prefer load_config() over stale CLI_CONFIG in delegate _load_config()#18978

Closed
shellybotmoyer wants to merge 1 commit into
NousResearch:mainfrom
shellybotmoyer:fix/delegate-config-stale-cache
Closed

fix(tools): prefer load_config() over stale CLI_CONFIG in delegate _load_config()#18978
shellybotmoyer wants to merge 1 commit into
NousResearch:mainfrom
shellybotmoyer:fix/delegate-config-stale-cache

Conversation

@shellybotmoyer

Copy link
Copy Markdown
Contributor

Fix

Reverses the priority in _load_config() so that load_config() (which has mtime-based cache invalidation) is checked before the in-memory CLI_CONFIG dict.

Problem

hermes config set delegation.model X writes to disk and reports success, but _load_config() in delegate_tool.py checks the in-memory CLI_CONFIG dict first. Since CLI_CONFIG was loaded once at process startup and never invalidated, the stale cached value wins — the new disk config is never read until the process restarts.

This affects CLI, gateway, and cron — any long-running process that calls delegate_task() after a config change via hermes config set.

Root Cause

_load_config() prioritized CLI_CONFIG (stale in-memory dict) over load_config() (mtime-cached disk reads with automatic invalidation). The load_config() function in hermes_cli/config.py already handles cache invalidation correctly by checking (mtime_ns, size) on every call — it just was never reached because CLI_CONFIG was checked first.

Fix Details

  • Try hermes_cli.config.load_config() first (mtime-aware, always fresh)
  • Fall back to cli.CLI_CONFIG only if load_config() fails
  • Added if cfg: guard to the CLI_CONFIG path for consistency

Testing

  1. Start a gateway session with delegation.model: google/gemini-2.5-flash
  2. From another shell: hermes config set delegation.model google/gemini-3-flash-preview
  3. Call delegate_task(...) from the original session
  4. Before fix: subagent uses gemini-2.5-flash (stale cache)
  5. After fix: subagent uses gemini-3-flash-preview (fresh from disk)

Fixes #18946

…oad_config()

Fixes NousResearch#18946: hermes config set delegation.* silently has no effect on running process because _load_config() checks CLI_CONFIG first (stale in-memory dict) before load_config() (mtime-cached disk reads). Reverse priority so disk config with mtime invalidation wins.
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/tools Tool registry, model_tools, toolsets tool/delegate Subagent delegation labels May 2, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #18967 — same root cause (stale CLI_CONFIG priority in delegate_tool._load_config()), same fix (invert to disk-first).

1 similar comment
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #18967 — same root cause (stale CLI_CONFIG priority in delegate_tool._load_config()), same fix (invert to disk-first).

@shellybotmoyer

Copy link
Copy Markdown
Contributor Author

Closing in favor of clean rebase. See #19007 (supercedes this).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tools Tool registry, model_tools, toolsets P2 Medium — degraded but workaround exists tool/delegate Subagent delegation type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: hermes config set delegation.* silently has no effect on running process (CLI_CONFIG cache stale)

2 participants