Skip to main content

โšก 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.

Python Version CLI Framework OpenAI Support Anthropic Support Gemini Support Tests PyPI Version LinkedIn License CI


๐ŸŽฌ 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 โœ… โŒ โœ… โœ…
Mobile / Android (Termux) Support โœ… โŒ โŒ โš ๏ธ
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, and Google gemini-2.5-flash).
  • ๐Ÿ”„ Auto-Provider Fallback: --provider auto chains gemini โ†’ anthropic โ†’ openai and 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.
  • ๐Ÿ“ฑ Full Mobile / Android (Termux) Support: Optimized zero-dependency C-wheel exclusions and pure-Python /proc/meminfo RAM/CPU detection allow pip install nexus-agent-ai to run 100% natively on Android phones inside Termux without C-compilation errors.
  • ๐Ÿ› ๏ธ 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 โ€” powering nexus-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-stream toggle 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 --> Mem["Conversation Memory (Pair-Aware Pruning)"]
    Mem --> Provider["LLM Provider (Local / 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 / run_file"]
        Dispatcher --> WEB["search_web (DuckDuckGo / Offline Cache)"]
        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| Mem
    Provider -->|Final Markdown Text| UI["Rich Terminal UI Panel"]

๐Ÿš€ Getting Started

1. Installation

Install officially via PyPI across any desktop or server (Windows / macOS / Linux):

pip install nexus-agent-ai

๐Ÿ“ฑ Mobile / Android (Termux) Quickstart

Nexus-Agent is fully optimized to run on Android phones via Termux (v2.2.6+). It uses pure-Python spec detection (/proc/meminfo) and automatically skips C/Rust compilation dependencies (psutil, jiter, pydantic-core) by default:

# 1. Update Termux & install Python/Git
pkg update && pkg upgrade -y
pkg install python git -y

# 2. Install Nexus-Agent cleanly from PyPI (fast pure-Python install)
pip install --upgrade nexus-agent-ai

# 3. Launch from anywhere!
nexus-agent

(Optional: If you explicitly want Claude (anthropic) or ChatGPT (openai) models inside Termux, run pkg install rust python-pydantic -y before installing via pip install nexus-agent-ai[all])

๐ŸชŸ Windows Setup & Troubleshooting Guide

If installing or running on Windows 10/11, here are standard resolutions for common Windows & PyPI edge cases:

  1. PowerShell Script Execution Restriction (PSSecurityException): If activating a virtual environment (venv\Scripts\activate) fails due to script execution policies, run this in PowerShell:
    Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process
    
  2. File-Locking Bug ([WinError 2] .deleteme): If upgrading global dependencies triggers Windows binary file-locking errors, upgrade pip first:
    python -m pip install --upgrade pip
    
  3. Executable PATH Isolation Warning (CommandNotFoundException): If nexus-agent is not recognized because AppData\Roaming\Python\Scripts is not on system PATH, launch directly via Python module invocation:
    python -m nexus_agent_ai
    
  4. Official PyPI Package Identifier: Ensure you install using the exact PyPI package name nexus-agent-ai:
    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. Initial Setup & User Guide

When you install nexus-agent-ai, getting started takes less than 30 seconds whether you choose Local Offline Mode (zero cost, private) or Cloud Provider Mode (Claude, OpenAI, Gemini).

A. First-Run Interactive Wizard (Automatic)

On your very first nexus-agent invocation from the terminal, the built-in Interactive Onboarding Wizard launches automatically:

nexus-agent

The wizard auto-detects your system specifications (CPU threads, total RAM, and GPU capabilities on Desktop or Termux), helps you choose a default provider (local, gemini, anthropic, or openai), and saves your preferences cleanly to a local .env file in your workspace or home directory (~/.nexus_agent_initialized).

B. Offline Local Model Download (pull-model)

Nexus-Agent includes built-in support for autonomous local reasoning (LocalQwenProvider) โ€” allowing you to generate, review, and debug code completely offline with zero API keys required.

To download or verify the quantized reasoning model (Qwen2.5-Coder 4-bit AWQ / GGUF engine):

nexus-agent pull-model

What this does:

  • Checks your system environment and verifies huggingface_hub availability.
  • Downloads the optimized local quantized model weights (~4.5 GB) directly to your local cache (~/.cache/huggingface/hub/...).
  • Validates model integrity (verify_download=True) and confirms readiness (โœ… Local Quantized Model Ready).
  • Once pulled, you can run offline any time using: nexus-agent --provider local.

