
Senior Full-Stack & AI Product Engineer | AI Agents & Agentic Workflows | TypeScript, React, Node.js | Products used by millions daily
Wroclaw, Poland
Joined October 2018
- Tweets102
- Following428
- Followers43
- Likes2K
I hadn't heard of Agent Substrate before reading Katelyn Lesse's article, so this morning I dug a bit deeper. Sharing some of my notes.
What it is
An open-source runtime from Google that runs AI agents on Kubernetes. You pay for compute only while an agent is actually working.
What problem it solves
A coding agent works in short bursts. It runs a step, then waits for the model to answer, for an API call or for you to review its work. Waiting can take 90 to 95% of a typical session.
While it waits, it uses no CPU, but you can't just shut it down. It still has a cloned repo, uncommitted edits and running processes in memory and on disk. Kubernetes was never built for that.
The usual setup on Kubernetes is one Pod per agent, which leaves two bad options. You can keep the Pod running all day so the agent answers fast, but then you pay for idle compute around the clock. Or you can scale it to zero, which is cheap, but waking it up means cloning the repo and reinstalling packages again. That takes more than 20 seconds.
Substrate separates the agent's state (memory and files) from the compute it runs on. That compute comes from a small shared pool of workers: sandboxes that are already started and ready to take any agent.
When a turn ends and the agent waits for your next message, Substrate saves a snapshot of its memory and files to storage and returns the worker to the pool.
When your message arrives, any free worker loads the snapshot, and the agent continues where it paused. There's no cloning or reinstalling, and it takes under half a second.
Live connections don't survive the snapshot, so the agent has to reconnect to its database or a remote MCP server after it wakes up.
software engineers are going to have to tackle a new set of problems to unlock powerful multiagent systems to solve the world's hardest problems - right now is one of the most interesting moments in history to be an engineer.
2
2
275
If you want to dive deeper into any of these blocks, here's what to read:
Lauren Tan, "All Code Is Slop (Except Mine)": youtube.com/watch?v=O_zcc6Xl…
Addy Osmani, "How the Claude Code team thinks about verification": xitter.gq/addyosmani/status/2122…
Claude Code hooks: code.claude.com/docs/en/hook…
pstack, which can generate a verification skill for your repo: github.com/cursor/plugins/tr…
LaunchDarkly guarded rollouts (automatic rollback): launchdarkly.com/docs/home/r…
Claude Code Code Review (Important / Nit / Pre-existing): code.claude.com/docs/en/code…
ECC instincts: github.com/affaan-m/ECC
Permission deny rules + sandbox: code.claude.com/docs/en/sand…
/loop: code.claude.com/docs/en/sche…
Routines: code.claude.com/docs/en/rout…
1
157
Switching providers in the Vercel AI SDK is one line of code. Your caching bill is not.
With OpenAI and Gemini, the same code caches by itself. With Claude, nothing is cached until you ask for it.
OpenAI and Gemini notice when a request starts like an earlier one and bill that repeated part at a discount.
On Claude you mark where the cached part ends. An agent calls the model once per step, and each call resends the whole conversation with every tool result so far. Without a marker, you pay full input price for all of it. For a 100,000-token conversation on Opus 5.5, that's $0.40 of input per step. From the cache, the same tokens cost $0.02, a twentieth of the price.
✔️ The fix is one option on the call: caching: 'auto' through Vercel's AI Gateway, or cacheControl with ai-sdk/anthropic. Both keep the cache marker at the end of the conversation for you. Anthropic calls the second one "automatic caching", but despite the name it's off until you send it. The exact code is in the first comment.
Message threads, a beta in Anthropic's API, sound like another fix: Anthropic keeps the conversation for a few minutes, so you send only the new messages and the first token arrives sooner. But the price is the same, and a thread doesn't cache by itself, so send the same cache option with every thread request.
⚠️ Where to pay attention:
→ In an agent or a chat, each request extends the previous one, so put the cache option on the generateText call. The marker then moves to the end of every request. If you put it only on the system prompt, everything after it costs full price on every step.
→ For one-off calls (the same long system prompt, a new question each time), do the opposite and put the marker on the system prompt. On the call, it would land on the question, which never repeats, so you'd pay for a cache write on every call and never read it.
→ Don't put dynamic values at the top of the system prompt, for example a timestamp. Any change at the start breaks caching on all three providers. On OpenAI and Claude the tool list counts as the start too, so don't change activeTools between steps.
💡 Before you ship a provider switch, look at cacheReadTokens on each step of an agent run. When caching works, the number goes up step after step, because each request reads everything before it from the cache. If it's zero, you're paying full price. If it stays the same, only the system prompt is cached.
✍ I write every week about AI agents in practice: tips & tricks and common traps. I try to explain them as simply as possible. Follow me so you don’t miss the next post.
6
6
333
When Claude Code searches or fetches the web, Claude almost never reads the page itself. It reads what another model wrote about it.
A model can't run anything. To "call a tool", Claude writes a small request like {"name": "WebSearch", "input": {"query": "..."}} and stops. Something else runs it and returns the result, then Claude picks the next step. That cycle is the agent loop, and whatever runs the tool decides what Claude sees.
I followed one tool call from a real run: I asked Claude Code 2.1.316 whether a demo repo is affected by the Mini Shai-Hulud npm worm (its lockfile pins two of the worm's May versions). Claude wanted to check two articles, so its reply held two tool calls at once. Here's one:
{"name": "WebFetch", "input": {"url": "thecybersecguru.com/…", "prompt": "Quote verbatim the affected versions listed for echarts-for-react, timeago.js, and lodash…"}}
Look at the prompt field: Claude writes the question a second model will answer. Then Claude's turn ends.
Claude Code, the harness, checks my permissions and downloads this page: 252 KB of HTML. It converts it to Markdown and keeps at most 100,000 characters. For a longer page, the tool result tells Claude how much went unread. This one fit.
Then it sends that Markdown and Claude's question to a second model. I had Opus 5.5 selected, but the reading went to a cheaper model. The docs don't say which; my run's usage report shows Claude Haiku 5.5. Its answer was 1,597 characters, with the key line: the article "doesn't mention echarts-for-react, timeago.js, or lodash". For the whole run (5 pages, 2 searches), Haiku's bill was $0.03 at API prices. Opus, doing the main work, cost $0.61.
Claude Code ran both fetches at the same time, then sent a new request: the whole conversation plus both answers, 56,409 tokens. The API keeps no memory, so Claude Code resends the whole conversation each time.
Now Claude, the main model, reads the answer, not the page. If Haiku had missed a line, Claude couldn't tell. The docs list this as a prompt-injection safeguard. I think it's first of all about context and cost: the page itself never goes into the expensive model's context.
I checked that article myself: Haiku was right, it says nothing about these packages (it covers the worm's May 11 wave). The second article listed both versions, so Claude's verdict was right: the repo is affected.
So a harness like Claude Code is a multi-model system. In my run, Opus planned and Haiku read the pages. Not every step runs on the model you picked.
For an experiment, I pointed Claude Code's Haiku setting at Opus (ANTHROPIC_DEFAULT_HAIKU_MODEL=claude-opus-5-5) and asked the same question again. Now Opus read the pages too, but the main Opus still got only the short answers, never the pages.
Same verdict both times: affected. Only the bill changed: $0.64 with Haiku reading ($0.61 + $0.03), $1.35 with Opus, at API prices.
Next post: prompt caching. Follow me so you don't miss it.
9
8
600
Claude Code can delete a file that /rewind cannot bring back.
If Claude only touched that file through Bash, it isn't tracked for rewind. An rm command can delete it without leaving a checkpoint to restore.
But if Claude had already edited that file through its file-editing tools, subsequent Bash changes can be restored too.
The difference comes from what the harness tracked.
Here's how tool calling works underneath.
The model receives tool definitions: names, descriptions, and input schemas. It generates a structured request describing which tool to use and what to do.
The Claude Code process checks permissions, executes the allowed action, and returns the result.
The model receives that result and chooses its next step.
That surrounding software is the agent harness. It handles execution, manages the context the model receives, and tracks changes for features like /rewind.
If you've used Redux DevTools, the idea is familiar: time travel restores store state, but it doesn't undo an HTTP request or a localStorage write. Claude Code has its own boundary: /rewind restores tracked files. Changes made only through Bash fall outside that boundary.
Background subagents have a similar limit. Rewind restores files already tracked through the main session's file-editing tools. Files touched only by the background subagent stay changed.
This matters for any agent you build. A tool call might make a booking, issue a refund, or email a customer. Agree with the business on what can run automatically, what needs a person's approval, and what you must be able to undo. Keep a record of what happened so you can investigate when something goes wrong.
So for every tool that changes something, I want three answers:
→ What happened? Return enough detail to check the result.
→ What happens if it runs again? A retry should not create a second booking or issue another refund.
→ If something goes wrong, how do we recover? Define what can be undone and when a person needs to step in.
#AIAgents #AIEngineering
5
3
218
Using Railway? Your environment variables may have been exposed.
Railway disclosed the security incident yesterday. When I checked our Gemini usage, I found a sudden spike our application's activity couldn't explain.
We had a budget alert in place, and it fired overnight. I treated the key as compromised and disabled it immediately. That took one non-critical feature offline.
If you have credentials stored on Railway, here's what I'd check:
1. Check usage at each provider.
Compare API requests and spending with your application's actual activity. Look across the possible exposure window, rather than assuming the last few hours tell the whole story.
2. Act on suspected abuse.
I disabled our key because the usage was already suspicious. Changing a value in Railway doesn't revoke the old credential at its provider.
3. Review every credential stored there.
Railway recommends rotating API keys, database credentials and private registry credentials. Include storage and other service credentials in your review.
4. Check access as well as spending.
Review database connections and cloud audit logs. For Google Cloud service accounts, check permissions, new keys, IAM changes and unexpected resources.
5. Check what your spending controls actually do.
An alert-only budget sends a warning; it doesn't stop usage. Check quotas, supported spending caps and auto-reload settings where applicable.
For a controlled rotation: create a replacement, apply the restrictions it needs, update the application, deploy, verify, then revoke the old credential. Suspected active abuse may justify revoking first and accepting an interruption.
I appreciate Railway publicly disclosing the incident and contacting AI providers about revoking keys. Link to their disclosure in the first comment.
1
2
110
Agents are becoming users of software. More than half of the traffic to sites on Cloudflare is now automated, and daily AI-agent requests grew 1,700% in a year (Cloudflare, Sep 2026).
So a new kind of tool is growing fast: tools built for models, not for people. Web search is the clearest example. Here is how I would choose in October 2026.
First, name the job:
→ You don't know the URL yet: search.
→ You know the URL: read it. About $1 per 1,000 pages with Exa or Parallel.
→ You need a whole site: crawl it (Firecrawl, or Crawl4AI if you host it yourself).
→ You need logins, clicks or forms: use a real browser. Browser time is cheap. Model steps, proxies and CAPTCHAs are not.
Then pick the search:
→ Search built for agents (Exa, Perplexity, Parallel, Brave LLM Context, Tavily): my default. One call returns the relevant passages. Fast tiers from $1 per 1,000, standard $4–8.
→ Built-in search (OpenAI, Anthropic, Google Gemini, Microsoft Azure): one line to add, $10–14 per 1,000 searches plus tokens. Great for prototypes and chat. One catch: Google's and Microsoft's terms say the results are for showing to your users, not for keeping. No caching, no saving them to a database, no training on them. So they fit badly with agents that work in the background and keep what they find.
→ Google results (Serper, SerpApi): when you need exactly what Google shows. You get links, not content, so you need a second call to read the pages.
→ Deep research (Parallel Task, Exa Deep): seconds to hours per question, up to dollars per task. Only when one search can't answer.
Three things most teams miss:
1. On big models, reading costs more than searching. An average web page is about 2,500 tokens. On Claude Opus 5.5 ($4 per million input tokens), reading one page costs about $0.01, the same as one built-in search. Read ten pages, and you pay 10x the search fee. So pick a search tool that returns only the relevant paragraphs, and load a full page only when they don't answer the question.
2. Compare cost per solved task, not price per call. In Artificial Analysis's launch results, Exa Fast was quicker per search than Exa Auto, but the agent read more tokens, paid more per task and scored lower.
3. If a limit is a hard requirement, enforce it in your own code. Say your agent may only use approved sites, or only recent pages. A provider's filter helps, but it is not a guarantee. In my tests in May, Tavily still returned pages from sites outside my allowlist (it is strict by default now). So check the site and date of every result before your agent uses it.
And no benchmark crowns a winner. Two independent leaderboards disagree, and every vendor's own test ranks itself first. Test on your own questions.
Teams spend weeks choosing a model and minutes choosing how it sees the web. The second choice matters just as much. I think we will see many more products whose main user is an agent.
What does your agent use to see the web?
2
2
202










