← Reddit

Four calls became one: letting the agent author tools mid-session

Reddit · wesh-k · May 23, 2026
MCP in practice is a connector marketplace, not a runtime. You pick servers up front, the agent inherits a fixed catalog, and turn 1 looks the same as turn 200. The session conforms to the toolset. That ordering is backwards. Most non-trivial work surfaces a

Detailed Analysis

A practitioner working with AI agents and the Model Context Protocol (MCP) has documented a significant shift in how agentic systems can operate: rather than relying on a fixed, pre-configured toolset throughout a session, the agent itself identifies repetitive multi-step patterns and synthesizes new, bespoke tools on the fly. In the author's concrete example, a four-call sequence — querying traces, grepping by name, sorting by timestamp, and diffing the two most recent failures — was collapsed into a single authored function, `findFlakyRecipeRuns(name)`, written directly into a watched plugin directory that the runtime hot-reloads without restarting. Four such tools emerged organically by the end of one session, none of which the user would have anticipated specifying in advance.

The technical significance lies in what the author identifies as five simultaneous requirements that must all be satisfied for this pattern to be viable: the agent must write the tool definition, the runtime must register it without restarting, it must be callable on the next turn within the same session, it must persist across sessions, and failures must not corrupt the broader tool catalog. This is what the literature terms a "self-modifying execution environment," a concept previously treated as a theoretical footnote due precisely to the difficulty of satisfying all five conditions concurrently. The author's demonstration that these conditions can be met in a local, inspectable runtime — where tool files live on disk and can be versioned, edited, or deleted by the user — marks a meaningful transition from a "feature" to a distinct category of system architecture.

The author draws a sharp distinction between tools authored against a generic filesystem versus tools authored against live workspace state. The latter class of tool inherits contextual awareness — it knows what the workspace knows, making it a semantically richer primitive than a mere script. This framing extends the applicability well beyond software development: lawyers managing redlines, researchers working with manuscripts, and analysts operating within structured workbooks all represent domains where a stateful, cursor-aware workspace could support this same authoring loop. The implication is that the value of dynamic tool authoring scales with the richness and structure of the underlying workspace, not with the technical sophistication of the user.

The author candidly surfaces three anticipated failure modes that merit serious attention as this pattern matures. Plugin sprawl occurs when the agent authors tools faster than it prunes them, accumulating near-duplicates that degrade catalog coherence over time. Authored-then-ignored tools represent a subtler problem: a tool written at turn 30 may be functionally forgotten by turn 80 as context window decay erodes the agent's awareness of its own catalog faster than the disk forgets. Drift is perhaps the most insidious risk — a tool authored against a specific project state silently rots as that state evolves, producing incorrect results without obvious signals of failure. These failure modes collectively suggest that tool lifecycle management — not just tool authoring — will be a critical engineering concern as self-modifying agent environments move from demonstration to production use.

This development sits at the intersection of several converging trends in AI systems design: the growing emphasis on local, privacy-preserving agentic runtimes rather than fully hosted pipelines; the expansion of MCP as an ecosystem standard for tool connectivity; and the broader push toward agents that can adapt their own capabilities to the shape of actual work rather than conforming to pre-specified interfaces. The next layer the author gestures toward — declarative "when X happens, do Y" recipe files, hot-reloaded from disk — suggests an emerging architecture where agents progressively externalize both procedural and conditional logic into inspectable, persistent, human-editable artifacts, blurring the boundary between agent behavior and user-controlled configuration.

Read original article →