Discovery allowed

This commit is contained in:
2026-04-21 22:22:25 +02:00
parent 3b4245c9d5
commit dfd416a5aa
+15
View File
@@ -689,6 +689,21 @@ def _get_upstream_semaphore(base_url: str) -> asyncio.Semaphore:
return _local_upstream_semaphores[key] 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: async def _get_agent_routing_model(pool, agent_name: str) -> ModelConfig | None:
""" """
Look up the agent's configured model from the agent_models table. Look up the agent's configured model from the agent_models table.