Yes, Google has open-sourced a framework called Agent Harness that explicitly supports recursive agent workflows, where an agent can spawn and manage sub-agents. The framework was released as part of the Google Agent Framework (GAF) in April 2025, and it provides the scaffolding for building, orchestrating, and observing multi-agent systems, including recursive patterns. This article explains what that means, how the framework works, and what you can actually do with it.
What is the Google Agent Framework?
The Google Agent Framework (GAF) is an open-source Python library designed to simplify the creation of agentic AI systems. It was announced alongside Google’s Vertex AI Agent Engine and is built on top of existing Google AI tools like the Gemini API and Vertex AI. The framework provides a structured way to define agents, connect them to tools, and manage their execution. Unlike lower-level libraries that require you to handle every detail, GAF offers high-level abstractions for common agent patterns, including sequential pipelines, hierarchical teams, and recursive self-improvement loops.
One of the key features of GAF is its support for recursive agent harnessing. In this context, “harnessing” refers to the process of controlling and coordinating multiple agents—deciding when to spawn a sub-agent, what task to give it, and how to integrate its output. Recursive harnessing means an agent can create a child agent to handle a sub-task, and that child can itself create further agents, forming a tree of agents that can tackle problems too complex for a single agent.
How Recursive Agent Harnessing Works
In GAF, recursion is implemented through the Agent class and its sub_agents parameter. You define a parent agent that, when it encounters a task it cannot handle directly (or that would benefit from parallel processing), can instantiate a sub-agent with a specific prompt and toolset. The sub-agent runs independently, returns its result to the parent, and the parent integrates that result into its own reasoning. This is not just a simple function call—the sub-agent has its own state, memory, and execution loop, making it a true agent rather than a tool.
For example, consider a research agent that needs to write a report on a complex topic. It could spawn a sub-agent to gather data from a specific API, another to summarize academic papers, and a third to fact-check the final draft. Each sub-agent can itself spawn helpers if needed. The parent agent orchestrates the whole process, deciding when to delegate and how to combine results. GAF handles the mechanics of starting, monitoring, and stopping these agents, and it logs all interactions for debugging.
Why Recursive Agents Matter
Recursive agent architectures address a fundamental limitation of single-agent systems: context length and attention. A single agent has a fixed context window, and as it tries to handle many tasks, it can become overwhelmed or lose track of earlier steps. By delegating sub-tasks to sub-agents, each agent can focus on a narrow scope, keeping its context clean and its reasoning sharp. This is analogous to how a human team works—you don’t have one person do everything; you break the work into roles.
Another benefit is parallelism. If a task can be split into independent parts, a parent agent can spawn multiple sub-agents simultaneously, dramatically reducing wall-clock time. GAF supports this with its asyncio-based execution model, allowing agents to run concurrently. This is particularly useful for tasks like data scraping, where you can have one agent per URL, or for running multiple simulations with different parameters.
Recursive patterns also enable self-improvement. An agent can spawn a “critic” sub-agent to review its own output, then use that feedback to revise. This creates a loop that can iteratively improve quality. GAF’s design makes this pattern straightforward to implement, and it’s a popular use case among developers experimenting with agentic AI.
How to Get Started with GAF
To use the Google Agent Framework, you need Python 3.9 or later and access to Google’s AI APIs (Gemini or Vertex AI). You can install it via pip:
pip install google-agent-framework
Then, you define an agent by subclassing Agent or using the built-in Agent class with a system prompt and tools. Here’s a minimal example of a parent agent that spawns a sub-agent:
from google.agent_framework import Agent, Tool
class ParentAgent(Agent):
def run(self, task):
# Create a sub-agent
sub = Agent(
name="summarizer",
system_prompt="Summarize the given text in 100 words.",
model="gemini-2.0-flash"
)
# Delegate a sub-task
summary = sub.run(task["text"])
return f"Summary: {summary}"
This is a simplified illustration—the actual API may differ slightly, but the core concept is that you can instantiate agents inside other agents. The framework also provides a Runner class to execute agents with built-in tracing and observability.
Common Problems and Misconceptions
A common misconception is that recursive agents are always better than a single agent. In practice, recursion adds overhead: each sub-agent consumes API tokens, increases latency, and can introduce errors if not carefully managed. For simple tasks, a single agent is faster and cheaper. Recursion is only beneficial when the task genuinely benefits from decomposition or parallelism.
Another issue is runaway recursion. If you don’t set limits, an agent can spawn an infinite chain of sub-agents, exhausting your API quota. GAF provides a max_depth parameter to limit recursion depth, and you should always set it. Also, be careful with context—sub-agents inherit the parent’s tools by default, but you can override this to restrict what a sub-agent can do. This is important for security and cost control.
A frequent technical problem is state management. Since sub-agents run independently, they don’t automatically share memory. You need to pass necessary context in the prompt or use a shared memory store. GAF allows you to pass a state object to sub-agents, but designing the right state-sharing strategy is a key challenge.
Comparison with Other Frameworks
Google Agent Framework is not the only open-source option for recursive agents. LangGraph (from LangChain) also supports hierarchical agent structures and has a more mature ecosystem. LangGraph uses a graph-based approach where you define nodes and edges, and recursion is achieved by having a node call another sub-graph. It offers more fine-grained control over execution flow.
CrewAI is another popular framework that emphasizes role-based agent teams. It allows you to define agents with specific roles and tasks, and it supports hierarchical processes where a manager agent coordinates workers. CrewAI is often praised for its simplicity, but it may not be as flexible as GAF for complex recursive logic.
Compared to these, GAF’s advantages are its tight integration with Google’s Gemini models and Vertex AI, as well as its built-in support for observability through Cloud Trace and Cloud Logging. However, it’s newer and less battle-tested than LangGraph. If you’re already using Google Cloud, GAF is a natural fit; otherwise, you might prefer a more cloud-agnostic option.
Costs and Safety Considerations
Running recursive agents can be expensive because each sub-agent invocation incurs API costs. For example, if you have a parent agent that spawns 3 sub-agents, and each sub-agent makes 10 API calls, that’s 30 calls for one parent task. If you’re using a paid model like Gemini, the cost multiplies quickly. Always estimate your token usage and set budget alerts. GAF doesn’t have built-in cost controls, so you need to implement your own checks.
Safety is another concern. Recursive agents can amplify biases or errors if not monitored. Since sub-agents act autonomously, you should ensure they have clear constraints and cannot perform harmful actions. GAF allows you to restrict tools per agent, so you can give a sub-agent read-only access to a database, for instance. Also, consider adding human-in-the-loop checkpoints for critical tasks—GAF supports this via the human_approval parameter on tools.
Frequently Asked Questions
Is Google Agent Framework free to use?
The framework itself is open-source and free, but you need to pay for the underlying AI models (Gemini API or Vertex AI) and any cloud resources. There are free tiers for Gemini, but they have rate limits. For production use, expect to pay for API calls.
Can I use GAF with models other than Gemini?
GAF is designed to work with Gemini and Vertex AI, but because it’s Python, you can potentially adapt it to other models by implementing a custom model client. However, the built-in integrations are specifically for Google’s models, so using others requires more work.
What is the difference between a sub-agent and a tool?
A tool is a simple function that an agent calls (like a calculator or a web search). A sub-agent is a full agent with its own reasoning loop, memory, and ability to use tools. Sub-agents are more powerful but slower and more expensive. Use tools for simple operations, and sub-agents for complex sub-tasks.
Does GAF support parallel execution of sub-agents?
Yes, GAF supports asynchronous execution, so you can spawn multiple sub-agents concurrently using asyncio.gather(). This can significantly speed up tasks that can be parallelized.
Can I deploy GAF agents to production?
Yes, GAF is designed for production use. You can deploy agents to Vertex AI Agent Engine, which provides managed infrastructure, scaling, and monitoring. Alternatively, you can run them on your own servers using the framework’s runner.
What are the limitations of recursive agents?
The main limitations are cost, latency, and complexity. Recursive agents use more tokens and take longer to complete. They also require careful design to avoid infinite loops and to manage state. For simple tasks, a single agent is often better.
Related
Formula used
in t | Total time (min) | min | 120 | 0 in n | Number of agents | - | 3 | 1 | 100 out per | Time per agent (min) | min | t / n | 2 out per_hr | Time per agent (hr) | hr | (t / n) / 60 | 2
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Valheim Server Not Showing in Community List Fixes
- Soundbar vs 2.1 Speaker System: Which Is Better?
- DisplayPort vs HDMI: Which Cable Should You Use?
- Survive Lava for Brainrot Tier List170 points
- MySQL Dump Import: Fix Common Errors
- Mouse Moving on Its Own? Causes & Fixes