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

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.0.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.0-py3-none-any.whl (93.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: autopilot_agent-1.0.0.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.0.tar.gz
Algorithm Hash digest
SHA256 9e5067fbaa4de1d64c44641e4c3d53be87c9ff318306ecd19530e816eb8814fe
MD5 784f0174d591b5bac74fb5dc75c3efd0
BLAKE2b-256 a9ff28cebd21cb6661450229cf0b67df1e15b54eebd6fa6082bddf15df954a7a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for autopilot_agent-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9c6c290688dc77e2054029a0d9c07bd4ec10ce3e7ac90f45b3cba65d126502c4
MD5 e97cccc518c6ac74e7459363d48bcd71
BLAKE2b-256 85d3187660334b1b06f1d3b8c386a0676a845cb5d2b94aed661d121dcc6507df

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