helion: deepseek-first, on-demand CrewAI, local subagent profiles, concise post-synthesis

This commit is contained in:
Apple
2026-02-18 09:21:47 -08:00
parent 343bdc2d11
commit 635f2d7e37
6 changed files with 117 additions and 80 deletions

View File

@@ -61,7 +61,7 @@ helion:
synthesis:
role_context: HELION Orchestrator
system_prompt_ref: roles/helion/orchestrator_synthesis.md
llm_profile: reasoning
llm_profile: science
team:
- id: energy_researcher
role_context: Energy Researcher
@@ -70,7 +70,7 @@ helion:
- id: systems_modeler
role_context: Systems Modeler
system_prompt_ref: roles/helion/systems_modeler.md
llm_profile: reasoning
llm_profile: science
- id: policy_analyst
role_context: Policy Analyst
system_prompt_ref: roles/helion/policy_analyst.md
@@ -78,7 +78,7 @@ helion:
- id: risk_assessor
role_context: Risk Assessor
system_prompt_ref: roles/helion/risk_assessor.md
llm_profile: reasoning
llm_profile: science
- id: communicator
role_context: Communicator
system_prompt_ref: roles/helion/communicator.md
@@ -92,12 +92,12 @@ helion:
synthesis:
role_context: Executive Synthesis (CEO-mode)
system_prompt_ref: roles/helion/HELION_CORE/orchestrator_synthesis.md
llm_profile: reasoning
llm_profile: science
team:
- id: orchestrator_front_desk_router
role_context: Orchestrator (Front Desk / Router)
system_prompt_ref: roles/helion/HELION_CORE/orchestrator_front_desk_router.md
llm_profile: reasoning
llm_profile: science
- id: knowledge_curator_rag_librarian
role_context: Knowledge Curator (L1L3 RAG Librarian)
system_prompt_ref: roles/helion/HELION_CORE/knowledge_curator_rag_librarian.md
@@ -105,15 +105,15 @@ helion:
- id: safety_anti_hallucination_gate
role_context: Safety & Anti-Hallucination Gate
system_prompt_ref: roles/helion/HELION_CORE/safety_anti_hallucination_gate.md
llm_profile: reasoning
llm_profile: science
- id: legal_compliance_gdpr_mica_aml_kyc
role_context: Legal & Compliance (GDPR/MiCA/AML/KYC)
system_prompt_ref: roles/helion/HELION_CORE/legal_compliance_gdpr_mica_aml_kyc.md
llm_profile: reasoning
llm_profile: science
- id: security_anti_fraud_anti_fake
role_context: Security & Anti-Fraud / Anti-Fake
system_prompt_ref: roles/helion/HELION_CORE/security_anti_fraud_anti_fake.md
llm_profile: reasoning
llm_profile: science
- id: energy_systems_engineer
role_context: Energy Systems Engineer (GGU/BioMiner/SES)
system_prompt_ref: roles/helion/HELION_CORE/energy_systems_engineer.md
@@ -121,7 +121,7 @@ helion:
- id: finance_roi_modeler
role_context: Finance & ROI Modeler
system_prompt_ref: roles/helion/HELION_CORE/finance_roi_modeler.md
llm_profile: reasoning
llm_profile: science
- id: dao_guide_governance_onboarding
role_context: DAO Guide (Governance & Onboarding)
system_prompt_ref: roles/helion/HELION_CORE/dao_guide_governance_onboarding.md
@@ -129,7 +129,7 @@ helion:
- id: tokenization_rwa_nft_architect
role_context: Tokenization & RWA/NFT Architect
system_prompt_ref: roles/helion/HELION_CORE/tokenization_rwa_nft_architect.md
llm_profile: reasoning
llm_profile: science
- id: growth_soft_selling_cx
role_context: Growth & Soft-Selling CX
system_prompt_ref: roles/helion/HELION_CORE/growth_soft_selling_cx.md

View File

@@ -14,6 +14,7 @@ logger = logging.getLogger(__name__)
CREWAI_URL = os.getenv("CREWAI_URL", "http://dagi-staging-crewai-service:9010")
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"))
CREWAI_AGENTS_PATH = os.getenv("CREWAI_AGENTS_PATH", "/config/crewai_agents.json")
FALLBACK_CREWAI_PATH = "/app/config/crewai_agents.json"
@@ -90,6 +91,19 @@ def should_use_crewai(agent_id, prompt, agent_config, metadata=None, force_crewa
if not team:
return False, "agent_has_no_team"
metadata = metadata or {}
force_detailed = bool(metadata.get("force_detailed"))
requires_complex = bool(metadata.get("requires_complex_reasoning"))
# Helion policy: DeepSeek direct path by default; CrewAI only on-demand.
# This keeps first-touch replies fast and concise.
if agent_id == "helion":
prompt_lower = prompt.lower()
has_complexity = any(kw in prompt_lower for kw in COMPLEXITY_KEYWORDS)
if force_detailed or requires_complex or has_complexity:
return True, "helion_complex_or_detailed"
return False, "helion_direct_deepseek_first"
# Architecture mode: top-level orchestrators go through CrewAI API by default.
if CREWAI_ORCHESTRATORS_ALWAYS:
return True, "orchestrator_default_crewai"
@@ -111,9 +125,15 @@ async def call_crewai(agent_id, task, context=None, team=None, profile=None):
if not team:
crewai_info = get_agent_crewai_info(agent_id)
team = crewai_info.get("team", [])
effective_context = context or {}
metadata = (effective_context.get("metadata", {}) or {})
force_detailed = bool(metadata.get("force_detailed"))
# 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_context = context or {}
effective_profile = profile or (effective_context.get("metadata", {}) or {}).get("crewai_profile")
if not effective_profile and agent_id == "clan":
effective_profile = "zhos_mvp"

View File

@@ -1412,6 +1412,17 @@ async def agent_infer(agent_id: str, request: InferRequest):
if isinstance(row, dict):
logger.info(json.dumps(row, ensure_ascii=False))
logger.info(f"✅ CrewAI success for {agent_id}: {latency:.2f}s")
final_response_text = crew_result["result"]
# Helion: keep first-touch answers short by default, even after CrewAI.
if (
agent_id == "helion"
and isinstance(final_response_text, str)
and effective_metadata.get("force_concise")
and not effective_metadata.get("force_detailed")
):
parts = re.split(r"(?<=[.!?])\s+", final_response_text.strip())
if len(parts) > 3:
final_response_text = " ".join(parts[:3]).strip()
# Store interaction in memory
if MEMORY_RETRIEVAL_AVAILABLE and memory_retrieval and chat_id and user_id:
@@ -1423,13 +1434,13 @@ async def agent_infer(agent_id: str, request: InferRequest):
agent_id=request_agent_id,
username=username,
user_message=request.prompt,
assistant_response=crew_result["result"]
assistant_response=final_response_text
)
except Exception as e:
logger.warning(f"⚠️ Memory storage failed: {e}")
return InferResponse(
response=crew_result["result"],
response=final_response_text,
model="crewai-" + agent_id,
backend="crewai",
tokens_used=0