Skip to content
View original post on X: meng shao
Published
Pick

Lee Robinson's Stanford lecture explains how always-on agents work

AILee Robinson, a SpaceXAI model training team member, gave a Stanford CS146S lecture on the architecture of GrokBot, an always-on proactive agent. The notes cover sleep-and-wake VMs, a thin client with a single "send to user" tool, Temporal durable workflows, prompt caching, and layered memory and compaction.

AIWhy it matters.

The lecture notes explain how always-on agents handle sleep and wake, tool design, caching and memory, giving practical engineering context for building similar systems.

meng shaoVerified on X
@shao__meng
View on X

https://x.com/i/article/2108757732417572864

How Always-On Agents Work: Lee Robinson's Stanford CS146S Lecture, GrokBot Architecture, Harness, and Context Engineering in Full

Lee Robinson's Stanford CS146S Lecture "How do always-on, proactive agents like @Bot work?"

Background: Lee Robinson (former head of Vercel/Next.js, former Cursor, now on the model training team at SpaceXAI) walked through the engineering architecture of GrokBot-style "always-on proactive agents" in this roughly 45-minute lecture. This is firsthand disclosure from a production system, and he explicitly said "some of these things are what we're building at SpaceX."

Core Thesis: From "Tool" to "Coworker"

The lecture starts from the simple harness students built in the first week (a model plus a tool-calling loop). The paradigm is powerful but has a fundamental flaw: close the laptop and the process dies. Always-on agents are designed to solve exactly this. They run on servers, recover after crashes, have their own Linux cloud computer (files, browser, desktop), and work like a coworker: they know when to stay quiet, only come find you when there's meaningful progress, get woken by events such as Slack messages, emails, or calendar entries, and can keep working for weeks or months.

Part 1: Four Eras of Evolution (How we got here)

He divides the history of developer collaboration with AI into four stages: copy-pasting ChatGPT code → simple agents in the terminal (able to edit files and run commands) → dedicated agent apps (running in parallel and in the cloud, but humans are the bottleneck, with every command requiring approval) → always-on agents (running in the background in an environment, continuing to work while you sleep).

Two observations stand out as the most informative:

1. From "queuing" to "steering." The old pattern was: you give an instruction → wait → approve a command → wait again. The new pattern lets you interrupt at any time and fire off rapid-fire follow-up instructions ("go look at that thread... actually, do it Thursday"), and the model understands the relationships between these instructions. This is a direct sign of improved model capability.

2. AI review is actually safer. The industry now commonly uses "auto review" (an independent model that reviews every command before execution) in place of manual per-command approval. His judgment is sharp: in blind tests, models reviewing commands often do better than humans, because humans inevitably get fatigued and lax when approving hundreds of commands. As models get stronger, interfaces get simpler, and the eventual form is "texting a friend," because everyone already knows how to text.

Part 2: Six Key Model-Level Changes

1. Long-horizon instruction following: combined with compaction techniques, models can run stably for hours to days without losing track.

2. Subagents: the main model can hand tasks to "helpers," each with a fresh working memory; after doing the heavy work they only report results, which is effectively unlimited context.

3. Mature tool calling plus powerful tools: a few years ago models couldn't even call tools properly and hallucinated constantly (he joked "nobody talks about hallucinations anymore, because they're basically solved"). Now you can hand a model a full Linux computer and have it operate everything via computer use (clicking on screens like a human). Any website or SaaS without an API or MCP can be used headlessly.

4. Files as storage: information is stored in files, and the model queries them at any time with shell commands (grep/search).

5. Skills: encoding "how to do something well" into markdown files, and an entire skills ecosystem already exists. GrokBot has a plugin system (tool = plugin = skills + server) and routines (scheduled tasks, i.e., cron jobs).

6. From this comes a programmatic summary: "Everything is computer."

Part 3: Internal Architecture of Always-On Agents

Sleep-wake model. The server and cloud computer are normally asleep, triggered to start by messages or events; VMs are spun up on demand and put back to sleep when done. The reason: "keeping every person's agent computer online forever is expensive, and there aren't that many computers in the world." State (session logs, memory, routines) is persisted to a database.

Wake sources and the routing decision about "whether to disturb the user." Besides direct questions, Slack, phone calls, and meetings can all wake the agent; inside SpaceX it's already common for employees to have a bot attend meetings for them, take notes, and bring back minutes. All triggers pass through a router that deduplicates and merges them into the session, then a set of heuristics decides whether the event is worth interrupting you for. A coworker who reports every bit of progress would drive you crazy, and the same goes for agents.

The cloud computer is a Firecracker microVM: it can be snapshotted, shut down, and restored. Users can connect in to watch live or even take over. Commands run in an isolated environment rather than on your laptop. Virtual desktops are supported, so five or six bots can each have their own browser without interfering with each other.

Thin client, thick server. The key architectural decision: there is only one tool between client and server, "send to user." All heavy tools (shell, files, cloud agent, screen recording) live on the server side. The benefit is that any client form (mobile app, desktop, email, Slack) only needs to implement this one interface, while the client can render rich interactions on its own after receiving a response: login forms, 1Password integration, Stripe/XMoney payments, draft approval before irreversible actions (sending email), or even responding with just an emoji.

Message priority: your direct messages interrupt the current agent loop and are handled first; group chats and background tasks are queued; three or four messages arriving in quick succession are automatically merged into a single turn.

Task queues vs. durable workflows: with an ordinary queue, a crash means replaying steps 1, 2, and 3; with a durable workflow, a retry after failure resumes directly from step 3. They use the open-source Temporal to solve this rather than reinventing the wheel.

