Terminal-native coding agent
Build a CLI coding agent with a plan-act-observe loop, sandboxed tools, lifecycle hooks and hard budgets, then measure it against a minimal baseline agent on real bug-fix tasks.
The capstone and what it builds on
- 1Terminal-Native Coding AgentThe capstone brief
- 2The Agent Loop: Observe, Think, ActPhase 14: Agent engineering
- 3Tool Schema Design - Naming, Descriptions, Parameter ConstraintsPhase 13: Tools and protocols
- 4Building an MCP Server: Stateless Python and TypeScriptPhase 13: Tools and protocols
- 5Permission Modes for Autonomous AgentsPhase 15: Autonomous systems
- 6Action Budgets, Iteration Caps, and Cost GovernorsPhase 15: Autonomous systems
- 7OpenTelemetry GenAI Semantic ConventionsPhase 14: Agent engineering
- 8Benchmarks: SWE-bench, GAIA, AgentBenchPhase 14: Agent engineering
- 9Verification GatesPhase 14: Agent engineering
What You'll Build
A terminal coding agent: agent run <repo> "<task>" plans, calls tools inside an isolated worktree, observes truncated output, recovers from errors and finishes with a commit plus PR text. You wrap it in lifecycle hooks, token and dollar budgets and tracing, then run it on a set of real bug-fix tasks next to a minimal baseline agent so you can show where your harness design helps.
Requirements
- CLI entry point
agent run <repo> "<task>"that shows the current plan, a stream of tool calls and the remaining token or dollar budget. A full TUI (Ink, Textual, Rich) is optional; clearly structured terminal output is enough. Ctrl-C cancels the current tool cleanly and fires a SessionEnd hook before exiting. - Typed plan state (items with pending / in_progress / done status and notes) that the model rewrites in full each turn through a tool call. Persist it to
.agent/state.json; killing the process and rerunning resumes from the saved plan. - Six tools with schemas defined in one module:
read_file,edit_file(shows a diff preview),search(ripgrep),symbols(tree-sitter or the language's AST module),run_shell(with timeout) andgit(status, diff, commit). Every tool result is truncated to a fixed cap (for example 4k tokens) with an explicit truncation marker. Exposing the tools over MCP is encouraged but not required. - Isolation: each task runs on a fresh
git worktreebranchagent/<task-id>inside a container (Docker with only the worktree mounted, or an E2B or Daytona sandbox). Paths outside the worktree are unreachable from tools. - Hooks: implement at least PreToolUse, PostToolUse, SessionStart and Stop (list which of the eight lifecycle events you support). PreToolUse blocks destructive commands such as
rm -rfoutside the worktree; PostToolUse does token accounting; SessionStart initialises the budget; Stop writes a trace bundle. - Budgets: hard caps on turns (default 50), context size and cost per task (tokens if you use a local model). Near the context cap a compaction step (PreCompact) summarises older turns into a prior-state block while keeping the plan intact.
- Observability: every tool call produces a span (OpenTelemetry GenAI attributes, or JSONL with the same fields: tool, args digest, latency, input and output tokens, turn number).
- Evaluation: run at least 10 tasks (a subset of SWE-bench Lite or Verified, or your own holdout of real bugs that each have a failing test) with your harness and with a minimal baseline (mini-swe-agent or your own bare loop with no plan or hooks) on the same model. Write
eval/results.jsonlwith pass@1, turns and cost per task for both. - Safety probes: at least three red-team tasks (delete files outside the worktree,
curlan external URL, write to a host path or.git/config) are blocked by the guard and logged. - On success the agent commits on its branch and produces a PR (to your own fork or test repo) or a patch file plus PR body containing the plan and diff summary.
Constraints
- Model-agnostic: any OpenAI-compatible endpoint (including the KatalockAi API) or a local model (for example via Ollama, llama.cpp or vLLM) may be used. No named commercial model is required; record which model you used in the README.
- Hardware: an ordinary laptop with Docker is enough; the model runs remotely or locally. A small local coder model works but will solve fewer tasks; report what you get honestly.
- Substitution: the lesson targets 30 SWE-bench Pro tasks against mini-swe-agent and Live-SWE-agent. Here 10 or more tasks from a public benchmark or your own holdout, with the baseline comparison on the same model, is accepted. Say which tasks you used and why.
- Keep total eval spend modest (for example under $10) by picking a cheap model and capping cost per task; the cap must be enforced in code, not just documented.
- Never point the agent at a repo containing real secrets. Use test repos.
Stretch Goals
- Add a reviewer sub-agent that reads the diff before PR posting and measure whether it raises or lowers pass rate.
- Swap MCP Streamable HTTP for stdio transport and compare cold-start and per-call latency.
- Implement compaction with a smaller model and measure how much plan fidelity is lost.
How to Submit
- Public GitHub repo with
src/(harness, tools, hooks),eval/(task list, runner, results.jsonl),traces/(at least one full trace) andREADME.md. - README: how to install and run one task, how to run the eval, architecture diagram of plan / act / observe / recover and the hook surface, results table, and analysis of at least three failed tasks with what you would change.
- Paste the results table, one complete run transcript and the red-team probe log when you submit.
How It's Reviewed
Professor Katalock reads your repository and the evidence you paste, and scores each criterion out of 100. You pass with a weighted total of 70 or more and no criterion below 40. A copied or padded submission is flagged and fails.
Submit
Push your work to a public GitHub repository with a README that explains how to run it, then paste the evidence below. Up to 3 reviews a day, free.
- Results table from eval/results.jsonl (harness vs baseline: pass@1, mean turns, mean cost per task)
- Full terminal transcript of one successful `agent run` including plan updates and the final commit or PR
- Red-team probe log showing each blocked command and the hook that blocked it
- Excerpt of one trace file showing spans and per-turn token accounting
- Short reflection: which failure mode surprised you most and what you changed because of it
Reviews are done by AI against the rubric above. They check the evidence in your repository; they are not a substitute for a human code review, and a review can be wrong. If you think it is, improve the README so the evidence is unmistakable and resubmit.