agentcap
AGENTS.md7 starsChanged 2 months agoApache-2.0View on GitHub
Read this before changing the code. The README explains what the project is and how to use it; this file holds decisions that already hardened and what's not yet built. These are settled. If you want to revisit any, raise it with the user explicitly first. 1. Capture is dumb. The proxy persists raw OpenAI-compat bytes. No tokenisation, no chat-template render at capture time. The capture path must work without the model's tokenizer being loaded. 2. Export is a dumb…
- Deletes or force-pushes
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
The file
We split this AGENTS.md into the rules it gives an agent
4 rules. About 0 are common, 3 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 3
Read this before changing the code.
- Distinctive: line 13
No tokenisation, no chat-template render at capture time.
- Distinctive: line 16
Export is a dumb data shuffle: No tokenizer, no chat-template render, no per-token labels.
- Very specific: line 48
Only
/v1/chat/completionsPOST is captured: All other paths pass through transparently with no capture files.
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
agentcap — agent handoff notes
Read this before changing the code. The README explains what the project is and how to use it; this file holds decisions that already hardened and what's not yet built.
Architecture decisions — DO NOT relitigate
These are settled. If you want to revisit any, raise it with the user explicitly first.
- Capture is dumb. The proxy persists raw OpenAI-compat bytes. No tokenisation, no chat-template render at capture time. The capture path must work without the model's tokenizer being loaded.
- Export is a dumb data shuffle. No tokenizer, no chat-template
render, no per-token labels. Export pairs
<rid>.request.jsonwith<rid>.response.json, serialises each as a JSON string into a parquet row, and stamps a couple of constant provider columns plus per-rowserved_by/served_build_info/served_modelfrom the response fingerprint. The capture path doesn't need the model's tokenizer loaded; neither does the export path. - No hashable identifiers, no rendered tokens in rows. The
parquet exposes the raw
requestandresponsebodies as JSON strings. Token-level analysis is consumer-side: renderrequest.messagesthrough the model's chat template viatransformers.AutoTokenizer.apply_chat_templateand compute whatever ids you want. Reasons:- Different consumers want different definitions of "prefix id", "args hash", "agent build id". Shipping one in rows means everyone computes both ours and theirs.
- Some templates (Qwen3-Coder, Gemma-4) crash on list-typed
contentor string-typedtool_call.argumentsfrom real captures and need normalisation before render. Owning that normalisation in the producer locks consumers into our exact normaliser; leaving render consumer-side lets each consumer handle template quirks on their own terms.
- Capture is via a transparent HTTP proxy, not via patches to the serving stack. Compatibility with any OpenAI-compat backend is load-bearing. No fork patches, no in-server hooks.
- Upstream is a static base URL. Configured at proxy startup; path is mirrored verbatim onto upstream. No upstream pool, no per-request routing.
- Only
/v1/chat/completionsPOST is captured. All other paths pass through transparently with no capture files. - Streaming responses: forward chunk-by-chunk, persist the assembled raw bytes at end-of-stream. SSE parsing into discrete events is the export layer's job, not the proxy's.
- Synthesised follow-ups bypass the capture proxy — they go straight to the model server so the captured corpus stays a clean record of agent↔model interaction.
HermesDriverbuilds a sandboxedHERMES_HOMEoverlay inside the sandbox so a capture run never reads or mutates the sandbox-side~/.hermes/state. The overlay is materialised entirely via the Sandbox protocol (sandbox.mkdtempthensh -c "cp -aL ~/.hermes/. <overlay>"thenrm -rfof_HERMES_FRESH_PER_RUNentries thensandbox.write_textof the rewrittenconfig.yaml). The sandbox-side~/.hermes/lives inside the per-run podman container's filesystem; the user's actual home is never touched.- Snapshot: identity content (
skills/,SOUL.md,hermes-agent/,hooks/,pairing/,models_dev_cache.json) is brought across by thecp -aL. Agent writes inside the overlay diverge from the source. - Fresh per-run (
_HERMES_FRESH_PER_RUN):memories/,sessions/,sandboxes/,state.db,logs/,cron/,image_cache/,audio_cache/,auth.lock. Wiped from the snapshot after the copy and recreated empty (files are left absent so hermes recreates them on demand). Discarded on driver close.
config.yamlis regenerated with the proxybase_urlswapped in and (optionally) the twocontext_lengthguards lowered for CPU/small-model runs.Skills used by the corpus (e.g.
huggingface/skillsfor thehf-hub-sessionruns) are injected per-run viaagentcap run --skills <dir>. The runner bind-mounts the dir read-only into the sandbox and exposes it asAGENTCAP_SKILLS_DIR; the per-agent image entrypoint symlinks it into the agent's discovery path (~/.hermes/skills/for hermes;AGENTS.md+skills/in cwd for opencode/goose/pi).Lifecycle is per-
agentcap runinvocation, not per-task. The overlay is built once when the driver is constructed and reused for every prompt in the corpus. Memory written in task 1 is visible in the system prompt of task 2; the agent'sstate.dbaccumulates across all tasks in the run. This is intentional: it matches what a real user experiences when they invokehermes chatrepeatedly — each invocation reads and writes the same persistent home — so the captured corpus reflects realistic cross-invocation memory evolution. The trade-off, called out in the original bug report, is that theMEMORYsection of the system prompt grows turn-over-turn and task-over-task within a run, shifting the prefix in ways consumers must handle. Two separateagentcap runinvocations both start from empty memory, so per-invocation reproducibility is preserved.- Snapshot: identity content (
- Hermes runs from a clean per-run sandbox cwd
(
<workdir>/sandbox/), not from agentcap's invocation cwd. Hermes auto-injectsAGENTS.md/CLAUDE.md/.cursorrulesfrom the cwd into every system prompt; running from a project dir leaks those files into every capture, contaminating the dataset's "stable" prefix. --pushwrites to Hugging Face Dataset repos. Oneagentcap exportinvocation produces one git commit, regardless of how many runs it bundles; files land underdata/[<subdir>/]<file>.parquet. Repos are auto-created on first push, and a starter dataset card is seeded then (left alone on subsequent pushes). Buckets were the original target; the move to Datasets was driven by the free Hub Dataset Viewer that lights up automatically ondata/*.parquet. The "atomic-replace" semantics ofDataset.push_to_hubwould overwrite a growing corpus, so agentcap doesn't use it.- Each
push_datasetcall writes a unique parquet filename by default that embeds(agent, model, provider)so the filename alone tells you what's inside —train-<agent>-<model>-<provider>-YYYYMMDDTHHMMSS-HEX6.parquet. Each part is optional and is omitted when unknown;agentis read from the run'srun.json,modelandproviderare derived from the captured requests. An explicitfilename=opts back into overwrite-in-place — used only for "latest" pointer files. - One output format only: parquet. Single file per run, pushed
via
--push. JSONL was dropped — it's a one-liner away from a parquet viaDataset.from_parquet(...).to_json(...). Rendered token ids and per-message structural metadata are likewise consumer-side: a 5-line recompute viaapply_chat_templatekeeps rows small and avoids pinning consumers to our exact normalisation of the template-input shape (see decision 3). - Inference backend must deliver tool calls in
message.content, notmessage.reasoning_content. Hermes (and presumably other agents) parses tool calls from the OpenAI-speccontentfield. Reasoning-by-default models (Qwen 3.5+, etc.) on llama.cpp put their actual answer inreasoning_contentand leavecontentempty — the agent loop sees no tool calls and stalls. Runllama servewith--reasoning offfor these models;scripts/start_llama_cpp_server.shexposes this via theREASONINGenv var (defaultautofollows the chat-template's own default, set toofffor reasoning models). Also: agent capture requires a post-agentic-era model and a context window ≥64K tokens — Hermes refuses to launch otherwise.
What's not yet built
- YAML tasks file format.
read_tasks_txthandles.txt. Soft- import PyYAML to keep it optional. agentcap rungraceful interrupt. CatchKeyboardInterrupt, finish the in-flight turn, write a partialrun.json.- vLLM backend smoke test. llama.cpp is the validated default; verify the proxy stays transparent against vLLM too.
- Corpus-specific mounts. Corpora that need host content inside
the container — e.g.
transformers-coding-session's transformers source tree — pass it through as--sandbox <host-path>(writable) or--skills <host-path>(read-only); the driver hands those toPodmanSandboxas bind mounts. Tokens / per-run secrets (e.g.HF_TOKEN) flow throughsandbox.run(env={…})→podman run -e KEY=VAL …, no mount required.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

