@@ -40,24 +40,86 @@ def __init__(self):
4040 )
4141
4242 def get_required_context (self ) -> list [str ]:
43- """Required context for analysis"""
43+ """Required context for analysis (optional in demo mode) """
4444 return [
4545 "agent_definitions" , # Agent classes/configs
4646 "orchestration_code" , # Code that coordinates agents
4747 "project_path" , # Project root
4848 ]
4949
50+ def _parse_agents_from_text (self , text : str ) -> list [dict ]:
51+ """Parse agent definitions from natural language text input."""
52+ import re
53+
54+ agents = []
55+
56+ # Look for patterns like "5 agents", "agents: X, Y, Z", numbered lists
57+ # Pattern 1: "N agents" or "N specialized agents"
58+ count_match = re .search (r"(\d+)\s+(?:specialized\s+)?agents?" , text .lower ())
59+ if count_match :
60+ count = int (count_match .group (1 ))
61+ # Try to extract agent names from the text
62+ # Look for colon-separated list: "agents: ingestion, validation, ..."
63+ list_match = re .search (r":\s*([^.]+)" , text )
64+ if list_match :
65+ names = [n .strip () for n in list_match .group (1 ).split ("," )]
66+ for name in names [:count ]:
67+ agents .append ({"name" : name , "type" : "specialized" })
68+ else :
69+ # Generate generic agent names
70+ for i in range (count ):
71+ agents .append ({"name" : f"Agent_{ i + 1 } " , "type" : "specialized" })
72+
73+ # Pattern 2: Look for specific agent-like words
74+ agent_keywords = [
75+ "ingestion" ,
76+ "validation" ,
77+ "transformation" ,
78+ "analysis" ,
79+ "reporting" ,
80+ "extraction" ,
81+ "processing" ,
82+ "routing" ,
83+ "aggregation" ,
84+ "monitoring" ,
85+ "scheduler" ,
86+ "executor" ,
87+ "coordinator" ,
88+ "supervisor" ,
89+ "worker" ,
90+ ]
91+ for kw in agent_keywords :
92+ if kw in text .lower () and not any (a ["name" ].lower () == kw for a in agents ):
93+ agents .append ({"name" : kw .title (), "type" : "specialized" })
94+
95+ # Ensure at least 1 agent for demo
96+ if not agents :
97+ agents = [{"name" : "DefaultAgent" , "type" : "generic" }]
98+
99+ return agents
100+
50101 async def analyze (self , context : dict [str , Any ]) -> dict [str , Any ]:
51102 """
52103 Analyze agent orchestration patterns and predict coordination issues.
53104
54105 In our experience: Multi-agent complexity sneaks up fast.
55106 By agent #7-10, you need formal orchestration or face refactoring.
107+
108+ Supports two modes:
109+ - Structured: Pass agent_definitions, orchestration_code, project_path
110+ - Demo/Text: Pass user_input with natural language description
56111 """
57- self .validate_context (context )
112+ # Support text input mode (from web demo) or structured mode
113+ user_input = context .get ("user_input" , "" )
58114
59- agents = context ["agent_definitions" ]
60- orchestration = context ["orchestration_code" ]
115+ if "agent_definitions" not in context :
116+ # Parse agents from text input for demo mode
117+ agents = self ._parse_agents_from_text (user_input )
118+ orchestration = [] # No file analysis in demo mode
119+ else :
120+ self .validate_context (context )
121+ agents = context ["agent_definitions" ]
122+ orchestration = context ["orchestration_code" ]
61123
62124 # Current issues
63125 issues = await self ._analyze_orchestration_patterns (agents , orchestration )
0 commit comments