Execution Plans: Static vs. Dynamic Task Management

Execution Plans: Static vs. Dynamic Task Management

Coordinate complex agent activities through robust execution plans. Learn to balance the predictability of static workflows with the flexibility of dynamic, branching agentic behavior using Gemini ADK.

Execution Plans: Static vs. Dynamic Task Management

In the previous lesson, we learned how an agent thinks (the patterns of reasoning). In this lesson, we will learn how to turn those thoughts into a structured Execution Plan.

Building a production-ready agent requires a delicate balance. You want the agent to be Predictable (so it doesn't do something crazy) but also Flexible (so it can respond to unexpected data). We achieve this through the design of Static and Dynamic execution plans.


1. What is an Execution Plan?

An Execution Plan is the "Map" of the agent's journey toward a goal. It defines:

  • The Nodes: The individual tasks or tools to be called.
  • The Edges: The dependencies between tasks (e.g., "Don't do G until F is finished").
  • The Logic: The decision points (e.g., "If the file is too big, summarize it; otherwise, read the whole thing").

2. Static Planning: The Reliable Scaffold

In a Static Execution Plan, the developer defines the steps in advance. The agent follows a rigid "Railroad" path.

Characteristics:

  • Predictability: You know exactly which tools will be called and in what order.
  • Reliability: Easier to test and debug because the "flow" never changes.
  • Limitations: Brittle. If an unexpected event occurs (e.g., the API returns a different data format), the script breaks.

Use Case:

Routine data migration, standard document formatting, scheduled report generation.


3. Dynamic Planning: The Adaptive Navigator

In a Dynamic Execution Plan, Gemini generates the "Next Step" based on the result of the "Current Step." This is the core of true agency.

Characteristics:

  • Flexibility: The agent can pivot. If it finds a more efficient way to solve the problem, it takes it.
  • Complex Capabilities: Can handle open-ended goals like "Investigate this bug" or "Prepare a briefing for the CEO."
  • Risk: Can be unpredictable. The agent might pick a "creative" path that is expensive or dangerous.

Use Case:

Scientific research, complex debugging, customer support, and multi-agent coordination.


4. Managed Planning: The Hybrid Approach

Most Gemini ADK enterprise apps use a hybrid model. The high-level "Phases" are static, but the "Execution" within each phase is dynamic.

The Hybrid Flow:

  1. Phase 1 (Static): Load Data.
  2. Phase 2 (Dynamic): Analyze Data (Agent decides which columns to look at, which correlations to test).
  3. Phase 3 (Static): Generate Final PDF.
graph TD
    A[Start] --> B[Phase 1: Ingestion - Static]
    B --> C{Phase 2: Analysis - Dynamic}
    C -->|Reasoning| D[Tool Call 1]
    D --> E[Observation]
    E --> C
    C -->|Completion| F[Phase 3: Reporting - Static]
    
    style C fill:#4285F4,color:#fff

5. Managing Dependencies and Branching

Managing logic like "If A, then B" is the hardest part of execution planning.

A. Simple Branching (Conditionals)

"If the user says 'Yes', book the flight. If 'No', look for a train." In the ADK, this is handled by providing Gemini with two tools (book_flight, search_train) and letting it choose based on its internal reasoning.

B. Parallel Execution (Fan-out)

If a task can be split into 5 independent sub-tasks, a dynamic planner can execute them all at once.

  • Impact: Reduces total execution time significantly (e.g., 5 parallel searches take the same time as 1).

6. Implementation: A Branching Execution Plan

Let's simulate a branching execution logic in a Python agent.

import google.generativeai as genai

model = genai.GenerativeModel('gemini-1.5-pro')

def dynamic_execution_agent(request: str):
    # We give the agent two tools with different 'costs' and 'capabilities'
    def fast_summary(text: str):
        return f"Fast Summary: {text[:20]}..."

    def deep_analysis(text: str):
        return f"Deep Analysis: Detailed insights of '{text}'..."

    agent = genai.GenerativeModel(
        model_name='gemini-1.5-flash',
        tools=[fast_summary, deep_analysis]
    )

    chat = agent.start_chat(enable_automatic_function_calling=True)
    
    # Instruction to influence the branching
    prompt = (
        f"Process this: '{request}'. "
        "If it looks like a simple greeting, use 'fast_summary'. "
        "If it looks like a complex business request, use 'deep_analysis'."
    )
    
    response = chat.send_message(prompt)
    return response.text

# print(dynamic_execution_agent("Hello World"))
# print(dynamic_execution_agent("We need to acquire Company X by Q3 2026."))

7. The Human-in-the-Plan (Plan Review)

For high-stakes dynamic planning, we implement a Plan Approval Gate.

  1. Plan Generation: The Agent generates the multi-step plan.
  2. Pause: The execution loop stops.
  3. Human Review: The user sees the plan: "I will search for X, then move file Y, then delete folder Z. Proceed?"
  4. Resume: If the human clicks "Yes," the execution loop continues autonomously.

8. Summary and Exercises

Execution planning is the Management of Autonomy.

  • Static plans are for high-reliability, low-variability tasks.
  • Dynamic plans are for high-intelligence, high-variability goals.
  • Branching and Dependencies are the building blocks of logical flow.
  • Hybrid models provide the best of both worlds for enterprise systems.

Exercises

  1. Branching Logic: Design a branching plan for an agent that helps a user "Reset their password." What are the 3 different "Failure Paths" it might encounter?
  2. Efficiency Audit: You have an agent that needs to analyze 10 different stock tickers. How would its Execution Plan differ if it ran them sequentially vs. in parallel? Which one is better for cost? Which one for latency?
  3. Static Refactoring: Take a dynamic "Travel Agent" prompt and reformulate it into a Static Three-Step Workflow (1. Find Hotel, 2. Find Flight, 3. Calculate Total). Does it become more or less accurate?

In the next lesson, we will look at Handling Uncertainty, learning how to help our agents deal with ambiguous inputs and missing information.

Subscribe to our newsletter

Get the latest posts delivered right to your inbox.

Subscribe on LinkedIn