refactor(hermes_cli): route_identity/provider_catalog — *args async wrapper, url-var predicate, compact docs
This commit is contained in:
@@ -52,10 +52,8 @@ def should_clear_context_pin(
|
||||
configured_provider: Any, active_provider: Any,
|
||||
) -> bool:
|
||||
"""True when a configured ``model.context_length`` pin no longer matches its runtime route.
|
||||
|
||||
Fail-closed: any error during route comparison returns ``True`` (drop the pin) so a stale window
|
||||
never silently inflates the compression threshold.
|
||||
"""
|
||||
never silently inflates the compression threshold."""
|
||||
configured_model = str(configured_model or "").strip()
|
||||
if configured_model and configured_model != str(active_model or "").strip():
|
||||
return True
|
||||
@@ -67,19 +65,10 @@ def should_clear_context_pin(
|
||||
return True
|
||||
|
||||
|
||||
async def should_clear_context_pin_async(
|
||||
configured_model: Any, active_model: Any, configured_base_url: Any, active_base_url: Any,
|
||||
configured_provider: Any, active_provider: Any,
|
||||
) -> bool:
|
||||
"""Async wrapper for ``should_clear_context_pin``.
|
||||
|
||||
Offloads the route comparison to a worker thread so async gateway handlers never run it on the
|
||||
event loop — the resolution chain is cache-only (``allow_network=False``) but can still do cold-
|
||||
start disk I/O. Shares all logic with the sync version — no code duplication.
|
||||
"""
|
||||
async def should_clear_context_pin_async(*args: Any) -> bool:
|
||||
"""``should_clear_context_pin`` on a worker thread so async gateway handlers never run it on the
|
||||
event loop — the resolution chain is cache-only (``allow_network=False``) but can still do
|
||||
cold-start disk I/O."""
|
||||
import asyncio
|
||||
|
||||
return await asyncio.to_thread(
|
||||
should_clear_context_pin, configured_model, active_model, configured_base_url, active_base_url,
|
||||
configured_provider, active_provider,
|
||||
)
|
||||
return await asyncio.to_thread(should_clear_context_pin, *args)
|
||||
|
||||
Reference in New Issue
Block a user