Optimized for High-Performance Operation on Edge Devices (NVIDIA Jetson / Linux)
Ghost Agent is an advanced, autonomous AI operator designed to execute complex coding, research, and system administration tasks with minimal human intervention. It combines System 2 reasoning skills with a robust execution environment to solve problems iteratively, learn from mistakes, and manage its own memory.
Unlike standard chatbots, Ghost Agent employs a hierarchical planner (TaskTree) to break down complex objectives into manageable steps.
- Dynamic Replanning: The agent continuously evaluates its progress. If a strategy fails, it brainstorms alternative approaches (adjusting "temperature" variance).
- Loop Control: Strict checklist enforcement prevents premature stops, while intelligent termination logic ensures it stops exactly when the job is done (no "runaway" loops).
The agent features a battle-tested Python Specialist mode:
- Sanitizer 2.0: A sophisticated heuristic engine that repairs broken LLM code output (e.g., fixing "mashed" imports like
import os\nn, unclosed strings, and hallucinated line continuations) before execution. - Sandboxed Runtime: Executes code in a controlled environment to prevent system damage.
- Persistent Shell: Maintains a stateful terminal session (
tool_shell) for navigating directories and running long-lived commands. - Auto-Correction: If a script fails (non-zero exit code), the agent analyzes the stderr output and attempts to fix the code automatically, up to 3 times per turn.
Ghost Agent remembers you and your project context:
- Smart Memory: Automatically extracts and stores facts, preferences, and project details in a vector-searchable database.
- Profile Memory: Maintains a structured user profile (identity, coding style preferences).
- Skill Memory: Records "Playbooks" and "Lessons" from successful complex tasks. If the agent solves a tricky error, it saves the solution to avoid repeating the mistake in the future.
Built to run efficiently on limited hardware (e.g., 8GB RAM devices):
- Aggressive Garbage Collection: Explicit
malloc_trimcalls to release memory back to the OS. - Context Pruning: Intelligent history compression that keeps relevant context while discarding "bloat".
- Local Vectors: Uses
ChromaDBwith lightweight models for zero-latency recall.
The agent has access to a powerful suite of tools:
| Category | Tools | Capabilities |
|---|---|---|
| File System | read, write, list, move, rename |
Full CRUD operations with auto-correction for recursive listings and binary file handling. |
| Terminal | tool_shell, execute |
Stateful bash commands and isolated Python script execution. |
| Web | web_search, read_web_page |
Tor-proxied searching (junk-filtered) and deep content extraction. |
| System | check_health, manage_tasks |
Self-diagnostics (Docker/Network/Disk) and meta-task management. |
| Memory | recall, learn_skill |
Active memory retrieval and explicit lesson recording. |
- Input: User request is received.
- Context Loading: Relevant memories and skills are retrieved from the Knowledge Base.
- Planning (System 2): The Planner analyzes the state and updates the
TaskTree. - Execution (System 1): The LLM selects tools to execute the immediate next step.
- Sanitization: Code is cleaned and validated.
- Critic Check: Complex code is reviewed for safety.
- Observation: Tool outputs (
stdout,stderr) are captured. - Loop: The cycle repeats until the Planner signals
TaskStatus.DONE. - Auto-Learning: If the task was novel/complex, a lesson is synthesized and stored.
- Linux Environment (Ubuntu 22.04+ recommended)
- Python 3.10+
- OpenAI API Key (or compatible LLM endpoint)
# Clone the repository
git clone https://github.com/ghost-agent/core.git
cd ghost-agent
# Install dependencies
pip install -r requirements.txtRun the main agent loop:
python -m ghost_agent.mainThe project maintains a rigorous test suite to ensure stability.
# Run all tests (async supported)
pytest tests/
# Run specific regression tests
pytest tests/test_mashed_newlines.py # Verifies sanitizer robustness
pytest tests/test_system.py # Verifies system toolsRecent improvements (Feb 2026) have hardened the agent against common failure modes:
- Sanitizer Refinement: Fixed persistent
SyntaxErrorissues caused by LLM escaping (e.g., preserving\nin strings while fixing it in code blocks). - Asyncio Stability: Resolved
Event loop is closedwarnings in sub-process management. - Flow Control: Eliminated "runaway" loops by enforcing strict Planner termination signals.
License: MIT Author: Ghost Team