A terminal coding agent built from scratch.
No LangChain. No agent SDKs. Just a loop, four tools, and a healthy fear of rm -rf.
the agent, mid-task
Ask it something about your project. It reads files, runs commands, edits code and answers, deciding each step on its own.
you> what version is in package.json? bump the patch number.
π§ bash({"command":"ls -R","timeout":120}) β β
5 lines
π§ read({"path":"package.json","offset":1,"limit":200}) β β
6 lines
π§ edit({"path":"package.json","oldText":" \"version\": \"0.1.0\",","newText":" \"version\": \"0.1.1\","}) β β
1 lines
The package version has been bumped from **0.1.0** to **0.1.1** in `package.json`.
[tokens: 4,191 in, 254 out]
- π Streaming tool-calling loop, written by hand
- π οΈ 4 tools, same as Pi:
readΒ·writeΒ·editΒ·bash - π Any OpenAI-compatible model: OpenAI, Ollama (local or cloud), and more
- π‘οΈ Asks before running shell commands, validates every tool input with zod
- π
AGENTS.mdsupport for per-project instructions
git clone https://github.com/javin1106/agent-core.git && cd agent-core
npm install
cp .env.example .env # pick a model: Ollama works for free
npm run dev # add "-- --yolo" to skip command approvalsflowchart LR
U([you]) <--> CLI["cli.ts<br/>terminal UI"]
CLI -- your message --> A["agent.ts<br/>the loop"]
A -. events .-> CLI
A --> M["call-model.ts<br/>retry Β· resume Β· continue"]
M --> P["ai/openai.ts<br/>LLMProvider"]
P <--> LLM[(any OpenAI-<br/>compatible model)]
A --> T["tools/<br/>read Β· write Β· edit Β· bash"]
T <--> FS[(your project)]
The loop, in four lines:
ask the model β it wants tools? β run them, add the results β repeat
β no
final answer β
The agent only emits events; the CLI just draws them. Swapping in a TUI or a web UI means writing a new renderer, not touching the agent.
- Retries with exponential backoff (1s β 2s β 4s β 8s)
- Dropped connection mid-reply? It resumes the reply instead of restarting
- Hit the length limit? It asks for the rest automatically
- Ctrl+C stops the current task, not the app
- Failed turn? Finished tool steps are kept, so it never forgets a file it changed
- Token + cost tracking per turn and per session
15 small coding tasks (create, edit, search, run), each in a fresh temp folder, checked automatically. Run it yourself with npm run eval -- --runs 3.
| Model | Pass rate | Model calls / task | Tokens / task | Time / task |
|---|---|---|---|---|
gpt-oss:120b (Ollama Cloud) |
93% (42/45, 3 runs) | ~3.1 | ~3.3K | ~2.9s |
- Agent loop, tools, zod validation,
AGENTS.md - Retries, resume, auto-continue, Ctrl+C, cost tracking
- Eval suite (
npm run eval) and importable library (src/index.ts) - Context compaction + saved sessions (
--continue) - Publish to npm, then a proper TUI
Built to learn how agents really work, one loop at a time.