C. Manual API Key Configuration (Cloud Providers)

If you prefer manual configuration or want to use cloud LLMs (Anthropic Claude 3.5 Sonnet, OpenAI GPT-4o, Google Gemini 2.5 Flash), copy the example environment file:

cp .env.example .env

Open .env and set your desired default provider and API keys:

DEFAULT_PROVIDER=gemini
GEMINI_API_KEY=AIzaSy...
ANTHROPIC_API_KEY=sk-ant-...
OPENAI_API_KEY=sk-proj-...

3. Top Starting Commands (Quick Reference)

Here are the essential commands every developer should try first:

โšก 1. Start Interactive Pair-Programming (REPL Mode)

Launch a continuous multi-turn coding session inside your current directory. Ask questions, mention files via @filename, and let the agent autonomously inspect and edit code:

nexus-agent
# Specify provider explicitly:
nexus-agent --provider anthropic
# Enable auto-switching fallback (gemini -> anthropic -> openai):
nexus-agent --provider auto

๐Ÿ’ฌ 2. Instant One-Shot Coding Task (chat)

Execute a direct autonomous engineering instruction without entering REPL mode:

nexus-agent chat "Create a python script primes.py that generates the first 20 prime numbers and run it to verify." --provider gemini

๐Ÿ” 3. Read-Only Code Review (review)

Perform a strict read-only audit of any local code file to identify bugs, security vulnerabilities (SQLi, path traversal), and performance bottlenecks:

nexus-agent review src/utils/config.py --provider local

๐Ÿž 4. Autonomous Error Traceback Repair (debug)

Paste any terminal traceback or error message directly into Nexus-Agent. The agent autonomously reads the problematic file, diagnoses the exact root cause, and applies the corrected fix via write_file:

nexus-agent debug src/app.py --error "ZeroDivisionError: float division by zero when response_times is empty"

๐Ÿ“ 5. Direct Code File Generation (generate)

Instruct the agent to write production-ready code directly to a target destination path:

nexus-agent generate "Create an async web scraper using aiohttp and BeautifulSoup" --output scraper.py

๐Ÿ“ฆ 6. AI Conventional Git Commit (commit)

Analyze your staged or unstaged Git diff (git diff) and autonomously generate a concise conventional commit message (feat:, fix:, refactor:):

nexus-agent commit
# Skip confirmation and commit immediately:
nexus-agent commit --yes

4. Advanced Features & Trace Inspection

Verbose ReAct Trace Engine (--verbose)

See the agent's internal cognitive reasoning ([THINKING] โ†’ [ACTION] โ†’ [OBSERVE]) in real time across every tool execution loop:

