A coding agent stripped down to six readable moving parts
An educational single-file harness that exposes how coding agents actually work, using only Python’s standard library and a local Ollama backend.

What it does
mini_coding_agent.py is a self-contained coding agent loop that edits code inside a workspace by calling a local Ollama model. It collects repo context, manages prompts, validates tool calls, and persists memory and transcripts—all without importing anything beyond Python’s standard library. The goal is readability and pedagogy, not production robustness.
The interesting bit
Instead of hiding mechanics inside a framework, the code is organized around six explicit building blocks: live repo context, prompt caching, structured tools with approval gates, context reduction, transcript resumption, and bounded subagent delegation. It is essentially a dissected frog for agent architecture.
Key highlights
- Runs against local Ollama models with zero third-party Python dependencies.
- Risky actions like shell commands and file writes are gated by configurable approval modes (
ask,auto,never). - Sessions are saved as durable JSON transcripts that can be resumed later, paired with a distilled working memory.
- Long outputs are clipped and repeated reads deduplicated to keep prompts within bounds.
- The model is expected to emit
<tool>or<final>tags; reliability varies by model strength.
Caveats
- Explicitly optimized for readability over robustness, so edge-case handling is thin.
- Relies on the local model’s ability to follow strict output formats, which weaker models may ignore.
Verdict
Grab this if you are trying to understand agent internals or teaching the concept. Skip it if you need a battle-tested coding assistant for daily production work.
Frequently asked
- What is rasbt/mini-coding-agent?
- An educational single-file harness that exposes how coding agents actually work, using only Python’s standard library and a local Ollama backend.
- Is mini-coding-agent open source?
- Yes — rasbt/mini-coding-agent is open source, released under the Apache-2.0 license.
- What language is mini-coding-agent written in?
- rasbt/mini-coding-agent is primarily written in Python.
- How popular is mini-coding-agent?
- rasbt/mini-coding-agent has 1.2k stars on GitHub and is currently cooling off.
- Where can I find mini-coding-agent?
- rasbt/mini-coding-agent is on GitHub at https://github.com/rasbt/mini-coding-agent.