Summary
SmartModelRouter._build_cheap_route() in agent/smart_model_routing.py constructs its runtime dict without the credential_pool key, while both _build_primary_route() branches include it.
Root Cause
In _build_cheap_route() (the cheap/fallback routing path), the return dict's runtime block is missing credential_pool:
# _build_cheap_route() — MISSING credential_pool
return {
"model": route.get("model"),
"runtime": {
"api_key": runtime.get("api_key"),
"base_url": runtime.get("base_url"),
"provider": runtime.get("provider"),
"api_mode": runtime.get("api_mode"),
"command": runtime.get("command"),
"args": list(runtime.get("args") or []),
# credential_pool missing here!
},
...
}
Both _build_primary_route() branches include it:
# _build_primary_route() — present
"credential_pool": primary.get("credential_pool"),
Impact
When the smart router selects the cheap route (e.g. for low-cost tasks), downstream code that reads result["runtime"]["credential_pool"] will receive None or raise a KeyError, causing credential rotation to fail silently or crash.
Fix
Add the missing key to _build_cheap_route()'s runtime dict:
"credential_pool": runtime.get("credential_pool"),
A PR is being submitted with this fix.
Summary
SmartModelRouter._build_cheap_route()inagent/smart_model_routing.pyconstructs itsruntimedict without thecredential_poolkey, while both_build_primary_route()branches include it.Root Cause
In
_build_cheap_route()(the cheap/fallback routing path), the return dict'sruntimeblock is missingcredential_pool:Both
_build_primary_route()branches include it:Impact
When the smart router selects the cheap route (e.g. for low-cost tasks), downstream code that reads
result["runtime"]["credential_pool"]will receiveNoneor raise aKeyError, causing credential rotation to fail silently or crash.Fix
Add the missing key to
_build_cheap_route()'s runtime dict:A PR is being submitted with this fix.