Quota Exceeded with Gemini 2.5 Flash and Browser MCP in Web Automation
I am encountering a 429 RESOURCE_EXHAUSTED error when running a web automation agent using google.adk.agents.LlmAgent with the gemini-2.5-flash-preview-05-20 model and MCPToolset. Despite having a Tier 1 subscription (which I understand has a 1M TPM limit for this model), the quota appears to be exhausted very quickly after only a few browser interactions.
Steps to Reproduce:
- Environment Setup:
- Python environment with google-adk and python-dotenv installed.
- .env file configured with necessary API keys.
WEB_PROMPTis defined (content not provided, but assumes a general instruction for web Browse).
Code Used:
- Code Used:
import os
from dotenv import load_dotenv
load_dotenv()
from google.adk.agents import LlmAgent
from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset, StdioServerParameters
from remote_mcp_agent.prompt import WEB_PROMPT
# ---- MCP Library ----
# https://github.com/modelcontextprotocol/servers
# https://smithery.ai/
root_agent = LlmAgent(
model='gemini-2.5-flash-preview-05-20',
name='filesystem_assistant_agent',
instruction=WEB_PROMPT,
tools=[
MCPToolset(
connection_params=StdioServerParameters(
command='npx',
args=[
"-y", # Argument for npx to auto-confirm install
"@browsermcp/mcp@latest"
],
),
)
],
)
- Execution: The agent was instructed to find available apartments on Airbnb in the Dalmatia region, specifically near Zadar, Brela, or other kid-friendly locations near the beach, using the mcp browser tool.
Observed Behavior:
After initiating the agent, which involved several browser_click and browser_type operations (as seen in the attached log), the execution quickly halted with the following error:
{"error": "429 RESOURCE_EXHAUSTED. {'error': {'code': 429, 'message': 'You exceeded your current quota, please check your plan and billing details. For more information on this error, head to: https://ai.google.dev/gemini-api/docs/rate-limits.', 'status': 'RESOURCE_EXHAUSTED', 'details': [{'@type': 'type.googleapis.com/google.rpc.QuotaFailure', 'violations': [{'quotaMetric': 'generativelanguage.googleapis.com/generate_content_paid_tier_input_token_count', 'quotaId': 'GenerateContentPaidTierInputTokensPerModelPerMinute', 'quotaDimensions': {'location': 'global', 'model': 'gemini-2.5-flash'}, 'quotaValue': '1000000'}]}, {'@type': 'type.googleapis.com/google.rpc.Help', 'links': [{'description': 'Learn more about Gemini API quotas', 'url': 'https://ai.google.dev/gemini-api/docs/rate-limits'}]}, {'@type': 'type.googleapis.com/google.rpc.RetryInfo', 'retryDelay': '40s'}]}}"}
The attached screenshots and log show that the agent performed actions such as:
- Navigating to Airbnb.
- Adjusting guest numbers (adults, children, infants).
- Performing a search.
- Clicking on "Filters" and then "Beachfront".
The input token count graph shows a sharp spike exceeding 1.5M tokens, while the request count remained low (around 20 requests). This indicates that the token consumption per request or per interaction is much higher than anticipated for a simple Browse session.
Expected Behavior:
Given a Tier 1 subscription with a 1,000,000 TPM (Tokens Per Minute) quota for gemini-2.5-flash, the agent should be able to perform basic web Browse and interaction without hitting a quota exhaustion error so quickly. The observed number of clicks and page loads does not seem to warrant such high token consumption.
Questions/Concerns:
- Token Consumption Analysis: What aspects of the web Browse automation with MCPToolset are consuming such a large number of input tokens? Is the entire page snapshot being sent as input for every interaction, even for minor clicks?
- Strategies for Limiting Token Usage: Are there recommended strategies or configurations within ADK or MCPToolset to reduce token consumption during web Browse automation? For example, can the prompt or tool output be made more concise, or can the frequency of full page snapshots be reduced?
- Discrepancy with Quota: How is it possible to exceed 1M TPM (1.5M observed in the graph) with only a few interactions when the stated limit is 1M? Is there a misunderstanding of how tokens are calculated for web Browse tools?
isnt this because 2.5 are preview models and thus have low quotas? its even worse with 2.5 pro, it dies after like 3 requests
I've just got the same '429 RESOURCE_EXHAUSTED' error with gemini-2.0-flash-001 with a free tier.
Here is the complete message:
{"error": "429 RESOURCE_EXHAUSTED. {'error': {'code': 429, 'message': 'You exceeded your current quota, please check your plan and billing details. For more information on this error, head to: https://ai.google.dev/gemini-api/docs/rate-limits.', 'status': 'RESOURCE_EXHAUSTED', 'details': [{'@type': 'type.googleapis.com/google.rpc.QuotaFailure', 'violations': [{'quotaMetric': 'generativelanguage.googleapis.com/generate_content_free_tier_requests', 'quotaId': 'GenerateRequestsPerMinutePerProjectPerModel-FreeTier', 'quotaDimensions': {'location': 'global', 'model': 'gemini-2.0-flash-exp'}, 'quotaValue': '10'}]}, {'@type': 'type.googleapis.com/google.rpc.Help', 'links': [{'description': 'Learn more about Gemini API quotas', 'url': 'https://ai.google.dev/gemini-api/docs/rate-limits'}]}, {'@type': 'type.googleapis.com/google.rpc.RetryInfo', 'retryDelay': '32s'}]}}"}
Hi! Thanks for the detailed write-up and great questions—these are issues a lot of folks run into when using LLMs for browser automation. Here’s what research and community experience suggest:
1. Token Consumption Analysis
You’re right to suspect that the whole page is being sent to the model. In fact, most LLM-driven browser agents (including those using frameworks like MCPToolset) tend to send the entire DOM, or at least all visible text and structural data, as context for every action. Research from projects like AutoGPT and recent papers (e.g., “Toolformer” by Meta) shows that this “full context” approach ensures the agent always has up-to-date information, but at a huge token cost. Even minor page changes (like a modal opening) can mean tens or hundreds of thousands of new tokens per request, especially on content-heavy or dynamically updating sites.
This is a known tradeoff in LLM agent design: more context = better reasoning, but much higher cost.
2. Strategies for Limiting Token Usage
The field is evolving quickly, but here are some strategies researchers and practitioners recommend:
- Selective Context Extraction:
Newer research and open-source projects are experimenting with extracting only the “diff” (the parts of the DOM that have changed) or just the visible, relevant elements, rather than the full page. Some LLM agent toolkits (like LangChain’s WebNavigator) are starting to offer options for “context pruning” or “focused extraction.” - Prompt Compression:
Studies (see: OpenAI Cookbook, “Reducing Prompt Tokens”) show that even small reductions in instruction or history length can dramatically reduce per-request tokens. Try to keep instructions direct, and limit conversation history in the prompt. - Action Batching:
When possible, batch multiple actions into one step. For example, fill out all form fields before submitting, rather than one at a time—this reduces how many times the context needs to be resent. - Tool/Framework Settings:
Check if MCPToolset or ADK have config options for limiting what’s sent each step (e.g., only sending visible text, or updating context less frequently). Some frameworks support this, or at least allow you to customize the context extraction logic.
3. Discrepancy with Quota
This is a common confusion! Token quota enforcement is typically on a rolling window, and cloud providers may allow brief overages before throttling. Also, token counting isn’t always intuitive—HTML, embedded scripts, and long attribute strings can all inflate the count. Research and user reports (see: OpenAI, Google Gemini, Anthropic docs) confirm that a handful of large payloads can exhaust a quota surprisingly quickly, even if the number of requests is low.
For more detail, you can check out:
- Gemini API Rate Limits
- OpenAI Token Counting
- Recent LLM agent research on efficient context handling (e.g., Toolformer, AutoGPT)
Summary
So in short:
- Yes, the full page snapshot per interaction is likely driving up your token use.
- Try to limit what’s sent and keep prompts short—community projects and research are actively working on better context management for LLM agents.
- The quota overage is due to both how tokens are counted and how quickly large payloads add up.
If you want to explore specific settings or want help interpreting logs or payloads, just ping me!
Best,
Ajit
This is a model quota issue that can't be addrssed by ADK.