AI at Scale
November 18, 2026

Letting our agents write their own watchers with Monty and CodeMode

Author
Will McGinnis
Share
Stay Connected

Disclosure: Namespace, which Deckhand runs on, is a Scale Venture Partners portfolio company.

Investors are inundated with information, tasks, and nagging thoughts. Did we follow up with that founder? What was released today that changes everything? Who is in that call later today? Persistent user agents have made it possible for them to offload tons of those tasks to agents via recurring prompts. Review my emails, the CRM, call notes and help me stay on top of things.

Our custom agents do all of this automation by writing what we call watches: short Python programs that run on a schedule against any read-only MCP tool and wake an agent only when something worth acting on happens. Three pieces make that work. Pydantic's Monty runs the model-written program in a sandbox, CodeMode lets the model compose tool calls as code, and a small decision model judges what the program cannot. Together they let users build complex automations on arbitrary MCP capabilities, and by design a check that finds nothing runs no model at all.

Deckhand is the agent platform we built in house at Scale. It runs Sloppy Joe, our background coding agent, and the personal agents our users work with, like Scale Signal and the iMessage and email agents. Each person has a persistent agent that only uses compute while it works. When a message arrives, Deckhand starts a Namespace Instance with that person's volume attached, the agent takes its turn, and the Instance is destroyed. Files, notes and memory stay on the volume.

Disposable compute works well when an agent only answers messages. It is harder when the agent has to notice things on its own, like a meeting that just ended. Program watches are how we solve that, and the rest of this post explains how they work.

The cost of noticing

An agent that has to react to the world can poll or it can watch. 

Polling means a scheduled turn every so often in the actual agent. The full conversation history goes to a model, which calls a tool, reads the result and, almost every time, reports that nothing changed. 

A watch moves that check out of the model. Our agents use remote MCPs for all external communication, so we already have a standard tool-calling protocol. Our first watches read one tool on one MCP server, pulled out items, skipped any we had seen before, applied a few simple rules, and woke the agent only for a new match. No model ran unless something had happened.

That hit a wall quickly. People ask for things like "tell me when a meeting ends with someone from a prospect company and it has notes." That needs a calendar, a CRM and a notes app, plus a join. A fixed extractor cannot do that, and waking the model on every check is the cost watches were meant to avoid.

CodeMode: the model already writes the join

Our interactive agent already had a better way to use tools: the CodeMode capability from the Pydantic AI harness. Instead of giving the model every read tool as a separate call, the model gets one tool, run_code, and the read tools show up inside it as Python functions. It writes a snippet that fetches in parallel, joins the results and returns only the answer.

The tools we allow in a watch runner program are all read-only. Writes stay outside on purpose, so we don’t need to worry about things like human approvals in the watch loop.

Once there is a safe place to run model-written code against read-only tools, a watch is the same setup on a timer, with no LLM at the end.

Architecture diagram. A Worker Lambda holds the watch runner and Monty running through AsyncMonty. A Namespace Instance holds the agent daemon and Monty running through CodeMode. Both reach read-only MCP servers in the middle. The two Monty boxes are highlighted as the same sandbox.
Figure 1. The worker and the agent each run Monty in their own host, against the same kind of read-only tools.

What a program watch looks like

The user never sees the code. They describe what they want in chat and the agent writes a program like the one in Figure 2.

Annotated Python program. It lists calendar events, keeps the ones that have ended, fetches notes for each in parallel with asyncio.gather, builds items with the notes under a context key, and ends with a dictionary of items and context. Code:import asyncioevents = await google__list_events(    timeMin=now("-1d"), timeMax=now())ended = [    e for e in events["items"]    if e["end"] <= now()]notes = await asyncio.gather(*[    granola__notes_for(meeting_id=e["id"])    for e in ended])items = [    dict(e, context={"notes": n})    for e, n in zip(ended, notes) if n]ctx = {"checked_at": now()}{"items": items, "context": ctx}
Figure 2. A complete program watch. The last expression is the result.

The program returns a list of items, each with a stable id, plus a context dictionary. Extra data about an item, like a meeting's notes, goes under that item's own context key. Context is left out of the item's fingerprint, so notes that show up an hour later do not make the meeting look changed and send a duplicate alert. The model and the agent still see it. datetime.now() is frozen for the whole look.

Every MCP tool already has a signature: a name, a description and an input schema. When a tool becomes a Python function, that signature is the vocabulary the model writes in, and a program can only call the tools it declared. "Tell me when a meeting ends and has notes" becomes a call to list events, one notes lookup per meeting, and a join. We never built a tool for "meetings with notes." A new kind of watch needs no new tool, because the agent composes the ones the user has already connected, after reading their signatures with describe_watch_sources.

Why Monty

Monty is Pydantic's minimal Python interpreter for running code written by language models. Code runs in a pool of subprocess workers, so a crash or runaway loop kills a worker, not the Lambda. There is no file, environment, network or subprocess access. Busy loops, big allocations and too many tool calls each hit a limit and stop. A worker is ready in about 0.2 seconds, and asyncio.gather over eight 0.5 second calls took 0.5 seconds.

