A self-hosted autonomous AI development agent powered by Google Gemini β
coding assistant, terminal agent, security tester, and persistent memory in one interface.
Overview β’ Install β’ Run β’ Keys β’ CLI β’ Troubleshoot β’ Pro Version β’ Contribute
Agent-2-Beta is a self-hosted autonomous AI agent powered by Google Gemini. It ships in two modes:
| Mode | Entry point | Description |
|---|---|---|
| π Web UI | agent2web.py |
Browser interface β workspaces, multi-tab terminals, Three.js 3D welcome, real-time streaming |
| β‘ CLI | agent2cli.py |
Terminal-native agent β same brain, tools, and memory as the web UI |
Both modes share the same 8 agentic tools, persistent memory engine, and .env-based API key rotation.
| Feature | Description | |
|---|---|---|
| ποΈ | Workspaces | Claude Projects-style context β path browser, per-workspace memory, framework detection |
| π€ | 8 Agent Tools | Shell, file R/W, directory tree, project analyzer, web search, memory, planner |
| π§ | Persistent Memory | Global, workspace-scoped, and auto-extracted memories across sessions |
| π» | Multi-tab Terminals | Live streaming, stdin injection, ββ command history, 2-stage kill |
| π | API Key Rotation | Multiple keys, auto-rotate on quota, pin a key, per-key usage stats |
| π | Security Testing | nmap, nikto, gobuster, sqlmap, hydra, metasploit β built-in workflows |
| π | Web Search | DuckDuckGo instant answers β no extra API key required |
| βοΈ | Message Editing | Edit any past message and re-run the agent from that point |
| βΉοΈ | Stop Generation | Cancel agent mid-flight at any time |
| π | File Attachments | Attach code, images, PDFs as context |
| One-click Run | Click βΆ on any tool block to instantly run that command in the active terminal | |
| π¨ | 3D Welcome Screen | Three.js β neural particles, torus knot, rotating wireframes, octahedron |
| π¦ | Project Auto-Setup | Detect framework β install deps β run project automatically |
Left: Web Interface Β β’Β Right: Installation & Setup
Agent2 CLI β Rich UI, key rotation, ββ history, and all 8 tools in the terminal
agent2/
βββ run.py β Universal launcher β setup, run, manage keys
βββ agent2web.py β Web UI entry point
βββ agent2cli.py β CLI agent entry point
βββ .env β API keys (auto-created on first run)
βββ agent2.db β SQLite database (auto-created)
βββ agent2/
βββ __init__.py
βββ config.py β Platform detection, models, modes, constants
βββ database.py β SQLite helpers + schema + migrations
βββ memory.py β Memory engine (auto-extract, workspace-scoped)
βββ tools.py β 8 tool implementations
βββ keys.py β KeyRotator: rotation, pinning, usage tracking
βββ terminal.py β stream_command, stdin, kill, stop events
βββ agent.py β system_prompt, context builder, run_agent loop
βββ routes.py β All /api/* REST endpoints
βββ sockets.py β All Socket.IO event handlers
βββ ui.py β HTML/CSS/JS single-page frontend (89 KB)
git https://github.com/aaravshah1311/Agent-2-Beta.git
cd Agent-2-Betapython run.pyrun.py will automatically:
- β Create a virtual environment
- β
Install all dependencies (
flask,flask-socketio,google-genai,rich, β¦) - β
Prompt for your Gemini API key and save it to
.env - β Start the web server
π Free Gemini API key β https://aistudio.google.com/app/apikey
python run.py setup + start Web UI (default)
python run.py --web setup + start Web UI
python run.py --cli setup + start CLI agent
python run.py --addapi add / manage API keys
python run.py --reset wipe venv and reinstall everything
python run.py --uninstall completely remove Agent2 and its venv
python run.py -h show this help menu
python run.py
# or explicitly
python run.py --webOpens at β http://localhost:1311
python run.py --cliOr call directly after first setup:
# macOS / Linux
venv/bin/python agent2cli.py
# Windows
venv\Scripts\python agent2cli.pyOne-shot mode (pipe-friendly, just like gemini -m flash "..."):
venv/bin/python agent2cli.py "portscan 10.10.1.1"
venv/bin/python agent2cli.py --model 2.5-flash "explain this error"
venv/bin/python agent2cli.py --mode thinking "design this architecture"
venv/bin/python agent2cli.py --clear "start a fresh session"python run.py --addapiWalks you through adding keys interactively and saves them to .env.
Keys are stored as GEMINI_API_KEY, GEMINI_API_KEY_2, GEMINI_API_KEY_3 β¦ and auto-rotated when one exhausts its quota. No downtime β the next key is picked up on the very next request.
/addapi
Paste a new key without leaving the session β saved to .env immediately and active on the next call.
python run.py --resetWipes venv/ and reinstalls all dependencies. Use when packages break or Python is upgraded.
python run.py --uninstallRemoves the virtual environment and generated files, leaving source code intact.
- Open http://localhost:1311
- Click + Create Workspace in the sidebar
- Enter a name and optionally a project path β leave blank to auto-create a folder
- Click the workspace β New Chat β start working
Every chat belongs to a workspace. The agent always knows your project path, detected framework, and accumulated workspace memories.
| Command | Description |
|---|---|
/help |
Show all commands |
/addapi |
Add a Gemini API key to .env |
/keys |
Show current API key status and usage |
/model [name] |
Switch model (2.5-flash-lite Β· 2.5-flash Β· 2.5-pro Β· 3.1-*) |
/mode [name] |
Switch mode (fast β‘ Β· pro β
Β· thinking π§ ) |
/clear |
Clear current conversation and start fresh |
/history |
Show last 10 messages |
/memory |
List all saved memories with importance scores |
/addmem <text> |
Save a memory manually |
/workspace [path] |
Show or set working directory for commands |
/run <cmd> |
Run a shell command directly in the current workspace |
/read <file> |
Read and display a file's contents |
/write <file> |
Write text to a file (prompts for content) |
/ls [path] |
Display a recursive directory tree |
/analyze <path> |
Detect framework / language / dependencies / run command |
/search <query> |
Web search via DuckDuckGo (no key required) |
/exit Β· Ctrl+C |
Quit |
- Python 3.10+ installed
-
python run.pycompleted without errors - Gemini API key saved to
.env - Web UI β server starts at http://localhost:1311, first workspace created
- CLI β prompt
you [no-ws|2.5-flash-lite|β ]>appears
| Key | Model | Group |
|---|---|---|
2.5-flash-lite |
Gemini 2.5 Flash Lite | 2.5 |
2.5-flash |
Gemini 2.5 Flash | 2.5 |
2.5-pro |
Gemini 2.5 Pro | 2.5 |
3.1-flash-lite |
Gemini 3.1 Flash Lite | 3.1 |
3.1-flash |
Gemini 3.1 Flash | 3.1 |
3.1-pro |
Gemini 3.1 Pro | 3.1 |
| Mode | Max Tokens | Best for |
|---|---|---|
| β‘ Fast | 2 048 | Quick answers, simple commands β lowest cost |
| β Pro | 8 192 | Most tasks β balanced speed and quality |
| π§ Thinking | 16 384 | Complex reasoning, architecture, hard bugs (2.5 / 3.1 only) |
| Layer | Technology |
|---|---|
| Backend | Python 3.10+, Flask, Flask-SocketIO |
| AI Engine | Google Gemini (google-genai) |
| Database | SQLite (stdlib sqlite3) |
| Terminal | subprocess.Popen β live stdout streaming |
| Web frontend | Vanilla JS, xterm.js, marked.js, highlight.js, Three.js |
| 3D scene | Three.js r128 β particles, torus knot, icosahedra, octahedron |
| CLI UI | Rich β panels, markdown, syntax highlight, spinner |
| Memory | Auto-extraction via background Gemini call after each reply |
| Web search | DuckDuckGo Instant Answer API β no key required |
Agent-2-Beta is purpose-built for security research and CTF work:
portscan 10.10.1.1
enumerate http://target:8080 with gobuster
run sqlmap on http://target/login?id=1
check for open ports on localhost
scan for vulnerabilities on 192.168.1.0/24
brute force SSH on 10.10.1.5 with hydraSupports: nmap, nikto, gobuster, ffuf, sqlmap, hydra, metasploit,
searchsploit, theharvester, binwalk, strings, volatility, and more.
| Problem | Solution |
|---|---|
No API keys configured |
python run.py --addapi or type /addapi in the CLI |
| Key quota exhausted | Keys rotate automatically. Add more: python run.py --addapi |
| Model returns empty response | Switch to 2.5 Flash Lite: /model 2.5-flash-lite |
| Terminal not showing output | Refresh the browser tab and reconnect |
python not found on Windows |
Use py run.py or install from the Microsoft Store |
| Port 1311 already in use | Change port=1311 in agent2web.py to another port |
| Broken venv / import errors | python run.py --reset β wipes and reinstalls cleanly |
| CLI spinner frozen | Ctrl+C β cancels the request and returns to prompt |
rich not installed |
python run.py --reset β rich is included in the install list |
| Want to start completely fresh | python run.py --uninstall then python run.py |
Unlock the full power of autonomous AI engineering.
Agent-2-Pro is the professional-grade evolution of Agent-2-Beta β a proper Software Engineer and Brutal Pentester in one agent.
| Agent-2-Beta | Agent-2-Pro | |
|---|---|---|
| Workspaces | β | β |
| 8 Agent Tools | β | β Extended |
| Memory Engine | β | β Advanced |
| Multi-tab Terminals | β | β |
| Full-project generation from one prompt | β | β |
| Software Engineering mode | β | β |
| DeepDive β task decomposition | β | β |
| Brutal Penetration Testing | β | β |
| QA & automated test generation | β | β |
| Project Space | β | β |
ποΈ Software Engineering Mode Analyzes your prompt, architects the full solution, and engineers a complete multi-file project in a series of precise, self-correcting steps. One prompt β production-ready codebase.
π― DeepDive Breaks a single complex task into multiple focused sub-tasks, solves each with precision, then assembles the final result. Dramatically higher accuracy on hard problems.
π΄ Brutal Pentester Goes far beyond basic scanning β full kill-chain automation: recon β enumeration β exploitation β post-exploitation β report generation, all in one session.
π§ͺ QA Mode Automatically generates unit tests, integration tests, and edge-case coverage for any codebase it builds or is given.
π§ Contact: aaravprogrammers@gmail.com π GitHub: github.com/aaravshah1311
Contributions are welcome and appreciated! Agent-2-Beta is open to improvements in any area.
- Fork the repository
- Create a feature branch
git checkout -b feature/your-feature-name
- Make your changes and commit with a clear message
git commit -m "feat: add your feature description" - Push to your fork
git push origin feature/your-feature-name
- Open a Pull Request against
main
- π Bug fixes β especially edge cases on Windows/Mac/Linux
- π New tools β additional agent capabilities
- π¨ UI improvements β frontend polish, accessibility
- π Documentation β clearer explanations, more examples
- π Security workflows β new pentest automation patterns
- β‘ Performance β faster startup, lower memory, better streaming
- π Portability β improvements for different platforms or Python versions
- Keep changes focused β one PR per feature/fix
- Follow the existing code style in each file
- Test on at least one platform before submitting
- Add a brief description in the PR explaining what and why
Found a bug or have a feature request? Open an issue β please include your OS, Python version, and the exact error message.
β Star this repo if Agent-2-Beta helps you build or break things.
Built for developers, security researchers, and anyone who wants an AI that actually does things.


