VIP-63: Experimental.Agent: the agent loop, model-written scripts and coding-agent CLIs
Status: accepted by Will, 2026-11-23 — standard library only (no compiler or language changes). Will: "58 I accept. I accept every other language proposal but ones that don't require a change to the language and are purely library functions that don't require compiler changes at all should be marked as such". Runtime provides Agent.cli, Agent.layerCli, Agent.detect, and the internal QuickJS cell interpreter (Experimental.Agent); public agent loop completion queued.
Will's words
Vibelang is meant to have most of the features of durable execution agents etc. built into it. What is that status? Are the VIP open or are VIP missing for things like adding llm calls or jev calls to language sandboxing durable execution etc?
Ok so give me a list of [the reference engine's] features. We need to figure out what the VIP should look like. Some of the features outside of durable execution likely should simply be in the standard library I'm guessing but we should enumerate all of them
Summary
One sentence. Experimental.Agent.run runs a model in a loop until it produces a typed answer, with the model writing short scripts that call the tools it was handed, and Experimental.Agent.cli runs Claude Code, Codex or OpenCode as one step.
One paragraph. Vibe has three ways to run an agent, and only two need new code. A tool-call loop is Effect's, in scope today: LanguageModel.generateText({ prompt, toolkit }) resolves tool calls while the model answers. A code-mode loop is the reference engine's (an existing Effect durable-execution framework these built-ins are modelled on): each turn the model emits a small JavaScript program, a "cell", which runs in a QuickJS sandbox and reaches the world through one function. That loop is Agent.run. A coding-agent CLI is an external program that speaks the Agent Client Protocol on its stdio; Agent.cli drives one. The two differ in what a crash costs. A cell's tool calls are recorded one by one, so a resumed run repeats none that finished. A CLI is recorded as one session: its work is its diff, and its transcript is not replayable execution.
Experimental.Agent.run({ prompt, tools, output })
model ──► cell (JavaScript) ──► QuickJS realm ──► tools.read(…) each call: permission check, journal entry
▲ │ tools.bash(…)
└──────── results, next turn ◄─────┘
└─► done(answer) ──► decode with `output` ──► ResultDecision
// proposed
schema Review { approved: boolean; issues: readonly string[] }
export effect function review(diff: string) {
const result = try Experimental.Agent.run({
system: "You are a strict code reviewer.",
prompt: `Review this diff:\n${diff}`,
tools: Experimental.Tools.filesystem,
output: Review
})
return result.output
}// proposed
export effect function fix(issue: string) {
provide Experimental.Sandbox.container({ image: "node:22" }) {
return try Experimental.Agent.cli("claude", { prompt: `Fix: ${issue}`, cwd: "/workspace" })
}
}Module
Experimental.Agent, in scope with no import, as VIP-33 rules. Its code is vibelang-runtime/experimental/Agent.
| Call | Meaning | Built on |
|---|---|---|
Agent.run(options) | Run the cell loop to a typed answer. Gives { output, turns, usage } | Agent.Agent and AgentAction in the reference engine's agent package, CellTurn and QuickJSSandbox in its harness package |
Agent.stream(options) | The same run as a Stream of events: text deltas, cells, calls, the final answer | Agent.run's Stream<AgentEvent>, EventSink |
Agent.cli(profile, options) | Drive a coding-agent CLI through one task. Gives { summary, changed } | Acp.make in the reference engine's agent package, over ChildProcessSpawner |
Agent.detect() | Which CLIs this machine has, their versions and whether each is signed in | The reference engine's harness-detect package |
Options of Agent.run:
| Option | Meaning | Default |
|---|---|---|
prompt | The task | Required |
output | A schema. The answer is decoded with it | Required |
system | Instructions | None |
tools | A Toolkit: the functions a cell may call | None |
maxTurns | Frames before the run fails | The reference engine's maxFrames |
corrections | Re-prompts after an answer that fails output | 1 |
limits | Per cell: 64 calls, 30 seconds of compute, 120 seconds for one call. Per run: 128 MiB | The reference engine's Sandbox.defaultLimits |
judge | How many completion claims a decision model checks | 0 |
Rules
- The model is a requirement.
Agent.runneedsLanguageModelin context.provide Experimental.Model.use(seat)chooses it (std-model). - A cell has one authority. It can call the tools it was handed and nothing else. It has no file system, no network and no globals from the host. The sandbox is the boundary, not the type checker. A call to a tool that was not handed over fails before the host sees it.
- Every tool call is its own durable step. Inside a task, a crash mid-cell re-runs the cell from the top; calls that settled replay their recorded values, and the run reaches the call that did not. A call whose effect landed before its record can run again, so a tool that cannot repeat carries an idempotency key.
- A cell is bounded. A caller may raise a limit. No option turns one off.
- The answer is typed. A miss against
outputspends one correction: the task is repeated with the validation issues appended. A spent budget fails withAgent.AgentFailed. judgeis off by default. When positive, a decision model checks that a completion claim matches the run's evidence. It needsDecisionModelin context. A judge that cannot be reached fails the run; it never approves.Agent.clinames no vendor.profileselects a command, configured on the host, that speaks ACP on stdio. The CLI runs in whateverChildProcessSpawneris in context, soprovide Experimental.Sandbox.container(…)puts it in a container. The client offers the agent no file system and no terminal; the agent uses its own tools.- A CLI session is one step.
changedlists the files it touched. Its transcript is not journaled, and its output is untrusted text. After a crash the step resumes the session only where the CLI's protocol can; otherwise it reports the session as lost. It never invents a per-tool replay. Agent.detectgrants nothing. It reports what is installed and signed in, and reads no token.
What must be built
- A
Toolkitfor the cell loop. The reference engine's loop takesFlowBindingsources: flow declarations with handlers. An adapter from an EffectToolto aFlowBinding.Bindingdoes not exist atmain@originbcf8076a4ff4. std-tools needs the same adapter. - Effect's
LanguageModelfor the cell loop. The reference engine's loop takes a resolvedSeatholding its ownModel, a stream ofModelEvents. The port needsModel.streamwritten overLanguageModel.streamText. Agent.clias a local call. The reference engine runs external agents on a separate runner machine throughExternalAgent.makeand theAgentJobsport, which are onmainand not in 1.0.0-rc.16. The protocol client they use,Acp.make, is platform-neutral and takes a transport built from a child process's stdio.- A smaller dependency cut. The reference engine's agent package exports the loop beside registry, plugin and session products. The port takes
Agent,AgentAction,Budget,QuotaPolicyand the harness, and leaves the rest.
Host needs
| Call | Needs |
|---|---|
Agent.run | LanguageModel; WebAssembly for QuickJS. On Cloudflare workerd the build is QuickJSWorkerd.variant |
Agent.cli, Agent.detect | ChildProcessSpawner, FileSystem. Node, Bun or a sandbox. Not a browser |
Maintainers' decisions
This record comes from the 2026-11-09 built-in set review. The Status line above records Will’s subsequent ruling.
Experimental.Agent, in scope with no import, as VIP-33 rules. Design · Review.- Its code is
vibelang-runtime/experimental/Agent. Design · Review. - Call
Agent.run(options): Meaning: Run the cell loop to a typed answer. Gives{ output, turns, usage }; Built on:Agent.AgentandAgentActionin the reference engine's agent package,CellTurnandQuickJSSandboxin its harness package. Design · Review. - Gives
{ output, turns, usage }|Agent.AgentandAgentActionin the reference engine's agent package,CellTurnandQuickJSSandboxin its harness package | Design · Review. - Call
Agent.stream(options): Meaning: The same run as aStreamof events: text deltas, cells, calls, the final answer; Built on:Agent.run'sStream<AgentEvent>,EventSink. Design · Review. - Call
Agent.cli(profile, options): Meaning: Drive a coding-agent CLI through one task. Gives{ summary, changed }; Built on:Acp.makein the reference engine's agent package, overChildProcessSpawner. Design · Review. - Gives
{ summary, changed }|Acp.makein the reference engine's agent package, overChildProcessSpawner| Design · Review. - Call
Agent.detect(): Meaning: Which CLIs this machine has, their versions and whether each is signed in; Built on: the reference engine's harness-detect package. Design · Review. - Options of
Agent.run: Design · Review. - Option
prompt: Meaning: The task; Default: Required. Design · Review. - Option
output: Meaning: A schema. The answer is decoded with it; Default: Required. Design · Review. - The answer is decoded with it | Required | Design · Review.
- Option
system: Meaning: Instructions; Default: None. Design · Review. - Option
tools: Meaning: AToolkit: the functions a cell may call; Default: None. Design · Review. - Option
maxTurns: Meaning: Frames before the run fails; Default: the reference engine'smaxFrames. Design · Review. - Option
corrections: Meaning: Re-prompts after an answer that failsoutput; Default: 1. Design · Review. - Option
limits: Meaning: Per cell: 64 calls, 30 seconds of compute, 120 seconds for one call. Per run: 128 MiB; Default: the reference engine'sSandbox.defaultLimits. Design · Review. - Per run: 128 MiB | The reference engine's
Sandbox.defaultLimits| Design · Review. - Option
judge: Meaning: How many completion claims a decision model checks; Default: 0. Design · Review. - The model is a requirement.
Agent.runneedsLanguageModelin context. Design · Review. provide Experimental.Model.use(seat)chooses it (std-model). Design · Review.- A cell has one authority. It can call the tools it was handed and nothing else. Design · Review.
- It has no file system, no network and no globals from the host. Design · Review.
- The sandbox is the boundary, not the type checker. Design · Review.
- A call to a tool that was not handed over fails before the host sees it. Design · Review.
- Every tool call is its own durable step. Inside a task, a crash mid-cell re-runs the cell from the top; calls that settled replay their recorded values, and the run reaches the call that did not. Design · Review.
- A call whose effect landed before its record can run again, so a tool that cannot repeat carries an idempotency key. Design · Review.
- A cell is bounded. A caller may raise a limit. Design · Review.
- No option turns one off. Design · Review.
- The answer is typed. A miss against
outputspends one correction: the task is repeated with the validation issues appended. Design · Review. - A spent budget fails with
Agent.AgentFailed. Design · Review. judgeis off by default. When positive, a decision model checks that a completion claim matches the run's evidence. Design · Review.- It needs
DecisionModelin context. Design · Review. - A judge that cannot be reached fails the run; it never approves. Design · Review.
Agent.clinames no vendor.profileselects a command, configured on the host, that speaks ACP on stdio. Design · Review.- The CLI runs in whatever
ChildProcessSpawneris in context, soprovide Experimental.Sandbox.container(…)puts it in a container. Design · Review. - The client offers the agent no file system and no terminal; the agent uses its own tools. Design · Review.
- A CLI session is one step.
changedlists the files it touched. Design · Review. - Its transcript is not journaled, and its output is untrusted text. Design · Review.
- After a crash the step resumes the session only where the CLI's protocol can; otherwise it reports the session as lost. Design · Review.
- It never invents a per-tool replay. Design · Review.
Agent.detectgrants nothing. It reports what is installed and signed in, and reads no token. Design · Review.- A
Toolkitfor the cell loop. The reference engine's loop takesFlowBindingsources: flow declarations with handlers. Design · Review. - An adapter from an Effect
Toolto aFlowBinding.Bindingdoes not exist atmain@originbcf8076a4ff4. Design · Review. - std-tools needs the same adapter. Design · Review.
- Effect's
LanguageModelfor the cell loop. The reference engine's loop takes a resolvedSeatholding its ownModel, a stream ofModelEvents. Design · Review. - The port needs
Model.streamwritten overLanguageModel.streamText. Design · Review. Agent.clias a local call. The reference engine runs external agents on a separate runner machine throughExternalAgent.makeand theAgentJobsport, which are onmainand not in 1.0.0-rc.16. Design · Review.- The protocol client they use,
Acp.make, is platform-neutral and takes a transport built from a child process's stdio. Design · Review. - A smaller dependency cut. The reference engine's agent package exports the loop beside registry, plugin and session products. Design · Review.
- The port takes
Agent,AgentAction,Budget,QuotaPolicyand the harness, and leaves the rest. Design · Review. - Call
Agent.run: Needs:LanguageModel; WebAssembly for QuickJS. On Cloudflareworkerdthe build isQuickJSWorkerd.variant. Design · Review. - On Cloudflare
workerdthe build isQuickJSWorkerd.variant| Design · Review. - Call
Agent.cli,Agent.detect: Needs:ChildProcessSpawner,FileSystem. Node, Bun or a sandbox. Not a browser. Design · Review. - Node, Bun or a sandbox. Design · Review.
- Not a browser | Design · Review.
Adopted review answers
- Keep
Experimental.Xnames under VIP-33. Promotion to a bare module name requires a later decision. Review question 1.
Compared
The first example in the reference engine 1.x. It type-checks against the reference engine's agent package 1.0.0-rc.16.
import { AgentAction } from "@smthrs/agent"
import { Schema } from "effect"
export const Review = AgentAction.make("review/Diff", {
payload: { diff: Schema.String },
output: Schema.Struct({ approved: Schema.Boolean, issues: Schema.Array(Schema.String) }),
seat: "anthropic:claude-sonnet-5-5",
system: ["You are a strict code reviewer."],
prompt: ({ diff }) => `Review this diff:\n${diff}`,
corrections: 2
})| Program | Tokens (o200k_base) | Lines |
|---|---|---|
| Vibe, proposed | 75 | 11 |
| Reference engine 1.x, the declaration alone | 114 | 11 |
The two differ in kind. The reference engine declares a step: its tools are the flows the host registered, and running it takes the composition in agent/README.md, eight layers including AgentAction.layerHost, SeatResolver.layer, Agent.layer, QuotaPolicy, Budget, Agent.layerDefaults and Evaluator. The Vibe call is the whole program apart from one provide Experimental.Model.use(…).
Checked. Both Vibe examples use only existing syntax and compile under vibelang 0.0.13 against a declaration of Agent.run, Agent.cli, Tools.filesystem and Sandbox.container, with result.output typed by the schema. The reference engine declaration type-checks as shown. ExternalAgent is not exported by the published 1.0.0-rc.16; its description here is from agent/src/ExternalAgent.ts and agent/src/Acp.ts on main.
Principles
- TypeScript-first. Agents call tools by writing TypeScript in the cell loop.
- Effect-second. The tool-call loop is Effect's and is not rebuilt. Tools are Effect
Tools. The model is Effect'sLanguageModel. - Optimized for agentic programs. One call runs an agent, typed at both ends.
- Highly forkable. The loop sits behind one service, as the reference engine's
Agent.Servicedoes: "a future agent that drives a foreign CLI is another implementation", not a second loop. - Factory-first. The factory's agents are
Agent.runandAgent.clicalls inside its workflows.
What this changes
Experimental.Agentis new. No grammar changes.- The proposals page's coding-agent library is replaced: its
CodingAgent.make,TypeScriptSandboxand function table areAgent.run, QuickJS and aToolkit. - Two adapters and one local runner are built, as listed.
Alternatives
- Only Effect's tool-call loop. It exists and costs nothing. The reference engine deleted its own: "The provider-tool-call loop is gone", in favor of cells. Vibe keeps both because Effect's is already in scope.
agentas a declaration keyword. An agent has no schema or tag the compiler must derive beyond whattaskderives. An agent as a durable step is ataskwhose body callsAgent.run, and a detached sub-agent isspawn W(input).AgentAction.makeas the surface, a declared step with a seat string. It is the reference engine's form, and it needs the eight-layer composition to run. A call is shorter and needs oneprovide.- Cells written in Vibe. The model would write
.vibeand the host would compile it each turn. It is the right end state for a language agents write well. It needs the compiler inside the loop. See open question 1. - The reference engine's chain package, its second crash-safe loop with its own journal. Two loops with two journals would make replay unpredictable. This VIP ports the cell loop and uses Chain as evidence only.
Follow-up questions
- What language does a cell use? JavaScript today, in QuickJS. A Vibe cell would be type-checked against its tools before it runs, which the earlier design asked for. Recommendation: JavaScript in the first release; measure Vibe cells with an eval before switching.
- Is
Agent.cliin a language's standard library? It runs other companies' products and reads whether they are signed in. It is also how most coding work is done today. Recommendation: keepAgent.cli, over ACP only, withAgent.detectread-only. - Which loop does
Agent.runmean? This VIP makes it the cell loop and leaves the tool-call loop asLanguageModel.generateText. One name with amodeoption is the alternative. Recommendation: as written; the two loops have different safety properties. - Sub-agents a model starts. The reference engine lets a cell start a child run (
ChildFlows,EngineChildren), and a parent reaches only the children it started. Should a workflow be usable as a tool? Recommendation: yes, in a follow-up, once std-durable is built.
Depends on
- std-model: the model.
- std-tools: what an agent may call.
- std-sandbox: where a CLI runs.
- capabilities: the check in front of each call.
- std-durable: recorded calls.