The alternatives were exec() in a Lambda, which isolates nothing, or a container or microVM per look, which is too slow and costly for a check that may find nothing. A subprocess pool in the Lambda fit better.

Anatomy of a look

A program watch runs at most every ten minutes. The worker connects to each declared server with the user's own credentials, which never enter the sandbox. Each tool function is a closure in the worker that calls the server and returns the result. Before anything runs, the worker checks that every tool exists and is marked read-only, or approved by the user, and refuses the look if not. This runs on every look, so a server that changes or drops a tool is caught at the next one.

Swimlane diagram with lanes for Worker, Monty, Decision model and Agent. The worker verifies read-only tools, Monty runs the program, and the worker checks for a new match. With no match the look ends. With a match, the decision model judges the items. A firm no ends the look, and otherwise one agent turn starts.
Figure 3. One look, split by who does each step. The green exit ends the look without a model call.

The program runs in Monty with 30 seconds of compute, 128 MiB of memory and 50 tool calls. The interactive agent gets 120 seconds, 512 MiB and 500 calls. The call cap is counted in the host, not the sandbox, because a program that counted its own calls could catch the error and keep going. The host flags the overrun and fails the look after the run, even if the program swallowed the exception.

Horizontal bar chart of the program-watch limit as a share of the interactive agent's limit: compute time 25 percent, memory 25 percent, tool calls 10 percent. Agent limits are 120 seconds, 512 MiB and 500 calls. Watch limits are 30 seconds, 128 MiB and 50 calls.
Figure 4. A watch runs on a smaller budget than the interactive agent.

‍Decision models decide whether to wake the agent

A program can join and filter, but some conditions need a reader. "A meeting with a founder" depends on the notes. A watch can carry a predicate in plain words, and a small model in our Decisions service judges each new item before the agent wakes.

The gate is conservative. Only a confident no (probability below 0.1) skips the turn. An uncertain answer still wakes the agent, and a failed call leaves the item unseen so the next look retries. 

The gate sees each item with its context, so it judges the meeting with its notes attached. The agent's turn gets the same material, so it starts with the data in hand. Our guidance is to do cheap filtering in the program and use a predicate only for what takes a reader.

Four-step chevron diagram of stages. The program does joins and filters in seconds on a Lambda. Rules drop seen and non-matching items. The decision model, highlighted, is a small model that judges each item. The agent turn is the full model acting with the data in hand.
Figure 5. Each stage is more expensive than the one before it, and each passes on only what it cannot rule out.

One or more matches start a single turn. By design, a look that finds nothing costs a few seconds of Lambda time: no Instance, no model turn, no Decisions call.

The agent writes it, and a dry run proves it

The agent has three tools for authoring a watch. One lists the connected servers and their tool signatures. One runs a program once in the worker and shows the result, including each call and its timing, without saving anything. One creates the watch. It uses the same sandbox, credentials and read-only checks as every later look.

Sequence diagram with three actors: Agent, Deckhand API and Worker. The agent submits a program. The API queues a dry run on the worker and returns a run id. The worker runs the program in Monty. The agent polls for the result, then creates the watch from the run id. The API checks that the program and sources match and saves the baseline.
Figure 6. Creating a watch references a dry run by id, and the server checks that it matches.

Creating the watch references the test run by id. The request is refused unless that run succeeded and used the same program, sources and approvals. The baseline is exactly what the program produced, and only items that arrive after it can match. Deckhand itself, not the model, then tells the user which tools the watch reads, how often, and what the agent will do on a match.

Failures that do not leak

A failing look counts as a problem, not an outage. Three in a row stop the watch, and Deckhand tells the user once. We store only the kind of failure, the exception type and a line number, never the message, because messages can quote what a tool returned. The full error goes only to the program's author during a dry run. Inside a program, a failed tool call raises an ordinary exception, so a watch can tolerate one flaky source and still return the rest.

Three incredible technologies

Each of these technologies is useful on its own. Monty gives us a safe place to run code a model wrote. CodeMode lets a model use any tool performantly by writing a short program instead of making one call at a time. A small decision model gives us a cheap judgment on the things code cannot decide. Together they make things like program watches possible.

A program watch can be built on any capability exposed through MCP. Users describe what they want in chat, and the agent composes the tools they have already connected into a watch, with no new tool, extractor or engineering work from us. The program does the joins and filtering, the decision model reads what is left, and the full model only runs when something is worth acting on. By design, that keeps each look cheap enough to run on a schedule for every user, so automations that used to need a custom integration can be something a person simply asks for.

This is the part we find most exciting. The automation is not a feature we shipped. It is something users compose, and every MCP server anyone connects makes every watch more capable. We of course use it for things related to VC, but there’s absolutely nothing domain specific in the actual implementation.

‍

News from the Scale portfolio and firm

Investment perspectives, market analysis, and growth playbooks from 30 years of backing Founders.
View All Press
Related Insights