Skip to main content

Open source terminal-based AI coding agent built from scratch

Project description

Autopilot — AI Coding Agent (Built from Scratch)

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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for autopilot_agent-1.0.6.tar.gz
Algorithm Hash digest
SHA256 8243385f11f519fd050468b1a8fddf2b9f46acf70f60d815f38b6389da2d7fef
MD5 5a4d0d6f049b34d9f56f9ee7f867c2b5
BLAKE2b-256 7c8afd1c92580042b3a2ffbc276bfb6df597642e31b4ed99364ab8adf18baab4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for autopilot_agent-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 7fb9f57337da67764628caaeb135d5a9d953287a8b9ee883e5bb268612986d3c
MD5 86337dbeb53b56ade05a47e04f62fd7a
BLAKE2b-256 e10a80cbf6c2b35321012cf48111472fa739d8fa36ea556d41cdb51d994091bb

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