March 31, 2026

Build Log 09: The Agent Loop.

Mar 4 — extracting the brain into a single file.


The agent worked. Most of the time. "Most of the time" is not good enough when the agent is your product.

One File, One Loop

Both API routes had their own copy of the agent logic. Slightly different error handling, slightly different context assembly, slightly different bugs. Pulled all of it into a single agent-loop.ts. Loop detection, dual-threshold iteration management, smart context pruning, error classification — one place to fix, one place to improve.

This is the kind of refactor that doesn't show up in a changelog but changes everything about how fast you can move afterward.

Pipeline Upgrades

Per-tool timeouts so one slow tool doesn't stall the whole response. Circuit breaker so a flaky integration fails fast instead of retrying forever. Parallel context assembly — fetch memory, knowledge base, and codebase context at the same time instead of sequentially. Provider failover so if one model is down, the agent switches without the user noticing.

Fast-path for simple questions: if someone asks "what time is standup?" the agent skips tool registration entirely. Streaming tool results during execution so you see progress, not silence.

Codebase Indexing

Smart context scoring for codebase queries. The agent now ranks which files matter for a given question instead of dumping everything it can find into the context window.

Housekeeping

Fixed 18 React Compiler eslint errors from the Next.js 16 upgrade. Bumped route timeouts to 300s — long-running agent tasks were hitting the old limits.


The agent went from "works most of the time" to "works reliably under pressure." That gap is where trust lives.