add: resolve agent for user, check agent health
This commit is contained in:
parent
b74277a189
commit
e50bb8fae5
2 changed files with 25 additions and 0 deletions
|
|
@ -7,6 +7,11 @@ from typing import Literal
|
|||
|
||||
import yaml
|
||||
|
||||
import structlog
|
||||
|
||||
|
||||
|
||||
logger = structlog.get_logger()
|
||||
|
||||
class AgentRegistryError(ValueError):
|
||||
pass
|
||||
|
|
@ -134,6 +139,17 @@ def load_agent_registry(path: str | Path) -> AgentRegistry:
|
|||
return AgentRegistry(agents=agents, user_agents=user_agents_map)
|
||||
|
||||
|
||||
def resolve_agent_for_user(self, max_user_id: str) -> AgentAssignment:
|
||||
agent_id = self.get_agent_id_for_user(max_user_id)
|
||||
if agent_id is not None:
|
||||
return AgentAssignment(agent_id=agent_id, source="configured")
|
||||
if self.agents:
|
||||
# Логируем использование default агента
|
||||
logger.warning("using_default_agent_for_user", user_id=max_user_id, agent_id=self.agents[0].agent_id)
|
||||
return AgentAssignment(agent_id=self.agents[0].agent_id, source="default")
|
||||
return AgentAssignment(agent_id=None, source="none")
|
||||
|
||||
|
||||
def load_from_env() -> AgentRegistry:
|
||||
import os
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue