8 posts

Bits.

Short notes from building agents and teams: one idea each, read in a minute.

  1. Bit

    Most AI coding agents either start every session with amnesia or drown in a 150k-token dump of stale context.

    Treating context as a static prompt stuffed into one chat window breaks down across multi-repo systems. Over the past few months, I have been working on persistent memory architectures that pool live codebase state, architectural decision records, and operational observations into a cross-session knowledge graph:

    1. Persistent knowledge graph over ephemeral windows: Indexing repositories, synced docs, and verified engineering notes into a shared store gives agents durable recall of how a system evolved and why past architectural decisions were made.
    2. Decision-gated retrieval instead of eager dumps: Dumping full memory histories at the start of a run pollutes long-running agent sessions with irrelevant noise. Querying the graph dynamically only when an agent hits a decision point cuts token overhead and keeps context clean.
    3. Live code as primary truth: Weighting historical discussions and docs below the current repository state ensures agents never override working implementation with outdated notes.
    4. Scoped, permission-filtered context bundles: Passing each agent run a tightly scoped slice of the graph rather than unrestricted corpus access keeps multi-team boundaries intact.

    Separating ephemeral session state from durable system memory is one of the biggest unlocks for getting coding agents to work reliably on large legacy codebases.

  2. Bit

    Agent harness tip: a naive search_codebase tool is the fastest way to burn your context window and your latency budget in production.

    In a prototype, the agent greps a small repo and pastes the hits into the model. In an enterprise workflow, the same call returns thousands of hits, fills the context with vendor noise, and forces a multi-second LLM round trip just to work out what the user meant. Retrieval accuracy holds up fine. What breaks is the output: it arrives unbounded, unranked and unfiltered, and the context is finite.

    Here is how we architected around it.

    Deterministic pre-filtering runs before any model does: Every query is clamped before execution, with hard caps on result count and hits per file, exclusions for build artifacts and dependencies, extension filters, and pagination instead of truncation. One noisy file can’t dominate the results, and the agent knows when output was paged rather than silently cut.

    Query interpretation is tiered: A small, cached model call turns natural-language questions into structured search parameters. When that layer is unavailable, a deterministic term extractor takes over. When the caller already supplied structured criteria, the LLM round trip is skipped entirely. The model only runs on queries that need it.

    Semantic reranking sits behind a seam: It either re-orders the top results in one fast pass or drives a guided hierarchical traversal that finds files that never contain the literal search terms. If it’s unavailable or disabled, the deterministic pipeline still returns correct, ranked results, with a warning. Nothing between the agent and its answers is a single point of failure.

    The result is search that stays fast, bounded and deterministic even when the semantic layer is down. Retrieval is a contract with your context window.

  3. Bit

    Stop paying frontier LLM prices for work a deterministic script can do in milliseconds.

    Subsidised model pricing makes it easy to ignore token bloat during prototyping, where a 64k-token prompt costs pennies. Once an agent moves into high-throughput production workflows, those token economics catch up fast. If your harness burns reasoning tokens to walk file trees, grep codebases, or parse standard syntax, your architecture is burning margin on solved problems.

    Three ways to tighten the harness:

    Pre-digest repo state with local tools: Use AST parsers, ripgrep, and plain shell scripts to filter and structure codebase context before anything reaches an LLM.

    Distill context aggressively: Stop dumping raw files into the prompt window. Extract only the interface signatures, diff slices, and relevant memory nodes required for that specific step.

    Route by task complexity: Send simple classification, formatting, or linting checks to smaller specialised or open-weight models, saving frontier reasoning models for planning and ambiguity.

    Trimming unnecessary tokens lowers API bills, cuts end-to-end latency, and keeps the model’s attention focused on the code that actually matters.

  4. Bit

    Stop micro-managing your AI agents in 15-minute PR loops.

    Micro-batches create review fatigue. When you have to approve every file edit and read 20 tiny pull requests a day, you spend your entire shift reviewing diffs instead of shipping architecture.

    Group related changes (like a schema migration, API contract, and repository layer) into a single end-to-end workstream using the W.A.V.E. Framework (Workstream Autonomous Validation & Execution):

    20% Scope Gate: You define the intent and constraints; the agent writes the Wave Spec.

    60% Execution: The agent builds across file boundaries without interruptions.

    80% Self-Validation: The agent generates end-to-end tests, runs them, and fixes failures on its own.

    95% Human Realignment: You review the complete, tested deliverable for architectural fit.

    100% UAT: Automated verification and release.

    Reviewing one cohesive workstream at the 20% and 95% gates keeps you focused on system design while the agent handles the implementation grind.

  5. Bit

    Sub-agents get messy fast without a governance layer between them and your system state.

    Commercial multi-agent platforms enforce runtime boundaries out of the box, while custom harnesses often let delegated agents execute directly. Without a supervisor checking their work, sub-agents race through tasks and mutate state without validation, solving one problem while introducing new regressions just as fast.

    Put an Outbox Pattern between your sub-agents and actual execution:

    1. Sub-agents write proposed code edits, state changes, or tool calls into a staged outbox instead of executing them live.
    2. The orchestrator inspects, validates, and checks those proposals against scope and safety rules.
    3. Approved actions commit to the system, while unsafe or out-of-scope actions get rejected before touching production state.

    Gating execution through an outbox keeps multi-agent workflows auditable and prevents parallel sub-agents from corrupting shared state.

  6. Bit

    Stop over-engineering your system prompts.

    As software engineers, our instinct is to treat a system prompt like deterministic code: covering every edge case, stacking strict rules, and layering formatting tricks. Modern LLMs do not execute prompts like a compiler.

    With stronger post-training and instruction-following in current models, bloated system prompts trigger instruction drift, inflate latency, and crowd out reasoning capacity. Keeping the base system prompt short and loading specialized skills or tools dynamically on demand consistently produces cleaner execution.

    Keep your base instructions lean, load context only when the task calls for it, and let the model reason without wading through ten pages of edge-case rules

  7. Bit

    Run fabrics are the most overlooked layer in custom agent systems.

    When a multi-step agent crashes 90% of the way through a job, restarting the entire loop from scratch wastes tokens, time, and side-effect state. A durable run fabric checkpoints every step so execution resumes from the exact point of failure.

    Building a run fabric into your harness gives you three practical capabilities:

    Durable restarts: Automatic state recovery after timeouts, rate limits, or process crashes without re-running completed steps.

    Replayability: Step-by-step replay of past agent runs so you can reproduce and debug non-deterministic failures.

    Auditability: Full logs of token spend, state transitions, and tool calls across every execution path.

    Once agents move past single-prompt scripts into long-running production workflows, durable execution becomes mandatory infrastructure.

  8. Bit

    Modular skills beat monolithic system prompts.

    Cramming every workflow rule and edge case into a single base prompt bloats context and degrades instruction following. Keeping the base prompt lean and loading task-specific skills dynamically based on user intent scales much better:

    1. Base Agent: Core identity, safety guardrails, and global constraints.
    2. Skill: Contextual playbook and step-by-step instructions loaded on demand.
    3. Tools: APIs and functions scoped to what that specific skill needs.

    When an edge case breaks, you patch or swap out a single skill instead of rewriting the whole agent, cutting token overhead and shipping fixes faster.