hermes - 💡(How to fix) Fix [Performance] /model picker takes ~17s due to load_config() called 69 times [3 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

list_authenticated_providers() in model_switch.py triggers load_config() 69 times via credential_pool._load_config_safe(). Each call parses the full YAML config and performs deepcopy 81,951 times.

Additionally:

  • credential_pool.load_pool() called 65 times (0.585s cumulative)
  • shutil.which() called 64 times for copilot gh CLI detection (0.251s cumulative)
  • posix.stat x4486 calls (0.298s cumulative)

The 69 load_config calls come from credential_pool._seed_from_singletons()CredentialPool.__init__()get_pool_strategy()_load_config_safe().

Root Cause

list_authenticated_providers() in model_switch.py triggers load_config() 69 times via credential_pool._load_config_safe(). Each call parses the full YAML config and performs deepcopy 81,951 times.

Additionally:

  • credential_pool.load_pool() called 65 times (0.585s cumulative)
  • shutil.which() called 64 times for copilot gh CLI detection (0.251s cumulative)
  • posix.stat x4486 calls (0.298s cumulative)

The 69 load_config calls come from credential_pool._seed_from_singletons()CredentialPool.__init__()get_pool_strategy()_load_config_safe().

Fix Action

Fixed

Code Example

load_config x69:        0.388s  (yaml.safe_load x7, deepcopy x81939)
load_pool x65:          0.585s
shutil.which x64:       0.251s
posix.stat x4486:       0.298s
RAW_BUFFERClick to expand / collapse

Description

list_authenticated_providers() in model_switch.py triggers load_config() 69 times via credential_pool._load_config_safe(). Each call parses the full YAML config and performs deepcopy 81,951 times.

Additionally:

  • credential_pool.load_pool() called 65 times (0.585s cumulative)
  • shutil.which() called 64 times for copilot gh CLI detection (0.251s cumulative)
  • posix.stat x4486 calls (0.298s cumulative)

The 69 load_config calls come from credential_pool._seed_from_singletons()CredentialPool.__init__()get_pool_strategy()_load_config_safe().

Profiling Data (cProfile, cumulative)

load_config x69:        0.388s  (yaml.safe_load x7, deepcopy x81939)
load_pool x65:          0.585s
shutil.which x64:       0.251s
posix.stat x4486:       0.298s

Total: ~17s for a single /model invocation.

Suggested Fix

Cache load_config() result for the lifetime of the process, or at least within a single list_authenticated_providers() call. The config file does not change during a single picker invocation.

Impact

/model picker would drop from ~17s to <1s.

Version

v0.14.0 (2026.5.16)

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING