perf(llm): pass pre-loaded cfg dict to LLM clients, skip redundant file reads#153
Draft
CGFixIT wants to merge 2 commits into
Draft
perf(llm): pass pre-loaded cfg dict to LLM clients, skip redundant file reads#153CGFixIT wants to merge 2 commits into
CGFixIT wants to merge 2 commits into
Conversation
gate.py already holds a fully-parsed cfg dict when it instantiates LocalLLMClient and GrokClient. Both constructors previously opened and parsed config.yaml from disk independently, adding 2 extra file reads on every server start. Add an optional `cfg` parameter to both constructors. When a dict is passed the file read is skipped; when omitted (standalone use / tests) the existing config_path fallback is used unchanged. gate.py updated to pass cfg=cfg at the two call sites. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RgtYPGfWiJf7Tz2AYwdBEE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
gate.pyloads and parsesconfig.yamlonce at startup intocfg. It then instantiatesLocalLLMClient()andGrokClient(), each of which independently opens and parsesconfig.yamlfrom disk again — 2 extra file reads that produce the same data already in memory.Fix
Add an optional
cfg: Optional[dict]parameter to both client constructors:gate.pypasses the already-loaded dict at both call sites:Backward Compatibility
Fully backward compatible —
config_pathfallback is unchanged. Any existing code (tests, standalone scripts) that callsLocalLLMClient()orGrokClient()without acfgargument continues to work exactly as before.Files Changed
llm/client.py— optionalcfgparam on both constructorsgate.py— passcfg=cfgat the two instantiation sitesGenerated by Claude Code