Skip to content
Context Windowby Alex Janjic
Menu

Working code, clear diagrams, and the parts of a system that only show up in production.

blog.janjic.ca/postsFeatured

Tool calling that holds up in production

Most tool-calling failures are not model failures. Four things break in practice, and three are handled by one schema repair pass plus a single retry.

AI systemsReliability
Read the article
lib/agent/tool-loop.ts
if (!parsed.success) {
  const repaired = await repairArgs(call)
  return dispatch(repaired)
}

One repair pass. One retry. Then a hard failure you can inspect.

Latest

New notes and rewrites, newest first.

All articles

Production RAG on Postgres, start to finish

A complete retrieval path using Postgres, pgvector, hybrid search, and a reranker, including the measurements that changed the final query.

AI systemsPostgreSQL

What an agent actually is, in code

A loop, a tool table, and a stopping rule. Read the thirty lines that make it an agent; everything after that is product design.

AI systemsAgents

Treat the context window as a budget, not a bucket

Every token you spend on retrieved text is a token you cannot spend on instructions. Here is how I split it, and what happened when I got the ratio wrong.

AI systemsRetrieval

Your API does not need to be an agent

A workflow with known states needs an API and a queue. Giving it an agent loop adds cost and failure modes without adding useful judgment.

ArchitectureAPIs

Streaming responses cost more than you think

The visible latency looked cheap. The connection lifetime, retries, and abandoned requests made the operating cost tell a different story.

APIsReliability

Code behind the writing

The exact repositories behind the articles, with a clear place to start.

All projects
TypeScriptMaintained

ajanjic/tool-loop

A small tool-calling loop with schema repair, one retry, traceable failures, and an eval suite built from recorded calls.

lib/agent/tool-loop.tsStart at line 14

Follow without another inbox

RSS carries every article and correction. No account, tracking pixel, or algorithm.

Open the RSS feed