agent686
A small coding agent for Debian-class Linux: one binary, six tools, line mode.
Built because the existing harnesses are TypeScript bundles that either need a modern CPU or a Node runtime. This one is pure Rust with no runtime dependency, and it builds for whatever machine you are on.
4.0 MiB x86_64 glibc build, GLIBC_2.34 required
4.1 MiB x86_64 static musl build, no libc dependency
~1 ms startup
Build
./comp.sh # plan tuned for this CPU (the default)
./comp.sh --portable # plan for any 64-bit CPU (x86-64 / SSE2)
./comp.sh --run # build here, then run the glibc gate
./comp.sh --musl --run # static build: runs on Debian 10 and anything newer
./comp.sh --old-glibc # container recipe for an older glibc
comp.sh reports the distro, libc and glibc version, the x86-64 level of this
CPU, the target triple, and the cfg values the code will see. By default it
targets this CPU (-C target-cpu=native), which is the right build when the
binary runs here; --portable targets the architecture floor instead. If the
binary is for another machine, use --portable or run comp.sh on that machine
— a native build fails with an illegal instruction on older chips.
A glibc build is bounded by the glibc symbols it references, not by this
machine's glibc version: check-glibc.sh reports the real floor (e.g.
GLIBC_2.34). Static musl removes the floor entirely, and building inside an
older Debian image lowers it.
The commands above produce target/<triple>/release/agent686; replace
./agent686 below with that path.
The gate matters: the dev host's glibc is newer than the target's, so a dependency can silently raise the required symbol version.
Run
export OPENCODE_API_KEY=... # or write it to ~/.config/agent686/key
./agent686 "make a calculator in C" # one turn, then exit
./agent686 # interactive
./agent686 -c # continue the most recent session
./agent686 --session <id> # resume it, or create it if the id is new
./agent686 --list # id, model, message count, age
./agent686 --list --json # machine-readable
./agent686 --show [id] # render a transcript
./agent686 --doctor # key, dirs, provider, model
./agent686 --yolo "..." # approve every tool call
The provider is a type plus a URL, both speaking OpenAI-compatible chat completions:
opencode(default) —https://opencode.ai/inference/go/openai/v1, and it requires a stablex-opencode-sessionheader per conversation.openai-compatible— any endpoint (Ollama, llama.cpp, vLLM, OpenRouter, …), given via--base-url/AGENT686_BASE_URL/configurl; no session header.
--lenient tolerates servers that omit [DONE]/usage; HTTPS_PROXY/NO_PROXY
are honoured.
Config file
~/.config/agent686/config.toml (override with AGENT686_CONFIG) sets defaults
the CLI and environment can then override:
provider = "opencode" # or "openai-compatible"
url = "http://localhost:11434/v1" # for openai-compatible
model = "deepseek-v4.1-flash"
lenient = false
system_ca = false
yolo = false
allow_home = false # permit --yolo in $HOME or /
allow_nogit = false # permit --yolo outside a git repository
In a terminal: up/down walks history, bracketed paste arrives as one block
(multi-line is fine), ctrl-c abandons the line, ctrl-d exits. /undo reverts the
working tree to before the last turn, /compact summarises a long conversation,
/models and /model <id> manage the model, /forget <id> prunes sessions.
Rate limits and transient failures retry with backoff (four attempts, Retry-After
honoured); a 429 that survives them explains itself instead of dumping JSON.
Tools
read (numbered lines, streamed, regular files only), write (atomic, never
creates directories), edit (exact match that must be unique; CRLF files
supported), bash (fresh shell per call, own process group, stdout and stderr in
separate labelled sections, timeout_seconds and max_bytes per call),
grep (regular expression; fixed: true for literals), glob (*, ?, **,
follows file symlinks).
Reads never prompt. The first write/edit of a session shows a diff and asks;
answering a allows the rest of the process. Every bash call asks, because
that is where rm -rf lives. --yolo skips both, and is refused in $HOME, /,
and outside a git repository (the undo) unless AGENT686_ALLOW_HOME=1 /
AGENT686_ALLOW_NOGIT=1 are set.
Tests
cargo test # 92 tests, no network
python3 scripts/mock-provider.py & # canned SSE provider
# i686 still builds (comp.sh on a 32-bit host picks it up):
cargo build --release --target i686-unknown-linux-gnu
tests/sse.rs feeds the stream one byte at a time, so splits inside lines and
inside UTF-8 characters are covered. tests/loop.rs proves a tool call is
executed, recorded, and that a denial is returned to the model as data.
Versioning
MAJOR for API-breaking changes, MINOR for features that do not break the interface, PATCH for bug fixes. The interface is the CLI flags, the session file format, the config file, and the tool schemas.
While the major version is 0, interface changes ride on MINOR and are called out
explicitly, because there is no stability promise to break yet. The grep
change in 0.4.0 (literal to regex) is the example. See
CHANGELOG.md and docs/KNOWN-ISSUES.md.
Design notes
- CONTEXT.md — what the words mean (session, turn, step, approval).
- docs/PLAN.md — decisions, non-goals, milestones, acceptance test.
- docs/adr/0001 — why dynamic glibc, not a static binary: static glibc plus NSS modules segfaults on DNS.
- docs/adr/0002 — why history is never rewritten: cached prompt reads are ~50× cheaper, and they require a byte-identical prefix.
No async runtime, no full-screen TUI, no MCP, no subagents, no compaction. Those are choices, not gaps: see the non-goals.
License
Licensed under the GNU General Public License v3.0 or later. See LICENSE for the full text.
