Yash030 commited on
Commit
43f9fdf
·
1 Parent(s): fc92f80

batch_tool name mismatch

Browse files
Files changed (1) hide show
  1. src/agents.py +38 -7
src/agents.py CHANGED
@@ -14,7 +14,7 @@ if sys.platform == 'win32':
14
  from google.adk import Agent
15
  from google.adk.agents import SequentialAgent, ParallelAgent
16
  # from google.adk.events import Event, EventActions # Unused after removing loop
17
- from google.adk.tools import google_search, load_memory
18
  from .config import get_model, get_gemini_model
19
  from .tools import batch_tool, adaptive_tool, save_context_tool, retrieve_context_tool, submit_queries_tool, validate_tool, retrieve_memory_tool
20
  from .utils import logger
@@ -184,7 +184,7 @@ class WebCrawlAgent(Agent):
184
 
185
  # 1. Try Batch Crawl
186
  logger.info(f"🕷️ Attempting Batch Crawl for {len(urls)} URLs")
187
- batch_result = await batch_crawl_tool.func(urls)
188
 
189
  # 2. Analyze Result (Simple Heuristic)
190
  # Check if we got valid content
@@ -307,8 +307,8 @@ def create_memory_retrieval_agent():
307
 
308
  def create_root_agent():
309
  """
310
- Creates the root agent (Resolution Pipeline).
311
- Directly returns the sequential pipeline, bypassing Triage/Orchestrator.
312
  """
313
  # 1. Memory Retrieval
314
  memory_agent = create_memory_retrieval_agent()
@@ -340,7 +340,6 @@ def create_root_agent():
340
  code_surgeon = create_code_surgeon_agent()
341
 
342
  # Create the sequential pipeline (The "Heavy" Lifters)
343
- # Flow: Memory -> Research (Query+Search) -> Crawl -> Surgeon
344
  resolution_pipeline = SequentialAgent(
345
  name="Resolution_Pipeline",
346
  sub_agents=[memory_agent, web_research_team, web_crawl, code_surgeon],
@@ -348,8 +347,40 @@ def create_root_agent():
348
  after_agent_callback=auto_save_to_memory # Auto-save history
349
  )
350
 
351
- logger.info("✅ Root agent created (Direct Resolution Pipeline)")
352
- return resolution_pipeline
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
353
 
354
 
355
  # ===== MODULE-LEVEL INITIALIZATION FOR ADK WEB =====
 
14
  from google.adk import Agent
15
  from google.adk.agents import SequentialAgent, ParallelAgent
16
  # from google.adk.events import Event, EventActions # Unused after removing loop
17
+ from google.adk.tools import google_search, load_memory, FunctionTool
18
  from .config import get_model, get_gemini_model
19
  from .tools import batch_tool, adaptive_tool, save_context_tool, retrieve_context_tool, submit_queries_tool, validate_tool, retrieve_memory_tool
20
  from .utils import logger
 
184
 
185
  # 1. Try Batch Crawl
186
  logger.info(f"🕷️ Attempting Batch Crawl for {len(urls)} URLs")
187
+ batch_result = await batch_tool.func(urls)
188
 
189
  # 2. Analyze Result (Simple Heuristic)
190
  # Check if we got valid content
 
307
 
308
  def create_root_agent():
309
  """
310
+ Creates the root agent (Manager Agent).
311
+ Uses the Resolution Pipeline as a TOOL to handle technical requests.
312
  """
313
  # 1. Memory Retrieval
314
  memory_agent = create_memory_retrieval_agent()
 
340
  code_surgeon = create_code_surgeon_agent()
341
 
342
  # Create the sequential pipeline (The "Heavy" Lifters)
 
343
  resolution_pipeline = SequentialAgent(
344
  name="Resolution_Pipeline",
345
  sub_agents=[memory_agent, web_research_team, web_crawl, code_surgeon],
 
347
  after_agent_callback=auto_save_to_memory # Auto-save history
348
  )
349
 
350
+ # --- NEW: Wrap Pipeline as a Tool ---
351
+ async def run_resolution_job(problem_description: str) -> str:
352
+ """
353
+ Triggers the full dependency resolution pipeline.
354
+ Use this tool when the user describes a technical issue, error, or package conflict.
355
+ """
356
+ logger.info(f"🔧 Manager triggering Resolution Pipeline for: {problem_description}")
357
+ return await resolution_pipeline.run(problem_description)
358
+
359
+ resolution_tool = FunctionTool(run_resolution_job)
360
+
361
+ # --- NEW: Manager Agent (The Doctor) ---
362
+ manager_agent = Agent(
363
+ name="Package_Doctor_Manager",
364
+ model=get_gemini_model(), # Smart model for decision making
365
+ tools=[resolution_tool],
366
+ description="The main interface for the Package Doctor.",
367
+ instruction="""
368
+ You are the **Package Doctor**, an expert AI assistant for Python dependency issues.
369
+
370
+ YOUR BEHAVIOR:
371
+ 1. **Small Talk**: If the user says "Hello", "Hi", or asks general questions, reply politely and briefly. DO NOT call any tools.
372
+ - Example: "Hello! I'm ready to help you fix your dependency conflicts. Please share your error log or requirements file."
373
+
374
+ 2. **Technical Issues**: If the user describes a problem, provides an error log, or mentions package conflicts, **IMMEDIATELY** call the `run_resolution_job` tool.
375
+ - Pass the user's full description to the tool.
376
+ - Do not try to solve it yourself without the tool.
377
+
378
+ 3. **After Tool Execution**: The tool will return the solution. Present it clearly to the user.
379
+ """
380
+ )
381
+
382
+ logger.info("✅ Root agent created (Manager with Pipeline Tool)")
383
+ return manager_agent
384
 
385
 
386
  # ===== MODULE-LEVEL INITIALIZATION FOR ADK WEB =====