Discovery allowed
This commit is contained in:
@@ -689,6 +689,21 @@ def _get_upstream_semaphore(base_url: str) -> asyncio.Semaphore:
|
||||
return _local_upstream_semaphores[key]
|
||||
|
||||
|
||||
_last_discovery: dict[str, float] = {}
|
||||
DISCOVERY_COOLDOWN_SECONDS = 60.0
|
||||
|
||||
|
||||
def _discovery_allowed(agent_name: str) -> bool:
|
||||
"""Rate-limit context discovery to at most once per cooldown period per agent."""
|
||||
key = agent_name or "_default"
|
||||
now = time.time()
|
||||
if now - _last_discovery.get(key, 0.0) < DISCOVERY_COOLDOWN_SECONDS:
|
||||
log.debug("context discover throttled for agent=%s", key)
|
||||
return False
|
||||
_last_discovery[key] = now
|
||||
return True
|
||||
|
||||
|
||||
async def _get_agent_routing_model(pool, agent_name: str) -> ModelConfig | None:
|
||||
"""
|
||||
Look up the agent's configured model from the agent_models table.
|
||||
|
||||
Reference in New Issue
Block a user