clan: route simple requests to fast crew profile; keep zhos_mvp for complex
This commit is contained in:
@@ -16,6 +16,9 @@ CREWAI_ENABLED = os.getenv("CREWAI_ENABLED", "true").lower() == "true"
|
||||
CREWAI_ORCHESTRATORS_ALWAYS = os.getenv("CREWAI_ORCHESTRATORS_ALWAYS", "true").lower() == "true"
|
||||
HELION_CREWAI_TEAM_LIMIT = int(os.getenv("HELION_CREWAI_TEAM_LIMIT", "3"))
|
||||
CLAN_CREWAI_PROFILE = os.getenv("CLAN_CREWAI_PROFILE", "zhos_mvp")
|
||||
CLAN_CREWAI_PROFILE_FAST = os.getenv("CLAN_CREWAI_PROFILE_FAST", "default")
|
||||
CLAN_CREWAI_PROFILE_COMPLEX = os.getenv("CLAN_CREWAI_PROFILE_COMPLEX", CLAN_CREWAI_PROFILE)
|
||||
CLAN_CREWAI_TEAM_LIMIT_FAST = int(os.getenv("CLAN_CREWAI_TEAM_LIMIT_FAST", "3"))
|
||||
|
||||
CREWAI_AGENTS_PATH = os.getenv("CREWAI_AGENTS_PATH", "/config/crewai_agents.json")
|
||||
FALLBACK_CREWAI_PATH = "/app/config/crewai_agents.json"
|
||||
@@ -128,14 +131,27 @@ async def call_crewai(agent_id, task, context=None, team=None, profile=None):
|
||||
effective_context = context or {}
|
||||
metadata = (effective_context.get("metadata", {}) or {})
|
||||
force_detailed = bool(metadata.get("force_detailed"))
|
||||
requires_complex = bool(metadata.get("requires_complex_reasoning"))
|
||||
# Helion policy: limit CrewAI participants unless user requested detailed mode.
|
||||
if agent_id == "helion" and not force_detailed and HELION_CREWAI_TEAM_LIMIT > 0 and len(team) > HELION_CREWAI_TEAM_LIMIT:
|
||||
team = team[:HELION_CREWAI_TEAM_LIMIT]
|
||||
|
||||
async with httpx.AsyncClient(timeout=600.0) as client:
|
||||
effective_profile = profile or (effective_context.get("metadata", {}) or {}).get("crewai_profile")
|
||||
if not effective_profile and agent_id == "clan" and CLAN_CREWAI_PROFILE:
|
||||
effective_profile = CLAN_CREWAI_PROFILE
|
||||
if not effective_profile and agent_id == "clan":
|
||||
effective_profile = (
|
||||
CLAN_CREWAI_PROFILE_COMPLEX
|
||||
if (force_detailed or requires_complex)
|
||||
else CLAN_CREWAI_PROFILE_FAST
|
||||
)
|
||||
if (
|
||||
agent_id == "clan"
|
||||
and effective_profile == CLAN_CREWAI_PROFILE_FAST
|
||||
and not force_detailed
|
||||
and CLAN_CREWAI_TEAM_LIMIT_FAST > 0
|
||||
and len(team) > CLAN_CREWAI_TEAM_LIMIT_FAST
|
||||
):
|
||||
team = team[:CLAN_CREWAI_TEAM_LIMIT_FAST]
|
||||
|
||||
payload = {
|
||||
"task": task,
|
||||
|
||||
Reference in New Issue
Block a user