Skip to content

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` ──► Result

Decision

// 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.

CallMeaningBuilt 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 answerAgent.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 inThe reference engine's harness-detect package

Options of Agent.run:

OptionMeaningDefault
promptThe taskRequired
outputA schema. The answer is decoded with itRequired
systemInstructionsNone
toolsA Toolkit: the functions a cell may callNone
maxTurnsFrames before the run failsThe reference engine's maxFrames
correctionsRe-prompts after an answer that fails output1
limitsPer cell: 64 calls, 30 seconds of compute, 120 seconds for one call. Per run: 128 MiBThe reference engine's Sandbox.defaultLimits
judgeHow many completion claims a decision model checks0

Rules

  1. The model is a requirement. Agent.run needs LanguageModel in context. provide Experimental.Model.use(seat) chooses it (std-model).
  2. 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.
  3. 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.
  4. A cell is bounded. A caller may raise a limit. No option turns one off.
  5. The answer is typed. A miss against output spends one correction: the task is repeated with the validation issues appended. A spent budget fails with Agent.AgentFailed.
  6. judge is off by default. When positive, a decision model checks that a completion claim matches the run's evidence. It needs DecisionModel in context. A judge that cannot be reached fails the run; it never approves.
  7. Agent.cli names no vendor. profile selects a command, configured on the host, that speaks ACP on stdio. The CLI runs in whatever ChildProcessSpawner is in context, so provide 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.
  8. A CLI session is one step. changed lists 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.
  9. Agent.detect grants nothing. It reports what is installed and signed in, and reads no token.

What must be built

  • A Toolkit for the cell loop. The reference engine's loop takes FlowBinding sources: flow declarations with handlers. An adapter from an Effect Tool to a FlowBinding.Binding does not exist at main@origin bcf8076a4ff4. std-tools needs the same adapter.
  • Effect's LanguageModel for the cell loop. The reference engine's loop takes a resolved Seat holding its own Model, a stream of ModelEvents. The port needs Model.stream written over LanguageModel.streamText.
  • Agent.cli as a local call. The reference engine runs external agents on a separate runner machine through ExternalAgent.make and the AgentJobs port, which are on main and 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, QuotaPolicy and the harness, and leaves the rest.

Host needs

CallNeeds
Agent.runLanguageModel; WebAssembly for QuickJS. On Cloudflare workerd the build is QuickJSWorkerd.variant
Agent.cli, Agent.detectChildProcessSpawner, 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.Agent and AgentAction in the reference engine's agent package, CellTurn and QuickJSSandbox in its harness package. Design · Review.
  • Gives { output, turns, usage } | Agent.Agent and AgentAction in the reference engine's agent package, CellTurn and QuickJSSandbox in its harness package | Design · Review.
  • Call Agent.stream(options): Meaning: The same run as a Stream of events: text deltas, cells, calls, the final answer; Built on: Agent.run's Stream<AgentEvent>, EventSink. Design · Review.
  • Call Agent.cli(profile, options): Meaning: Drive a coding-agent CLI through one task. Gives { summary, changed }; Built on: Acp.make in the reference engine's agent package, over ChildProcessSpawner. Design · Review.
  • Gives { summary, changed } | Acp.make in the reference engine's agent package, over ChildProcessSpawner | 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: A Toolkit: the functions a cell may call; Default: None. Design · Review.
  • Option maxTurns: Meaning: Frames before the run fails; Default: the reference engine's maxFrames. Design · Review.
  • Option corrections: Meaning: Re-prompts after an answer that fails output; 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's Sandbox.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.run needs LanguageModel in 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 output spends one correction: the task is repeated with the validation issues appended. Design · Review.
  • A spent budget fails with Agent.AgentFailed. Design · Review.
  • judge is off by default. When positive, a decision model checks that a completion claim matches the run's evidence. Design · Review.
  • It needs DecisionModel in context. Design · Review.
  • A judge that cannot be reached fails the run; it never approves. Design · Review.
  • Agent.cli names no vendor. profile selects a command, configured on the host, that speaks ACP on stdio. Design · Review.
  • The CLI runs in whatever ChildProcessSpawner is in context, so provide 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. changed lists 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.detect grants nothing. It reports what is installed and signed in, and reads no token. Design · Review.
  • A Toolkit for the cell loop. The reference engine's loop takes FlowBinding sources: flow declarations with handlers. Design · Review.
  • An adapter from an Effect Tool to a FlowBinding.Binding does not exist at main@origin bcf8076a4ff4. Design · Review.
  • std-tools needs the same adapter. Design · Review.
  • Effect's LanguageModel for the cell loop. The reference engine's loop takes a resolved Seat holding its own Model, a stream of ModelEvents. Design · Review.
  • The port needs Model.stream written over LanguageModel.streamText. Design · Review.
  • Agent.cli as a local call. The reference engine runs external agents on a separate runner machine through ExternalAgent.make and the AgentJobs port, which are on main and 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, QuotaPolicy and the harness, and leaves the rest. Design · Review.
  • Call Agent.run: Needs: LanguageModel; WebAssembly for QuickJS. On Cloudflare workerd the build is QuickJSWorkerd.variant. Design · Review.
  • On Cloudflare workerd the build is QuickJSWorkerd.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.X names 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
})
ProgramTokens (o200k_base)Lines
Vibe, proposed7511
Reference engine 1.x, the declaration alone11411

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's LanguageModel.
  • 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.Service does: "a future agent that drives a foreign CLI is another implementation", not a second loop.
  • Factory-first. The factory's agents are Agent.run and Agent.cli calls inside its workflows.

What this changes

  • Experimental.Agent is new. No grammar changes.
  • The proposals page's coding-agent library is replaced: its CodingAgent.make, TypeScriptSandbox and function table are Agent.run, QuickJS and a Toolkit.
  • 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.
  • agent as a declaration keyword. An agent has no schema or tag the compiler must derive beyond what task derives. An agent as a durable step is a task whose body calls Agent.run, and a detached sub-agent is spawn W(input).
  • AgentAction.make as 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 one provide.
  • Cells written in Vibe. The model would write .vibe and 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

  1. 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.
  2. Is Agent.cli in 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: keep Agent.cli, over ACP only, with Agent.detect read-only.
  3. Which loop does Agent.run mean? This VIP makes it the cell loop and leaves the tool-call loop as LanguageModel.generateText. One name with a mode option is the alternative. Recommendation: as written; the two loops have different safety properties.
  4. 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