Skip to main content

Open source terminal-based AI coding agent built from scratch

Project description

Autopilot — AI Coding Agent (Built from First Principles)

Autopilot is a terminal-based AI agent that can understand entire codebases, execute complex multi-step tasks, manage long-running workflows, and operate autonomously within controlled limits.

It is built entirely in Python without using frameworks like LangChain, focusing on control, transparency, and reliability.


System Architecture

System Architecture


Overview

This project implements a complete agent system from scratch, including:

  • Custom agent loop
  • Tool calling system
  • Context management (compaction + pruning)
  • Session and checkpoint persistence
  • Sub-agents for complex workflows
  • MCP-based extensibility
  • Safety and approval controls

The system is designed to run continuously until tasks are completed, while maintaining correctness and avoiding uncontrolled behavior.


Features

Core Functionality

  • Interactive CLI mode for continuous workflows
  • Single-run mode for automation tasks
  • Streaming and non-streaming LLM responses
  • Multi-turn reasoning with tool execution
  • Retry mechanism with exponential backoff
  • Configurable model, temperature, and behavior

Agent Loop

A fully custom-built execution loop:

  • Interprets user intent
  • Breaks tasks into steps
  • Selects tools
  • Executes actions
  • Updates context dynamically

Runs until the task is completed or safely terminated.


Tool System

The agent interacts with the environment strictly through tools.

File Operations

  • read_file, write_file, edit_file

Search & Navigation

  • list_dir, glob, grep

Execution

  • shell

Web

  • web_search, web_fetch

Planning & Memory

  • todos, memory

Context Management

Built for large codebases + long sessions:

  • Compaction → compress past interactions
  • Pruning → remove irrelevant tool outputs
  • Token usage tracking
  • Maintains continuity without overflow

Safety and Approval System

  • Approval policies: auto, on-request, never, yolo
  • Risk-aware execution
  • Path validation
  • Controlled shell access
  • User confirmation for critical actions

Session & Checkpoints

  • Save and resume sessions
  • Create checkpoints mid-task
  • Restore any previous state
  • Persistent execution continuity

Subagents

  • Spawn specialized agents for complex workflows
  • Isolated execution contexts
  • Useful for large refactors, audits, deep analysis

MCP Integration

  • Connect external tools dynamically
  • Supports stdio + HTTP/SSE
  • Extend capabilities without changing core

Loop Detection

  • Detects stuck/repeating behavior
  • Prevents infinite loops
  • Self-corrects execution

Terminal UI

Built using Rich + prompt_toolkit:

  • Streaming responses
  • Structured tool output
  • Interactive commands

Currently Supported Commands

/help /config /model /tools /mcp /stats /save /resume /checkpoint /restore /history /exit


Tech Stack

  • Pure Python without Langchain (completely built from scratch!)

High-Impact Use Cases

1. Full Codebase Refactoring

“Migrate this entire project from JavaScript to TypeScript and fix all type errors”

The agent:

  • understands project structure
  • updates configs + files
  • fixes imports and types
  • ensures consistency across the codebase

2. End-to-End Feature Implementation

“Add authentication with JWT + refresh tokens”

The agent:

  • analyzes architecture
  • creates middleware & routes
  • updates database logic
  • wires everything together

3. Deep Debugging & Root Cause Analysis

“Find why this API randomly fails in production”

The agent:

  • traces execution paths
  • inspects related modules
  • identifies hidden issues
  • suggests and applies fixes

Setup

Install

pip install autopilot-agent

Or install directly from PyPI: 👉 https://pypi.org/project/autopilot/

Configure

Create a .env file in your project root:

Option 1 — OpenRouter

OPENROUTER_API_KEY=your_api_key
BASE_URL=https://openrouter.ai/api/v1

Option 2 — Local Model (Ollama / LMStudio, etc.)

BASE_URL=http://localhost:11434/v1

Run

Just type autopilot in your terminal and see the magic unfold.

Project details


Download files

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

Source Distribution

autopilot_agent-1.0.3.tar.gz (78.7 kB view details)

Uploaded Source

Built Distribution

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

autopilot_agent-1.0.3-py3-none-any.whl (93.7 kB view details)

Uploaded Python 3

File details

Details for the file autopilot_agent-1.0.3.tar.gz.

File metadata

  • Download URL: autopilot_agent-1.0.3.tar.gz
  • Upload date:
  • Size: 78.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for autopilot_agent-1.0.3.tar.gz
Algorithm Hash digest
SHA256 d85951201f36b475e4f76de38999ad0ad9e9d2723931f7560675cd8416cac90c
MD5 fdf896cfd4a2d407334185886f790cc2
BLAKE2b-256 43ee4dd64077dc58f5747e43bab3c388233aeff72405cb767dc9efc7ee510669

See more details on using hashes here.

File details

Details for the file autopilot_agent-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for autopilot_agent-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d26b81c095950115a88b68e17f1faabc9b0ae4fd127eb7ceca7502398a24982a
MD5 cafab2049a86920d574953461d66f276
BLAKE2b-256 2c3b56576bf6c9d35e2a07ea38d5fb1d1279ec3520f31cdaef19b465b8c38bd3

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