Skip to content

Latest commit

 

History

History
82 lines (64 loc) · 4.13 KB

File metadata and controls

82 lines (64 loc) · 4.13 KB
id TD-024
title "Agent Mind" — a generated repo digest injected into the warmed system prefix
status proposed
date 2026-06-22
supersedes
superseded_by
tags
agent-mind
context
repo-map
kv-cache
carbon-warm
rag
agentic
opencode

TD-024: "Agent Mind" — repo digest in the warmed prefix

Context

A human working a repo for a week does not re-read every file each morning — they hold a mental model (architecture, the files that matter, the constraints, the gotchas). Local agents have none: every task rebuilds context from zero, and the agentic benchmark shows the cost — the loop crawls and never converges fix-until-green. The model isn't the only bottleneck; context reconstruction is.

TD-023 already warms and KV-caches the static system head for free. The cheap, high-leverage next step is to make that head carry a project mental model — so it too is prefilled once and reused on every turn.

Decision (direction)

Generate a compact repo digest — call it the Agent Mind — and inject it into the warmed system prefix:

{ "architecture": "...", "critical_files": [...], "constraints": [...],
  "known_bugs": [...], "patterns": [...] }

Produced by a one-shot pass over the repo (a cheap local model summarizing the tree + key files, or a deterministic repo-map), written to e.g. AGENTS.md / the system prompt, and cached by carbon warm. The agent then starts each task already "knowing" the project instead of grepping it back into existence.

Why it fits this stack (and why it's the buildable one)

  • No engine patching. It's plain context engineering: digest → prepend to the system prompt → the existing TD-023 warm path caches it. Ships on llama.cpp today.
  • Carbon doesn't own the loop — and doesn't need to. The agent loop is OpenCode (external npm, README). Agent Mind is delivered as injected context, not runtime state — exactly the seam Carbon controls.
  • Composes with retrieval. TD-020 (NPU embeddings/RAG) is the dynamic side (retrieve the right chunk per query); Agent Mind is the static digest side. Together: a stable mental model in the warm prefix + per-task retrieval.

Plan

  1. Digest generator (carbon mind or a warm pre-step): walk the repo → architecture summary + critical-file list + constraints. Start deterministic (tree + headers + a repo-map), optionally enrich with a small local model.
  2. Inject + warm: write the digest into the system prompt / AGENTS.md; carbon warm prefills and caches the now-larger prefix.
  3. Incremental refresh: re-generate only on meaningful repo change (git diff trigger) — and re-warm, since any prefix edit invalidates the slot (TD-023).

Risks / unknowns

  • Prefix bloat. The digest grows the cached prefix → more KV RAM (precious under TD-006's ~2 GB KV budget) and less room for the task. Keep it tight (target ≤1–2K tokens) and measure the RAM hit.
  • Staleness. A wrong/old digest actively misleads the agent. Refresh-on-change + keep it factual (paths, signatures) over interpretive.
  • Digest quality. Auto-summaries hallucinate; prefer extracted facts to prose where possible.

Acceptance

On a real task in one of Guido's repos, with the Agent Mind warmed in vs a cold baseline: lower TTFT, fewer tool calls (grep/read round-trips), and equal-or-better task score on the agentic benchmark. A 30–50% drop in tool calls/time is "real optimization"; a 2–3× drop would argue this is an architecture, not a tweak.

Related

  • Builds directly on TD-023; pairs with TD-020 (RAG) and TD-027 (cache the workflow, not just the facts).