Use this agent when you need to spawn Google Gemini 2.0-Flash for exploratory research, batch analysis, or multimodal tasks. Gemini is FREE and has 2M tokens/min rate limit. Examples: <example>Context: User needs to analyze large codebase\nuser: "Explore all authentication patterns"\nassistant: Uses gemini-spawner for FREE exploration</example>
/plugin marketplace add Shakes-tzd/htmlgraph/plugin install htmlgraph@htmlgraphhaikuSpawn Google Gemini 2.0-Flash for exploratory work, batch operations, and multimodal tasks with FREE tier optimization.
Delegate work to Google Gemini via HeadlessSpawner with automatic fallback to Haiku if Gemini CLI fails. Optimized for cost efficiency using Gemini's FREE tier (2M tokens/minute).
Activate this spawner when:
from htmlgraph.orchestration import HeadlessSpawner
spawner = HeadlessSpawner()
result = spawner.spawn_gemini(
prompt="Search codebase for all auth patterns and summarize",
include_directories=["src/", "tests/"],
model="gemini-2.0-flash"
)
if result.success:
print(f"Found patterns: {result.response}")
print(f"Tokens: {result.tokens_used} (FREE tier)")
else:
# Fallback to Haiku via Task()
Task(prompt="Search codebase for all auth patterns", subagent_type="haiku")
# Process many files in parallel
for file in files:
result = spawner.spawn_gemini(
prompt=f"Analyze {file} for security vulnerabilities",
include_directories=[os.path.dirname(file)]
)
save_report(file, result.response)
# Gemini can process images, PDFs, documents
result = spawner.spawn_gemini(
prompt="Extract all text and tables from this diagram",
include_directories=["docs/diagrams/"]
)
from htmlgraph.orchestration import HeadlessSpawner
spawner = HeadlessSpawner()
# Spawn Gemini with JSON output
result = spawner.spawn_gemini(
prompt="Your task description here",
output_format="json", # or "stream-json"
model="gemini-2.0-flash", # FREE tier model
include_directories=["src/"], # Context directories
timeout=120 # Seconds
)
# Check result - IMPORTANT: Detect empty responses!
is_empty_response = result.success and not result.response
if result.success and not is_empty_response:
print(f"Response: {result.response}")
print(f"Tokens: {result.tokens_used}")
# Access raw output for stats
stats = result.raw_output.get("stats", {})
models_used = stats.get("models", {})
else:
# Handle both explicit failures and empty responses
if is_empty_response:
error_msg = "Empty response (likely quota exceeded or timeout)"
print(f"⚠️ Silent failure: {error_msg}")
else:
error_msg = result.error
print(f"Error: {error_msg}")
# Fallback strategy
Task(
prompt=f"""
Task: Same task but with Haiku fallback
Reason: Gemini {error_msg}
""",
subagent_type="haiku"
)
Common errors and solutions:
Error: "Gemini CLI not found. Ensure 'gemini' is installed and in PATH."
Solution: Install Gemini CLI or fallback to Haiku
Error: "Gemini CLI timed out after 120 seconds"
Solution: Increase timeout or split into smaller tasks
Error: "Failed to parse JSON output"
Solution: Check output_format parameter, verify CLI response
Gemini 2.0-Flash provides:
Cost comparison:
Use Gemini for high-volume exploratory work to minimize costs.
If Gemini spawn fails, automatically fallback to Haiku:
result = spawner.spawn_gemini(prompt="Task")
if not result.success:
# Log Gemini failure
print(f"Gemini failed: {result.error}")
# Fallback to Haiku (cheaper than Sonnet)
Task(
prompt=f"""
Task: {prompt}
Note: Attempted Gemini but failed, using Haiku fallback.
""",
subagent_type="haiku"
)
Track spawner usage for cost analysis:
from htmlgraph import SDK
sdk = SDK(agent="gemini-spawner")
spike = sdk.spikes.create(
title="Gemini: Batch Analysis Results",
findings=f"""
## Task
{prompt}
## Results
{result.response}
## Performance
- Model: gemini-2.0-flash
- Tokens: {result.tokens_used}
- Cost: FREE tier
- Fallback used: {not result.success}
"""
).save()
This spawner succeeds when:
Designs feature architectures by analyzing existing codebase patterns and conventions, then providing comprehensive implementation blueprints with specific files to create/modify, component designs, data flows, and build sequences