Escalation ladder, a principle that's elegant from an engineering standpoint: always try the cheapest and most reliable option first: session history → plugins/MCP/API (e.g., Plaid for bank data) → web search → opening a browser to act → using a full Linux desktop to run scripts → only if all fail, go ask the user. Information retrieval on the computer side has a similar ladder: screenshot → HTML → accessibility tree (greatly reducing tokens) → pixel-level clicking (for pop-ups) → hand back to the user (CAPTCHAs, two-factor authentication).

Part 4: Security Model

- Every shell command is reviewed by a model before execution (auto review);

- Untrusted input is isolated: phishing emails in the inbox and webhook data must never be treated as user instructions going straight into the model. This is the core of prompt injection defense, and he candidly said "there's still a lot of work to do in the industry";

- Irreversible actions require user approval first;

- Credentials such as passwords are kept outside the model session through product-level workflows.

Part 5: Context Engineering

He stated directly: context engineering is harness engineering, and the two are the same thing. Core insights and techniques:

1. Prompt caching is the lifeline of economics. Ideally most tokens should be cache hits (every turn resends the full history, and only the latest message is incremental). To achieve this, keep tool definitions and the system prompt static across calls; segment the prompt with a fixed order, almost like hashing; A/B tests that insert new paragraphs must not break everyone else's cache; a cache miss should be treated as a bug. He also mentioned that when OpenClaw exploded in popularity on subscription plans in January this year, this new always-on usage pattern caused large numbers of cache misses, and every provider was forced into urgent optimization. A clever trick: when a user opens the chat box and starts typing, the server pre-prepares the prompt to warm the cache, similar to a webpage prefetching the next page when you hover over a link.

2. The timing of compaction: all compaction is lossy ("this problem is enough for several PhD theses"). Their practical tip: when a conversation exceeds 100k tokens and the user has left, compaction should be completed immediately within the window while the cache is still warm (10–60 minutes), so that when the user returns, they continue from a cheap summary, which is far less costly.

3. Layered memory (the analogy to how the brain works is brilliant):

◦ Core facts: every message must carry them (e.g., "this user always uses lowercase," and he made a joke about Sam Altman along the way); garbage-collect facts, keeping what's relevant today and letting things like a football match fade from memory later;

◦ Dated logs: archives of past session history;

◦ Scratchpad: small things currently being handled, designed to exist only briefly;

◦ Everything else lives in files: the model greps them whenever needed. "This is the magic of files."

Part 6: Future Direction

Training flywheel: pretraining → SFT (teaching the model to work within this specific harness and get to know its tools) → RL (instruction following, choosing the right skill out of hundreds, clicking the right spot in a browser). The inner loop runs daily: "discover bug → turn it into an eval → fix the harness/prompts → verify → ship"; the outer loop runs monthly or quarterly: each new model learns from all the failures and climbs the eval curves. The capability leaps that new models bring in turn spawn new product usage. For example, multi-bot collaboration in group chats is a newly emerging behavior that has to be trained deliberately (he cited the Moltbook and Hugging Face incidents as negative examples).

"Delete the product": a principle he brought from Cursor to SpaceX. Assume today's model is the worst version it will ever be, and that in six months you may need to rewrite the whole UI. The right strategy is to build for the next generation of models: build as little as possible, keeping only a minimal interface that lets the model think and act.

Predictions for the next six to twelve months: agent working time stretches from hours per day to weeks or months; memory recall algorithms keep evolving (whether the form will be graphs, files, or something else is still undecided); agents get equipped with all the tools a new human employee gets during onboarding; voice-to-voice interaction; skills learned on the job and distilled into files; enterprises learn to write their custom workflows as documents that agents can read.

The sharpest industry judgment (quoted from Alex of OpenRouter): some people say "all AI apps look the same now, a sidebar plus a chat box." His response: "In 2005 everyone looked the same too: server + database + CRUD." Agent capability is the default foundation of the next generation of products: every product either integrates an agent or becomes a headless data source that someone else's agent calls. And durable workflows, sandboxes, cloud computers, memory, skills, voice, payments, identity, evals, and observability are each a multibillion-dollar VC category with twenty startups competing for it. Together they make up the "new primitives" for the next generation of companies.

Three pieces of advice for students

1. System design and architecture matter more than ever, and their decisions compound (he still insists on reading the code: "some people have already stopped").

2. Build one yourself. There is an open-source replica of GrokBot on GitHub.

3. Even if you don't do ML, you should understand the basic principles of LLMs, just as building web apps requires understanding databases, because countless decisions at the product and harness layers are being shaped in reverse by model characteristics.

Overall impressions

The value of this talk lies in its rare completeness: from changes in model capability, to the two-layer server/VM hibernation architecture, the single-tool thin client design, Temporal durable workflows, the cache economics tricks of segmented hashing and prewarming, layered memory and compaction timing, and then the training flywheel. The full decision chain of a production-grade resident agent is laid out in full, with real engineering trade-offs annotated throughout (why there is only one tool, why compaction should happen while the cache is warm, why auto review is actually safer).

It also clearly flags the industry's unsolved problems: how to evaluate an agent that runs for a month (when models release new versions every month), defenses against prompt injection, and the delicate balance between being proactive and being intrusive ("I noticed you missed class yesterday, so I took notes for you": is that thoughtful or overstepping?). These open questions are exactly where the opportunities for the next generation of practitioners lie.

AITranslated from No linguistic content
Source details

meng shao · x.comPublished · added here

Original title: 常驻智能体如何工作:Lee Robinson 斯坦福 CS146S 讲座,GrokBot 架构、Harness 与上下文工程全解