nexus-agent chat "Refactor utils.py to use dataclasses" --verbose
[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

@mention File Context Injection

Inside REPL mode or chat prompts, mention any file path using @filename (e.g. @src/agent/core.py). Nexus-Agent automatically attaches the file's exact contents cleanly into its context window before answering.


๐Ÿงช Testing & Verification

Nexus-Agent maintains a 100% passing automated regression & security test suite (36 unit tests) covering all tool dispatchers, AST sandbox boundaries, safe-dunder allowlisting, streaming mechanics, provider mocking, and filesystem handlers:

pytest tests/ -v --tb=short
============================= test session starts =============================
collecting ... collected 36 items

tests/test_audit_fixes.py::test_sandbox_check_blocks_bypass PASSED       [  2%]
tests/test_audit_fixes.py::test_sandbox_check_blocks_introspection_and_gc PASSED [  5%]
tests/test_audit_fixes.py::test_sandbox_check_allows_safe_dunders PASSED   [  8%]
tests/test_audit_fixes.py::test_validate_workspace_path_prefix_containment PASSED [ 11%]
tests/test_audit_fixes.py::test_execute_run_file_sandbox_validation PASSED [ 13%]
tests/test_audit_fixes.py::test_memory_pruning_user_boundaries PASSED    [ 16%]
tests/test_audit_fixes.py::test_search_web_offline_labeling PASSED       [ 19%]
tests/test_audit_fixes.py::test_local_provider_setup_model_verify PASSED [ 22%]
tests/test_audit_fixes.py::test_agent_run_stream_true PASSED             [ 25%]
tests/test_audit_fixes.py::test_onboarding_env_file_path PASSED          [ 27%]
tests/test_local_provider.py::test_local_qwen_provider_init PASSED       [ 30%]
tests/test_local_provider.py::test_local_qwen_provider_convert_tools PASSED [ 33%]
tests/test_local_provider.py::test_local_qwen_provider_setup_model PASSED [ 36%]
tests/test_local_provider.py::test_local_qwen_format_tool_result_message PASSED [ 38%]
tests/test_providers.py::test_anthropic_provider_schema PASSED           [ 41%]
tests/test_providers.py::test_openai_provider_schema PASSED              [ 44%]
tests/test_providers.py::test_gemini_provider_schema PASSED              [ 47%]
tests/test_providers.py::test_provider_tool_result_format PASSED         [ 50%]
tests/test_providers.py::test_fallback_provider_general_exception PASSED [ 52%]
tests/test_providers.py::test_anthropic_complete_and_stream PASSED       [ 55%]
tests/test_providers.py::test_openai_complete_and_stream PASSED          [ 58%]
tests/test_providers.py::test_gemini_complete_and_stream PASSED          [ 61%]
tests/test_tools.py::test_read_file_success PASSED                       [ 63%]
tests/test_tools.py::test_read_file_not_found PASSED                     [ 66%]
tests/test_tools.py::test_list_directory_success PASSED                  [ 69%]
tests/test_tools.py::test_list_directory_not_found PASSED                [ 72%]
tests/test_tools.py::test_search_web PASSED                              [ 75%]
tests/test_tools.py::test_write_file_success PASSED                      [ 77%]
tests/test_tools.py::test_run_code_success PASSED                        [ 80%]
tests/test_tools.py::test_git_status_tool PASSED                         [ 82%]
tests/test_tools.py::test_execute_tool_dispatcher PASSED                 [ 85%]
tests/test_tools.py::test_get_readonly_tools PASSED                      [ 88%]
tests/test_ux_features.py::test_parse_at_mentions PASSED                 [ 91%]
tests/test_ux_features.py::test_smart_startup_project_mode PASSED        [ 94%]
tests/test_ux_features.py::test_status_spinner_helpers PASSED            [ 97%]
tests/test_ux_features.py::test_sqlite_memory PASSED                     [100%]

============================= 36 passed in 5.25s ==============================

๐Ÿ›ก๏ธ Security & Sandbox Best Practices

  • Strict Secret Exclusion: Verified .gitignore blocks .env, .env.local, and .env.*.local.
  • AST Sandbox with Safe-Dunder Allowlist: The run_code sandbox uses AST static analysis to block dangerous imports (os, subprocess, socket, importlib, etc.), execution calls (exec, eval, compile, open, __import__), and introspection attributes (__class__, __bases__, __mro__, __globals__, __builtins__). Safe dunders (__name__, __main__, __file__, __str__, __repr__, __len__, __eq__) are explicitly allowed so standard Python patterns like if __name__ == "__main__": are not blocked.
  • Subprocess Isolation: Code execution (run_code) runs in dedicated subprocess threads with mandatory timeouts to prevent infinite loops.
  • GitHub Actions CI: Automated Python 3.11/3.12/3.13 matrix testing on every push and PR โ€” no manual QA gates needed.

Engineered by Yash Bajpai ยท LinkedIn

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nexus_agent_ai-2.3.1.tar.gz (132.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nexus_agent_ai-2.3.1-py3-none-any.whl (143.5 kB view details)

Uploaded Python 3

File details

Details for the file nexus_agent_ai-2.3.1.tar.gz.

File metadata

  • Download URL: nexus_agent_ai-2.3.1.tar.gz
  • Upload date:
  • Size: 132.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for nexus_agent_ai-2.3.1.tar.gz
Algorithm Hash digest
SHA256 dac8b6f6651744cb9d901815e931f9b65bda58e0d898ee41481ac0db6e92fe5b
MD5 ff61d6487eaf347d31d4af42a762f69c
BLAKE2b-256 9368fe8fb2a321c02878d7d04e297f4546113eca95986efec5e8c82da7166f1f

See more details on using hashes here.

File details

Details for the file nexus_agent_ai-2.3.1-py3-none-any.whl.

File metadata

  • Download URL: nexus_agent_ai-2.3.1-py3-none-any.whl
  • Upload date:
  • Size: 143.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for nexus_agent_ai-2.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cc5b4b76b7ed3180903afa2d4c90021cb77090c6c69607f296f4fd6d36d586ad
MD5 2ec91f277b6c2a5379daa2f67c1773b2
BLAKE2b-256 dedc13451205d49f88ac712f5afbb86aa90b6a835cedb4b301302a26d4027369

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page