This repository contains two alternative implementations of a mathematical expression evaluator built on the Google Agent Development Kit (ADK) and the Gemini API, adapted and extended from the skills.google code lab GENAI106: Build Multi-Agent Systems with ADK.
It provides a comparative codebase demonstrating the differences between Dynamic Multi-Agent Routing and Structured Workflow Loops (LoopAgent), including deep hierarchical nesting and error boundary validation.
├── adk_multiagent_systems/
│ ├── parent_and_subagents/ # Multi-Agent implementation
│ │ ├── .env # App configuration (Vertex AI, model info)
│ │ └── agent.py # Steering and 4 specialist agents
│ └── workflow_agents/ # Workflow implementation
│ ├── .env # App configuration (Vertex AI, model info)
│ └── agent.py # LoopAgent, state tools, and specialists
│
├── test_agents.py # Self-contained integration test suite
├── print_timeline_multiagent.py # Parse SQLite logs for parent_and_subagents
├── print_timeline_workflow.py # Parse SQLite logs for workflow_agents
└── README.md # This documentation file
- Root Agent:
steering(acts as an orchestrator coordinator). - Specialist Sub-agents:
adder,substracter,multiplier,divider. - Validation Guard:
zero_division_guard(nested sub-agent ofdivider). - Orchestration:
steeringroutes terms dynamically to the correct specialist using ADK'stransfer_to_agenttool based on mathematical precedence. The specialists evaluate their part, and transfer control back tosteering.
- Root Agent:
workflow_steering(coordinator that initializes state and delegates). - Loop Container:
calculator_loop(a structuredLoopAgent). - Specialist Sub-agents:
adder,substracter,multiplier,divider(executing in a fixed sequence). - Validation Guard:
zero_division_guard(nested sub-agent ofdivider). - Orchestration: The specialists execute in a pre-defined sequential loop, modifying the shared session state via the
update_expressiontool. Whichever specialist resolves the expression to a single number prints the final value and exits the loop usingexit_loop.
Ensure you have the virtual environment activated before running any scripts:
source .venv/bin/activateVerify that the .env files in both directories (parent_and_subagents/.env and workflow_agents/.env) contain your correct Vertex AI project, location, and model configuration:
GOOGLE_GENAI_USE_VERTEXAI=TRUE
GOOGLE_CLOUD_PROJECT=your-gcp-project-id
GOOGLE_CLOUD_LOCATION=us-central1
MODEL=gemini-2.5-flashYou can execute either evaluator from the command line using the ADK CLI:
PYTHONPATH=. .venv/bin/adk run adk_multiagent_systems/parent_and_subagents "((12 + 8) * 5) - (10 / 2) + (4 * 6) - (50 / 5)"PYTHONPATH=. .venv/bin/adk run adk_multiagent_systems/workflow_agents "((12 + 8) * 5) - (10 / 2) + (4 * 6) - (50 / 5)"To verify the evaluation correctness, mathematical operator precedence, and the nested zero_division_guard validation boundaries for both applications, run the integration test suite:
PYTHONPATH=. .venv/bin/python test_agents.pyThis runs four test cases:
- Complex expression evaluation (
109) on the Multi-Agent app. - Complex expression evaluation (
109) on the Workflow-based app. - Division by zero validation error on the Multi-Agent app.
- Division by zero validation error on the Workflow-based app.
To see a unified, step-by-step history of all internal agent transitions, tool calls, and intermediate simplified expressions, run the log parsers:
PYTHONPATH=. .venv/bin/python print_timeline_multiagent.pyPYTHONPATH=. .venv/bin/python print_timeline_workflow.py