fix: update mock multi-agent system to route requests to single calculator agent

- Modified `mock_multi_agent.py` to avoid duplicate responses from multiple calculators
- Integrated logic using `agent.py` and `mcp_integration.py` for proper agent-tool mapping
- Updated output formatting and response control for clearer user experience
pull/819/head
Pavan Kumar 2 days ago committed by ascender1729
parent 3899a22c97
commit 94363755db

@ -42,15 +42,11 @@ class MathAgent:
class MultiAgentMathSystem: class MultiAgentMathSystem:
def __init__(self): def __init__(self):
base_url = "http://0.0.0.0:8000" base_url = "http://0.0.0.0:8000"
self.agents = [ self.calculator = MathAgent("Calculator", base_url)
MathAgent("Calculator-1", base_url),
MathAgent("Calculator-2", base_url)
]
async def process_task(self, task: str): async def process_task(self, task: str):
tasks = [agent.process(task) for agent in self.agents] result = await self.calculator.process(task)
results = await asyncio.gather(*tasks) return [result] # Keep list format for compatibility
return results
def run_interactive(self): def run_interactive(self):
print("\nMulti-Agent Math System") print("\nMulti-Agent Math System")
@ -64,12 +60,12 @@ class MultiAgentMathSystem:
results = asyncio.run(self.process_task(user_input)) results = asyncio.run(self.process_task(user_input))
print("\nResults:") print("\nResult:")
for result in results: result = results[0] # We now only have one result
if "error" in result: if "error" in result:
print(f"\n{result['agent']} encountered an error: {result['error']}") print(f"\nCalculator encountered an error: {result['error']}")
else: else:
print(f"\n{result['agent']} response: {result['response']}") print(f"\nCalculation: {result['response']}")
except Exception as e: except Exception as e:
print(f"System error: {str(e)}") print(f"System error: {str(e)}")

Loading…
Cancel
Save