Autonomous Deep Research Council & Self-Directed Code Refactoring Agents
Powered by Google's Antigravity Sandbox (antigravity-preview-09-2026) via Google Gemini API & LiteRouter Gateway
This repository is optimized for AI assistants, autonomous coding agents, and automated context ingestion:
- Machine Discovery (llms.txt): Curated Markdown index for LLMs based on the Answer.AI specification.
- Full Context Document (llms-full.txt): Aggregated reference manual for large-context models (Claude, ChatGPT, Gemini).
- System Architecture (ARCHITECTURE.md): Mermaid topology diagrams, execution sequences, and verification primitives.
- Agent Master Guidelines (AGENTS.md): Rules, schema constraints, and endpoint contracts for autonomous agents.
- Claude Code Config (CLAUDE.md): Direct memory file and development invariants for the Anthropic Claude CLI.
- One-Click Ingestion: Ingest this repository into Claude or ChatGPT with a single click using GitIngest.
- Repomix Packaging: Package the codebase into an AI-optimized XML context file with token counts:
# Generate repomix-output.xml using repomix.config.json npx repomix
When working with an AI assistant on this repository, paste this prompt for instant orientation:
"I am working on the agy-agents repository (https://github.com/Acivar-Digital/agy-agents).
- Context: Autonomous multi-persona deep research and automated Python code refactoring connected to Google Antigravity (
antigravity-preview-09-2026).- Endpoint Contract: Strictly use
POST /v1beta/interactionswith{'agent': 'antigravity-preview-09-2026', 'input': '...', 'environment': 'remote'}. NEVER use/v1/chat/completionsor:generateContent.- Tech Stack: Python 3.10+, uv, Pydantic V2 (
extra='forbid'), FastMCP (agy-mcp).- Verification: Run
uv run python -m unittest tests/test_mcp_server.pybefore declaring any work complete.- Architecture: Follow
ARCHITECTURE.mdandAGENTS.mdfor design invariants."
agy-agents is an open-source framework of autonomous AI agent workflows designed for institutional-grade intelligence gathering and production-ready code modernization. Built directly on Google's stateful Antigravity Sandbox environment (/v1beta/interactions), it delivers capabilities beyond standard single-turn LLM chat completions:
- π¬ Deep Research (Council Protocol): Automatically orchestrates a multi-perspective panel of 5 specialized expert personas (e.g., Quantitative Analyst, Macro Strategist, Systems Architect, Risk Specialist, and Adversarial Skeptic). The council searches live web data, verifies empirical evidence, resolves internal contradictions, and compiles whitepapers natively rendered into Markdown, HTML, PDF, and Word (.docx) formats.
- π οΈ Autonomous Code Refactoring: Analyzes real-world codebases to enforce PEP 8 standards, strict type annotations, architectural decoupling, and helper extraction. Operates in two modes: surgical single-file CLI or batch manifest pipelines with shared reference contexts.
- π Dual-Engine Inference:
- Public Community Mode (Default): Out-of-the-box connectivity to the Google Gemini API using a standard
GEMINI_API_KEY. - Self-Hosted Mode: Direct routing through a private LiteRouter LAN gateway (
http://literouter.lan:7766) usingLITEROUTER_AUTH_KEY.
- Public Community Mode (Default): Out-of-the-box connectivity to the Google Gemini API using a standard
- π MCP & Pipeline Ready: Zero CLI lock-in. Both tools export cleanly decoupled core functions (
execute_researchandexecute_refactor) ready for integration into custom Python pipelines or Model Context Protocol (MCP) server tools.
agy-agents is designed for rapid installation via pip or uv:
# Using standard pip
pip install git+https://github.com/Acivar-Digital/agy-agents.git
# Using uv
uv pip install git+https://github.com/Acivar-Digital/agy-agents.gitOnce installed, the CLI tools are available globally in your environment:
# Run Deep Research
agy-research Quantum_Computing
# Run Code Refactoring
agy-refactor path/to/script.py --prompt "Add type hints and PEP 8"git clone https://github.com/Acivar-Digital/agy-agents.git
cd agy-agents
# Copy environment configuration
cp .env.example .envInstall local dependencies:
pip install -r requirements.txt
# Or run scripts directly with uv (uv automatically handles environment and dependencies)Add your API credentials to .env:
# --- Option A: Public Community Mode (Google Gemini API) ---
GEMINI_API_KEY=AIzaSy...your_gemini_api_key_here
# --- Option B: Self-Hosted Mode (LiteRouter Gateway) ---
# LITEROUTER_HOST=literouter.lan
# LITEROUTER_PORT=7766
# LITEROUTER_AUTH_KEY=your_literouter_key_here# 1. Create a prompt template
cp deep-research/prompts/_template_guide.md deep-research/prompts/Quantum_Computing.md
# 2. Edit Quantum_Computing.md with your research question and 5 tailored personas
# 3. Run the research agent
uv run python deep-research/deep-research.py Quantum_ComputingThe agent runs live web sprints, aggregates findings, executes supervisor reviews, and compiles four artifact formats in deep-research/reports/:
Quantum_Computing_YYYYMMDD_HHMM.mdQuantum_Computing_YYYYMMDD_HHMM.htmlQuantum_Computing_YYYYMMDD_HHMM.pdfQuantum_Computing_YYYYMMDD_HHMM.docx
# Refactor and save to path/to/script_refactored.py
uv run python refactor/refactor.py path/to/script.py
# Optional: provide custom inline refactoring prompt
uv run python refactor/refactor.py path/to/script.py --prompt "Refactor to Pydantic v2 schemas and strict async/await"
# Optional: overwrite the target file in-place
uv run python refactor/refactor.py path/to/script.py --inplace# Process all manifests in refactor/manifests/*.json concurrently
uv run python refactor/refactor.py
# Or process a specific manifest
uv run python refactor/refactor.py --manifest refactor/manifests/template.jsonThis repository provides an open architecture. We encourage you to use your favorite LLM (Claude, ChatGPT, Gemini, or OpenCode) to adapt the personas, rules, and manifests to your specific project needs!
"I am researching [INSERT TOPIC HERE]. Review
deep-research/prompts/_template_guide.mdand generate a complete prompt file containing 5 distinct, adversarial expert personas (e.g. specialized domain engineer, macro economist, risk quant, contrarian skeptic, and regulatory analyst) with search objectives tailored to this topic."
"Inspect
refactor/prompt.txt. Refactor this system prompt to enforce our engineering team's standards: [e.g. enforce Google docstrings, Pydantic v2 data models, zero Any annotations, decoupled repository pattern, and FastAPI route best practices]."
"Review
refactor/manifests/template.jsonand my codebase insrc/. Generate a manifest JSON that targets our database query modules, providessrc/models.pyas a reference context, and refactors all queries to use SQLAlchemy 2.0 select statements."
agy-agents includes a native Model Context Protocol (MCP) server (agy-mcp via FastMCP) enabling AI assistants across other IDEs and workspaces (OpenCode, Claude Desktop, Cursor, and subagent workpools) to invoke the Deep Research Council and autonomous code refactoring.
Standard MCP clients enforce a strict 60-second RPC timeout. Because the 5-persona research council conducts 50 live Google searches and sandbox document compilation (taking ~3β8 minutes), agy-mcp implements a hybrid execution protocol:
prepare_research_prompt: (<1s) Dynamically crafts and saves a 5-persona research prompt file indeep-research/prompts/<stem>.mdand provides the exact CLI command.start_research: (<1s) Spawns an asynchronous background worker and immediately returns a uniquejob_id, preventing client RPC timeout errors.get_research_status: Queries job progress, returns execution elapsed time, and delivers the synthesized executive summary and paths to compiled artifacts (.md,.html,.pdf,.docx) upon completion.refactor_code: (5β15s) Synchronous, high-speed code refactoring with AST syntax validation and unified diff preview.list_research_prompts: Discovers available structured prompt templates and active stems.check_gateway_health: Probes the inference gateway (literouter.lan:7766or Google Gemini) for reachability and latency.
| Tool Name | Type | Key Inputs | Description |
|---|---|---|---|
prepare_research_prompt |
Fast | topic, prompt_stem, custom_rubric |
Sculpt tailored 5-persona research council prompt with background CLI execution commands. |
start_research |
Async | prompt_stem_or_topic, timeout_seconds |
Non-blocking dispatch returning job_id immediately. Avoids client timeout drops. |
get_research_status |
Polling | job_id |
Poll background progress or retrieve executive summary and compiled artifact paths. |
refactor_code |
Sync | code, filename, instructions |
Autonomously refactor Python code (PEP 8, strict type hints, clean architecture) with diff summary. |
list_research_prompts |
Discovery | (None) | Scan repository for ready-to-run prompt templates and topics. |
check_gateway_health |
Diagnostic | (None) | Inspect LiteRouter / Gemini endpoint connectivity and latency. |
The MCP service can be accessed via Direct Intranet SSE (Recommended for LAN / WireGuard) or SSH Stdio (Zero configuration):
Any client on the LAN or WireGuard mesh can connect directly to the persistent systemd service:
- SSE Stream URL:
http://agy-agents.lan:7788/sse(orhttp://192.168.50.10:7788/sse) - Streamable HTTP URL:
http://agy-agents.lan:7788/mcp
{
"mcpServers": {
"agy-agents": {
"url": "http://agy-agents.lan:7788/sse"
}
}
}{
"mcp": {
"agy-agents": {
"type": "local",
"command": [
"ssh",
"-o", "BatchMode=yes",
"vps466a",
"/home/vps466a/.local/bin/uv run --directory /home/vps466a/services/agy-agents agy-mcp"
]
}
}
}{
"mcpServers": {
"agy-agents": {
"command": "ssh",
"args": [
"-o", "BatchMode=yes",
"vps466a",
"/home/vps466a/.local/bin/uv run --directory /home/vps466a/services/agy-agents agy-mcp"
]
}
}
}{
"mcpServers": {
"agy-agents": {
"command": "ssh",
"args": [
"-o", "BatchMode=yes",
"vps466a",
"/home/vps466a/.local/bin/uv run --directory /home/vps466a/services/agy-agents agy-mcp"
]
}
}
}Both agent tools export cleanly modular functions for inclusion in custom Python scripts:
from deep_research import execute_research
from refactor import execute_refactor
# 1. Trigger Deep Research programmatically
research_result = execute_research(
prompt_content="Analyze impact of liquid cooling in next-gen AI data centers...",
prompt_stem="data_center_cooling",
)
print("Generated report artifacts:", research_result.extracted_files)
# 2. Trigger Code Refactoring programmatically
refactor_result = execute_refactor(
code_content="def calculate(data): return [x*2 for x in data if x > 0]",
prompt="Add complete type hints, Google docstrings, and input validation.",
)
print("Refactored code:\n", refactor_result.refactored_code)- π FastMCP Integration: Native MCP server (
agy-mcp) exposing 6 sovereign tools for AI assistants in OpenCode, Claude Desktop, and Cursor. - β‘ Hybrid Execution Engine: Solves 60s MCP RPC timeout drops via asynchronous background research jobs (
start_research,get_research_status) and dynamic prompt preparation (prepare_research_prompt). - π οΈ Synchronous Code Refactoring: Direct in-turn code modernization (
refactor_code) with AST syntax validation and unified diff calculation. - π VPS & LiteRouter LAN Deployment: Validated remote execution over SSH against LiteRouter at
literouter.lan:7766with zero hardcoded credentials.
- π‘οΈ Pydantic V2 Type Contracts: Full migration to modern Pydantic V2 (
pydantic>=2.10.0) across all workflows. - π Immutable Provider Configs: Frozen
ProviderConfigmodels for both Deep Research and Refactor engines, validating URLs, placeholders, and headers. - π‘ Strict Interaction Schemas: Validated
InteractionRequest,InteractionStep, andInteractionResponsemodels safeguarding communication with LiteRouter and Google Gemini/v1beta/interactions. - π Robust Manifest Validation: Strictly validated
RefactorManifest,RefactorExecutionRequest, andRefactorExecutionResultensuring early detection of malformed configurations. - π 100% Backward Compatibility: Native support for dict-style indexing, tuple unpacking, and existing CLI interfaces with zero breaking changes.
- π Initial Stable Release: First public release of
agy-agentsframework. - π Zero Hardcoded Secrets: Clean credential design with strict
.gitignorerules. - β‘ Dual-Engine Auto-Resolution: Transparent auto-switching between public Google Gemini API (
GEMINI_API_KEY) and self-hosted LiteRouter gateway (LITEROUTER_AUTH_KEY). - π¦ Standardized Packaging:
pyproject.tomlandrequirements.txtconfigured withhatchlingpackaging for nativeuvandpipinstallation. - π§© Modular Python Exports: Standalone
execute_research()andexecute_refactor()APIs ready for Model Context Protocol (MCP) servers. - π οΈ Hybrid Refactoring CLI: Direct single-file arguments and concurrent manifest processing with automatic markdown code fence stripping.
- π Sandbox Multi-Format Extraction: Automatic compilation and extraction of
.md,.html,.pdf, and.docxreport artifacts.
agy-agents/
βββ .env.example β Universal environment template
βββ pyproject.toml β PEP 621 package metadata & dependencies
βββ requirements.txt β Dependencies (python-dotenv, httpx, h2, pydantic)
βββ CHANGELOG.md β Keep a Changelog documentation
βββ deep_research.py β Modular programmatic import shim
βββ deep-research/
β βββ deep-research.py β Deep research runner & execute_research()
β βββ run.sh β Cron-friendly batch runner
β βββ README.md β Deep research guide
β βββ prompts/
β β βββ _template_guide.md β Prompt & 5-persona template
β β βββ *.md β Topic prompt files
β βββ reports/ β Generated reports (.md, .html, .pdf, .docx)
βββ refactor/
β βββ __init__.py β Package exports for programmatic refactoring
β βββ refactor.py β Dual-engine hybrid refactorer
β βββ prompt.txt β Default refactoring instructions
β βββ INSTRUCTIONS.md β Manifest workflow documentation
β βββ manifests/
β β βββ template.json β Manifest reference template
β βββ reports/ β Batch reports (gitignored)
βββ .opencode/skills/agy-agents/ β OpenCode / AI Assistant skill definitions
βββ README.md β Project documentation
For GitHub repository maintainers, configure the following repository topics:
ai-agents β’ deep-research β’ code-refactoring β’ google-gemini β’ antigravity β’ literouter β’ mcp β’ python β’ autonomous-agents β’ llm-tools
Distributed under the MIT License. See LICENSE for full details. Open to the global AI and developer community.