Autonomous terminal-first AI software engineering assistant with ReAct tool loops and multi-provider fallback
Project description
โก Nexus-Agent: Autonomous Agentic AI Coding Assistant
A production-grade, terminal-first AI Software Engineering Companion powered by autonomous ReAct tool loops and multi-provider backend switching.
๐ฌ Live Demo Recording
https://github.com/user-attachments/assets/73e78850-8669-40e9-aec3-3a355e975c1f
๐ Overview
Nexus-Agent is an autonomous command-line coding agent designed to pair-program with developers directly inside their local workspace. Built from the ground up to showcase modern Agentic AI Engineering principles, Nexus-Agent doesn't just generate textโit autonomously inspects files, modifies codebases, executes scripts inside secure local sandboxes, searches live web documentation, and inspects Git repositories.
Built with a clean ReAct (Reasoning + Acting) cognitive architecture, Nexus-Agent reasons step-by-step after every tool execution before deciding its next move.
โ Why Nexus-Agent?
Unlike cloud-dependent tools like GitHub Copilot CLI, Nexus-Agent is built for offline-capable, cost-zero local execution. V2 will integrate a custom-trained 124M parameter LLM as the local backend โ enabling completely private, zero-latency execution with no external API key required.
๐ How Nexus-Agent Compares
| Feature | Nexus-Agent | Copilot CLI | Cursor | Aider |
|---|---|---|---|---|
| Multi-Provider Support (Claude, Gemini, OpenAI) | โ | โ | โ | โ |
| Auto-Provider Fallback (rate limit resilient) | โ | โ | โ | โ |
| Autonomous Local Tool Execution | โ | โ | โ | โ |
| Real-Time Token & Cost Tracking | โ | โ | โ | โ |
@mention File Context Injection |
โ | โ | โ | โ |
| Smart Project vs. Global Detection | โ | โ | โ | โ |
AI-Powered agent commit |
โ | โ | โ | โ |
๐ฅ Key Architectural Highlights
- ๐ง Autonomous ReAct Loop: Implements multi-step cognitive reasoning (
Thought โ Action โ Observation โ Repeat), allowing the agent to solve complex multi-file engineering tasks independently (up to 10 autonomous tool iterations per query). - ๐ Universal Multi-Provider Backend: Abstracted provider layer supporting seamless switching between industry-leading LLMs (
OpenAI GPT-4o,Anthropic claude-sonnet-4-6, andGoogle gemini-2.5-flash). - ๐ Auto-Provider Fallback:
--provider autochainsgemini โ anthropic โ openaiand switches silently on rate limit or auth failure, with a clean[WARN]message. - ๐ฐ Real-Time Dynamic Cost Tracker: Live token computation engine that calculates exact input/output token expenditure and monetary cost in real time per session.
- ๐ First-Run Onboarding Wizard: Auto-detects first launch, guides through API key setup, detects RAM/CPU/GPU specs, and suggests optimal local model for V2.
- ๐ ๏ธ Comprehensive Developer Toolset:
read_file: Safely parses local file contents to prevent hallucinations.write_file: Actively writes or overwrites code files with automatic directory creation.list_directory: Recursively maps workspace architecture.run_code: Executes arbitrary Python code inside isolated subprocesses with strict execution timeout enforcement (CODE_EXECUTION_TIMEOUT = 10s).search_web: Queries live DuckDuckGo indexes for real-time API docs and error debugging.git_status: Monitors uncommitted workspace changes and diff statistics.git_diff+git_commit: Reads full staged diff and commits โ poweringnexus-agent commit.
- ๐จ Rich Syntax-Highlighted UI: Beautiful terminal display powered by
Rich, featuring markdown rendering and ReAct trace badges ([THINKING],[ACTION],[OBSERVE]). - โก Streaming CLI Response: Interactive streaming text output with
--no-streamtoggle support.
๐๏ธ System Architecture
nexus-agent/
โโโ pyproject.toml โ Package metadata & Typer binary entry point (`nexus-agent` / `agent`)
โโโ requirements.txt โ Core dependencies (Typer, Rich, OpenAI, Anthropic, Gemini, DDGS)
โโโ .env.example โ Environment variable configuration template
โโโ src/
โโโ agent/
โ โโโ core.py โ Autonomous ReAct agent loop & system instructions
โ โโโ memory.py โ Sliding-window conversation buffer (max 20 turns)
โ โโโ tools.py โ Universal tool schema & execution handlers
โโโ cli/
โ โโโ app.py โ Typer CLI command definitions (chat, repl, review, debug, generate, commit)
โ โโโ display.py โ Rich terminal UI components & live cost tracking
โ โโโ onboarding.py โ First-run wizard (API keys, system spec detection, provider setup)
โโโ providers/
โ โโโ base.py โ Abstract BaseProvider interface & RateLimitError
โ โโโ fallback_provider.py โ Auto-fallback chain (gemini โ anthropic โ openai)
โ โโโ openai_provider.py โ OpenAI backend implementation
โ โโโ anthropic_provider.py โ Anthropic claude-sonnet-4-6 backend implementation
โ โโโ gemini_provider.py โ Google gemini-2.5-flash backend implementation
โโโ utils/
โโโ config.py โ Environment loader & dynamic token cost calculator
Cognitive ReAct Workflow
graph TD
User["Developer Query"] --> Core["Agent ReAct Loop"]
Core --> Provider["LLM Provider (OpenAI / Claude / Gemini)"]
Provider -->|Tool Call Requested| Dispatcher["Tool Execution Dispatcher"]
Provider -->|Rate Limit| Fallback["FallbackProvider (auto-switch)"]
Fallback --> Provider
subgraph Sandbox Tools
Dispatcher --> RF["read_file / list_directory"]
Dispatcher --> WF["write_file"]
Dispatcher --> RC["run_code (Subprocess Timeout)"]
Dispatcher --> WEB["search_web (DuckDuckGo)"]
Dispatcher --> GIT["git_status / git_diff / git_commit"]
end
RF --> Obs["Observation Buffer"]
WF --> Obs
RC --> Obs
WEB --> Obs
GIT --> Obs
Obs -->|Append Tool Result| Core
Provider -->|Final Markdown Text| UI["Rich Terminal UI Panel"]
๐ Getting Started
1. Installation
Install officially via PyPI:
pip install nexus-agent-ai
Or clone for local development:
git clone https://github.com/Yash1bajpai/nexus-agent.git
cd nexus-agent
pip install -e .
2. API Key Configuration
Copy the example environment template and add your preferred API keys:
cp .env.example .env
Open .env and configure your keys:
DEFAULT_PROVIDER=gemini
GEMINI_API_KEY=AIzaSy...
ANTHROPIC_API_KEY=sk-ant-...
OPENAI_API_KEY=sk-proj-...
First run auto-wizard: On the very first
nexus-agentlaunch, an interactive onboarding wizard will guide you through key setup automatically.
3. Usage
Interactive Multi-Turn REPL Mode (Default)
Start a continuous pair-programming session directly by invoking nexus-agent (or agent) without any subcommands:
nexus-agent
# Or with flags: nexus-agent --provider anthropic
# Auto-fallback mode: nexus-agent --provider auto
Single-Turn Coding (chat)
Execute an instant autonomous coding task directly from your terminal:
nexus-agent chat "Create a python script fib.py that prints the first 10 Fibonacci numbers and run it to verify." --provider openai
Automated Code Review (review)
Inspect local code files for bugs, security vulnerabilities, and clean coding practices:
nexus-agent review src/utils/config.py --provider gemini
Autonomous Error Debugging (debug)
Feed error tracebacks directly into Nexus-Agent to diagnose root causes and write fixes:
nexus-agent debug src/app.py --error "AttributeError: 'NoneType' object has no attribute 'stream'"
# With verbose ReAct trace:
nexus-agent debug src/app.py --error "KeyError: 'model'" --verbose
Direct File Generation (generate)
Generate complete code files autonomously and save them to your workspace:
nexus-agent generate "Create an async web scraper using aiohttp and BeautifulSoup" --output scraper.py
AI Commit Message (commit)
Reads your git diff, generates a meaningful conventional commit message, asks for confirmation, then commits:
nexus-agent commit
# Skip confirmation prompt:
nexus-agent commit --yes
Verbose ReAct Trace
See the agent's full reasoning process โ thinking, actions, and observations:
nexus-agent chat "Refactor utils.py to use dataclasses" --verbose
Output looks like:
[THINKING] I need to read the file first to understand the current structure
[ACTION] read_file(path="utils.py")
[OBSERVE] Done (0.1s) โ class Config: | def load(): | ...
[THINKING] Now I'll rewrite using dataclasses and write_file
[ACTION] write_file(path="utils.py", content="...")
[OBSERVE] Done (0.0s) โ Successfully wrote 847 characters to utils.py
๐งช Testing & Verification
Nexus-Agent maintains a 100% passing unit test suite covering all tool dispatchers, filesystem handlers, UX features, and subprocess safety boundaries:
pytest tests/ -v
============================= test session starts =============================
collecting ... collected 19 items
tests/test_providers.py::test_anthropic_provider_schema PASSED [ 5%]
tests/test_providers.py::test_openai_provider_schema PASSED [ 10%]
tests/test_providers.py::test_gemini_provider_schema PASSED [ 15%]
tests/test_providers.py::test_provider_tool_result_format PASSED [ 21%]
tests/test_tools.py::test_read_file_success PASSED [ 26%]
tests/test_tools.py::test_read_file_not_found PASSED [ 31%]
tests/test_tools.py::test_list_directory_success PASSED [ 36%]
tests/test_tools.py::test_list_directory_not_found PASSED [ 42%]
tests/test_tools.py::test_search_web PASSED [ 47%]
tests/test_tools.py::test_write_file_success PASSED [ 52%]
tests/test_tools.py::test_run_code_success PASSED [ 57%]
tests/test_tools.py::test_git_status_tool PASSED [ 63%]
tests/test_tools.py::test_execute_tool_dispatcher PASSED [ 68%]
tests/test_ux_features.py::test_parse_at_mentions PASSED [ 73%]
tests/test_ux_features.py::test_smart_startup_project_mode PASSED [ 78%]
tests/test_ux_features.py::test_status_spinner_helpers PASSED [ 84%]
tests/test_ux_features.py::test_sqlite_memory PASSED [ 89%]
============================= 19 passed in 4.28s ==============================
๐ก๏ธ Security & Sandbox Best Practices
- Strict Secret Exclusion: Verified
.gitignoreblocks.env,.env.local, and.env.*.local. - Subprocess Isolation: Code execution (
run_code) runs in dedicated subprocess threads with mandatory timeouts to prevent infinite loops.
Engineered by Yash Bajpai ยท LinkedIn
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nexus_agent_ai-2.2.1.tar.gz.
File metadata
- Download URL: nexus_agent_ai-2.2.1.tar.gz
- Upload date:
- Size: 105.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
292eea1cf2ceaa7b13cd0aa33476eb547cba125e5e88db48c064a1b481f78b28
|
|
| MD5 |
5431a18e29f5de4e2ee97c182742cfb4
|
|
| BLAKE2b-256 |
a766935a1c910e29f3518ee39db02bb2a3603114cfde8d4c6354eeb52df4bc10
|
File details
Details for the file nexus_agent_ai-2.2.1-py3-none-any.whl.
File metadata
- Download URL: nexus_agent_ai-2.2.1-py3-none-any.whl
- Upload date:
- Size: 120.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6268cbdce122550ccc9e13e3527f742eef5b9b828bae3d07dc4d09d50af255ba
|
|
| MD5 |
46e3d2f9e90dc05d13bc82392531dc95
|
|
| BLAKE2b-256 |
f2ec67d7ca9e90654e2a4f7f30b96b4394fc6e0da8e05ee3c96611b5dd481322
|