Skip to main content
Glama
README.md
# 🌌 Quantum Agent

> **Autonomous Quantum-Inspired Multi-Model Agent Framework with Model Context Protocol (MCP) & Infinite Possibility Search**

[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
[![Python: 3.9+](https://img.shields.io/badge/Python-3.9%2B-brightgreen.svg)](pyproject.toml)
[![MCP Compatible](https://img.shields.io/badge/MCP-Compatible-purple.svg)](https://modelcontextprotocol.io)
[![Zero Dependencies](https://img.shields.io/badge/Dependencies-0%20Required-success.svg)](requirements.txt)

---

## ⚑ What is Quantum Agent?

Traditional AI agents reason in a single, linear thread (step $A \to step\ B \to step\ C$). When they hit an error, rate limit, or complex multi-variable problem, they fail or produce shallow hallucinations.

**Quantum Agent** is built on the core computational principles of quantum computing:
1. **Superposition & Multi-Branch Exploration**: Evaluates $N$ orthogonal hypotheses and possibilities simultaneously rather than sequential trial-and-error.
2. **Constructive & Destructive Interference**: Amplifies high-confidence reasoning paths (Grover's Amplitude Amplification) while pruning dead ends.
3. **Quantum Tunneling**: Detects when reasoning is trapped in local optima or defensive walls, executing high-entropy lateral leaps to bypass barriers.
4. **Infinite Possibility Queue (Zero Limits)**: Built on a high-throughput SQLite WAL state engine capable of evaluating millions of possibilities without memory exhaustion.
5. **Multi-Day/Week Autonomous Persistence**: Run continuous sessions for seconds, hours, days, weeks, or months with live HUD telemetry (`DD:HH:MM:SS`).
6. **Smart AI Rate-Limit Sentinel**: When an AI API hits HTTP 429 or quota limits, the agent freezes active states, calculates backoff cooldown, displays a live resume countdown, and **automatically resumes without losing progress**.
7. **Universal AI Connector**: Connect to **Google Gemini, OpenAI, Anthropic Claude, DeepSeek, Groq, OpenRouter, or local Ollama/LMStudio models**.
8. **Native Model Context Protocol (MCP)**: Exposes quantum reasoning directly to Claude Desktop, Cursor, Antigravity, and Cline.

---

## πŸ“ System Architecture

```mermaid
flowchart TD
    UserTarget["🎯 Target Objective / Problem"] --> CoreRouter["🧠 Quantum Core Router"]
    
    subgraph SuperpositionEngine ["🌌 Superposition & Parallel State Graph"]
        CoreRouter --> B1["Basis Branch: Structural Decomposition"]
        CoreRouter --> B2["Basis Branch: Invariant & Adversarial Inversion"]
        CoreRouter --> B3["Basis Branch: Lateral Mapping"]
        CoreRouter --> Bn["Basis Branch: Infinite Permutation Space..."]
    end
    
    subgraph PersistentCore ["⏱️ Persistence & Resilience Engine (SQLite WAL)"]
        Telemetry["Live HUD Telemetry (DD:HH:MM:SS)"]
        StateDB[("Quantum States & Checkpoint DB")]
        Sentinel["AI Quota Sentinel (Auto-Pause / Auto-Resume)"]
    end

    SuperpositionEngine <--> PersistentCore
    
    Sentinel -- "HTTP 429 / Quota Depleted" --> PauseState["⏸️ Freeze State & Cooldown"]
    PauseState -- "Timer Fires / Quota Restored" --> AutoResume["▢️ Auto-Resume Execution"]
    AutoResume --> SuperpositionEngine
    
    SuperpositionEngine --> Interference["πŸ”¬ Quantum Interference Engine"]
    Interference -- "Sub-threshold / Dead End" --> Prune["πŸͺ“ Destructive Pruning"]
    Interference -- "High Potential" --> GroverAmp["⚑ Amplitude Amplification"]
    
    GroverAmp --> TunnelDetector{"Stagnant in Local Optima?"}
    TunnelDetector -- "Yes" --> TunnelEngine["πŸš‡ Quantum Tunnel Leap (Lateral Bypass)"]
    TunnelEngine --> SuperpositionEngine
    
    TunnelDetector -- "No" --> ConvergenceChecker{"100% Exact Convergence?"}
    ConvergenceChecker -- "Not Yet" --> SuperpositionEngine
    ConvergenceChecker -- "Verified Exact Match" --> Winner["πŸ† Wavefunction Collapse: Optimal Solution"]
```

---

## πŸš€ Quick Start

### 1. Installation

Quantum Agent core requires **zero third-party dependencies**! It runs straight out of the box on Python 3.9+:

```bash
git clone https://github.com/your-username/quantum-agent.git
cd quantum-agent
```

Optional editable install:
```bash
pip install -e .
```

### 2. Configure AI Providers (Any AI)

Set the API key for your preferred provider:

```bash
# Google Gemini
export GEMINI_API_KEY="your-gemini-key"

# OpenAI
export OPENAI_API_KEY="your-openai-key"

# Anthropic Claude
export ANTHROPIC_API_KEY="your-anthropic-key"

# DeepSeek
export DEEPSEEK_API_KEY="your-deepseek-key"

# Groq
export GROQ_API_KEY="your-groq-key"

# Local Ollama (No API Key Required!)
# Simply have Ollama running at http://localhost:11434
```

Check detected providers anytime:
```bash
python3 -m quantum_agent.cli providers
```

---

## πŸ’» CLI Usage

### Basic Run
```bash
python3 -m quantum_agent.cli run \
  --target "Build a thread-safe lock-free queue in Python with zero memory leak" \
  --intensity FAST
```

### Unbounded High-Intensity Run (Infinite Possibilities)
```bash
python3 -m quantum_agent.cli run \
  --target "Synthesize a robust consensus algorithm resilient to 33% Byzantine failures" \
  --intensity HIGH \
  --provider gemini \
  --model gemini-2.5-flash
```

### Resume a Past Session
```bash
python3 -m quantum_agent.cli run \
  --target "Resuming research problem" \
  --session qsession-edaae5eb
```

### Inspect Sessions & Telemetry
```bash
# List all active and completed sessions
python3 -m quantum_agent.cli status

# Deep-dive into a specific session
python3 -m quantum_agent.cli status --session qsession-edaae5eb
```

---

## πŸ”Œ Model Context Protocol (MCP) Integration

Quantum Agent is a fully compliant MCP Server over `stdio`. It exposes tools directly to Claude Desktop, Cursor, Antigravity, and Cline.

### Available MCP Tools:
- `quantum_solve`: Solve high-complexity problems with superposition search and exact verification.
- `quantum_explore_branches`: Decompose a problem into orthogonal quantum basis vectors.
- `quantum_tunnel`: Force a lateral quantum leap to bypass an intractable defensive wall or bottleneck.
- `quantum_session_status`: Retrieve live uptime and state metrics for long-running jobs.

### Configuration for Claude Desktop / Cursor / Antigravity

Add this to your MCP configuration file (`claude_desktop_config.json` or `mcp_settings.json`):

```json
{
  "mcpServers": {
    "quantum-agent": {
      "command": "python3",
      "args": ["-m", "quantum_agent.cli", "mcp"],
      "cwd": "/path/to/quantum-agent",
      "env": {
        "GEMINI_API_KEY": "your-key-here"
      }
    }
  }
}
```

---

## πŸ“‚ Project Structure

```
quantum-agent/
β”œβ”€β”€ README.md                  # Comprehensive Documentation & Guide
β”œβ”€β”€ LICENSE                    # MIT License
β”œβ”€β”€ pyproject.toml             # Modern packaging standard
β”œβ”€β”€ requirements.txt           # Zero required runtime dependencies
β”œβ”€β”€ quantum_agent/
β”‚   β”œβ”€β”€ cli.py                 # Rich CLI with live HUD & subcommands
β”‚   β”œβ”€β”€ core/
β”‚   β”‚   β”œβ”€β”€ superposition.py   # Multi-branch basis expansion
β”‚   β”‚   β”œβ”€β”€ interference.py    # Amplitude amplification & pruning
β”‚   β”‚   β”œβ”€β”€ tunneling.py       # Local optima escape & lateral leaps
β”‚   β”‚   └── convergence.py     # 100% exact solution verifier
β”‚   β”œβ”€β”€ engine/
β”‚   β”‚   β”œβ”€β”€ persistence.py     # SQLite WAL crash-resilient storage
β”‚   β”‚   β”œβ”€β”€ telemetry.py       # Live timer HUD (DD:HH:MM:SS)
β”‚   β”‚   └── scheduler.py       # Autonomous long-run orchestrator
β”‚   β”œβ”€β”€ providers/
β”‚   β”‚   β”œβ”€β”€ base.py            # LLM interface & response dataclass
β”‚   β”‚   β”œβ”€β”€ universal.py       # Universal AI adapter (Gemini, Claude, GPT, Ollama)
β”‚   β”‚   └── rate_limiter.py    # Rate-limit backoff & auto-resume
β”‚   └── mcp/
β”‚       β”œβ”€β”€ server.py          # Standard JSON-RPC 2.0 MCP server
β”‚       └── tools.py           # Quantum Agent MCP tools
β”œβ”€β”€ examples/
β”‚   β”œβ”€β”€ solve_coding_problem.py
β”‚   └── mcp_client_example.py
└── tests/
    β”œβ”€β”€ test_superposition.py
    β”œβ”€β”€ test_persistence.py
    └── test_mcp_server.py
```

---

## πŸ›‘οΈ License

This project is licensed under the **MIT License**. See [LICENSE](LICENSE) for details.

TDQS

C2.7/5.0

Scored across 7 tools

Disambiguation2/5

quantum_init_task and quantum_explore_branches both claim to decompose a problem into orthogonal basis states, differing only by a 'host AI control' nuance, and quantum_solve vs. quantum_step (autonomous vs. host-driven evaluation) overlaps heavily. quantum_tunnel and quantum_system_info are distinct, but the core workflow tools have unclear boundaries that will cause misselection.

Naming Consistency4/5

All tools use a uniform snake_case quantum_ prefix, which is highly predictable. The only minor deviation is mixing verb-style (step, solve, tunnel, init_task) with noun-style (session_status, system_info) suffixes, which is still readable.

Tool Count4/5

Seven tools is a well-scoped size for a quantum-search workflow covering init, explore, step, solve, status, info, and tunnel. The count would be ideal if the near-duplicate init/explore pair were consolidated.

Completeness3/5

The set covers initialization, exploration, iteration, solving, and status inspection, but has no session termination/reset, no session listing, and no explicit result/answer retrieval endpoint β€” only status queries. These gaps force agents to leave sessions dangling and infer outcomes from status.

Maintenance

ActivityMaintained
ResponsivenessSyncing