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

Uploaded Python 3

File details

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

File metadata

  • Download URL: autopilot_agent-1.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 0c8c41c57ab2ca05974654b3c67788fff081de77a43f6add35649e0646b4b9e3
MD5 deabb50e62f635481e064d06e4880106
BLAKE2b-256 52ab2498ce1716602bf027b1489bb6d67fe82c55521dcffbe0bbb63e54a11773

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for autopilot_agent-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c1ea01255f39ee4691f80dc3499ecf133b45ee70bb995cee244b6e0715430193
MD5 eca7eb7884967ed2d9c2e7c1ff648d20
BLAKE2b-256 99796fbdfb04e717743e8ceeedd57e702cd224a622d3fe9ca4f614f584b9b09c

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