Quantum Agent
# π Quantum Agent
> **Autonomous Quantum-Inspired Multi-Model Agent Framework with Model Context Protocol (MCP) & Infinite Possibility Search**
[](LICENSE)
[](pyproject.toml)
[](https://modelcontextprotocol.io)
[](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
Scored across 7 tools
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.
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.
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.
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.