---
title: "Introducing Cerebras Canvas: a fast edit, then an agent checks"
summary: "A page beside its chat, with a fast Cerebras first pass and a full agent following up. Four editing flavours explore how to change a running page while keeping its saved source in step."
app: "Cerebras Canvas"
created: 2026-11-18
revision: 3
updated: 2026-11-20
url: https://blog.misherate.com/introducing/cerebras-canvas
previous: https://blog.misherate.com/introducing/cerebras-canvas/at/8e383a1bb7e5a49628e712d2173df44a6c0d90bf
---

“Make it faster” should change the thing moving on screen, not start a long conversation while nothing happens.

Cerebras Canvas is an experiment in giving that request two chances: a fast model makes the first edit, then a full agent checks or repairs it. A web page sits beside the chat that changes it. The aim is immediate feedback without giving up a saved, editable source file.

An [iterate](https://iterate.com) mind is its own code and everything that code runs. This experiment puts one of its agents next to a page the agent can rewrite. It is members-only; this introduction describes the machinery rather than linking to the private app.

## One page, one conversation

The starting page is a moving black ball. Open a new canvas, pick an editing flavour, and describe a change in the adjacent chat. Each named canvas has its own agent, conversation and git repository. The saved HTML is the starting point at the next load, not an image of a page that only existed in a model's answer.

The original Canvas experiment had one agent doing the work. Cerebras Canvas adds a first pass through Cerebras's hosted gpt-oss-120b. The regular agent deliberately waits three seconds before asking its own model. A separate event processor uses that gap to ask the fast model for the edit.

A successful answer is applied and recorded, then handed to the agent as context. The agent still takes its turn: it can confirm what happened, repair a mistake or finish a request that needs more than the first pass can do. This trades extra model work for quick feedback plus a second pair of eyes. It is not a guarantee of an instant or correct result.

The coordination below is **pseudocode**, not an iterate API. Each arrow is a durable event; the processor deduplicates its own appends on redelivery. The request stores the source revision as well as the prompt, so an answer cannot silently overwrite a newer file.

```ts
// Processor: a three-second agent wait, with 0.6 s to apply.
onUserMessage(message) {
  requestFastEdit({
    prompt: canvasPrompt, chat: recentVisibleChat,
    page: savedHTML, parent: sourceRevision,
    expiresAt: message.time + 2400
  });
}
onFastAnswer(request, answer) {
  if (expired(request) || agentAlreadyStarted(request)) return;
  validateAndSave(request, answer); // may fail; tell the agent
  giveAgentCurrentFilesAndOutcome();
  releaseAgentWait(); // restore it after the agent starts
}
```

A production version also needs strict answer parsing, bounded inputs and request timeouts; the real processor records failed and no-change outcomes too, and still lets the agent continue.

## Four ways to describe an edit

The flavours change what the fast model sees and returns, not the basic page-and-chat layout:

- Edits: read the HTML and return exact find-and-replace changes. Each search must match once; an ambiguous edit is discarded.
- jQuery: return one function that changes the document. It runs against the saved HTML through Cheerio and against the live preview for immediate feedback.
- Patches: return a JavaScript function that runs in the preview. Keep it in a replayable patch log until the agent folds the change into the source.
- Snap: read a compact outline of the running page instead of all its HTML, including element references, appearance and editable script settings. Return a patch or replacement values and functions.

For example, the edits flavour can return this **invented response** instead of regenerating a whole document:

```json
{
  "edits": [{
    "find": "--ball-colour: black;",
    "replace": "--ball-colour: coral;"
  }],
  "reply": "Changed the ball colour."
}
```

The file-side rule is small but important. This **simplified JavaScript** stages every replacement before saving; one missing or ambiguous match discards the entire answer. Saving names the revision read before inference as its parent; a conflict is a failure for the agent to resolve, not permission to overwrite.

```js
function applyEdits(html, edits) {
  let candidate = html;
  for (const { find, replace } of edits) {
    if (!find || candidate.split(find).length !== 2)
      throw new Error("Expected one exact match");
    candidate = candidate.replace(find, () => replace);
  }
  return candidate; // only now may the caller commit it
}
```

The snapshot is useful because a running page can contain elements its scripts created, absent from its original markup. It is also smaller than sending a large document for a tiny visual change. It is an outline, not a screenshot, and cannot capture everything about a page's behaviour.

Each flavour has editable prompts. New canvases copy those prompts; the fast pass reads its canvas's prompt on each request. That makes the experiment's editing strategy changeable without changing the whole app.

## Fast feedback must survive saving

Changing the screen is only half the job. A patch must survive a reload, and committing a source change must not wipe out the animation the person was adjusting.

The preview runs in a sandboxed frame that allows scripts but has no shared origin with the signed-in outer app. The outer page watches repository commits. Compatible changes to top-level function bodies and literal settings can update the running script through stable forwarding functions; changes outside that narrow contract reload the frame. The details are in [Change the function, not the running page](/posts/change-the-function-not-the-running-page).

An answer consisting only of editable values and functions can be folded into HTML by code. More general patches are kept for replay and left for the agent to fold. A fold that merely saves changes already shown should leave the live page alone, rather than replaying setup and losing its state.

The live-edit trick is a stable function reference: timers keep the wrapper, while the implementation changes behind it. This **illustrative JavaScript** omits the parser and registry's per-script scope handling:

```js
const bodies = { move: () => { x += step; draw(); } };
function move(...args) { return bodies.move.apply(this, args); }
setInterval(move, 50);
// A later edit changes the implementation, not the timer:
bodies.move = () => { x += step * 2; draw(); };
```

The actual loader parses inline scripts with Acorn and supplies replacements inside their original scope. Anonymous callbacks, nested functions and classes are outside this contract. A setting already consumed by setup code is not magically reactive: changing a timer's old delay variable does not restart that timer.

For a general patch, the durable document is the HTML **plus** the ordered log. This **pseudocode** shows the replay/fold contract, not a DOM-diff algorithm:

```ts
onFreshLoad(() => {
  loadHTML(savedHTML);
  for (const patch of savedPatches) runOnce(patch);
});
onPatch(answer => {
  tryOnLivePage(answer); // a throw must not become a saved patch
  appendToPatchLog(answer); // mark already run on this screen
});
onAgentFold(() => {
  commitTogether({ html: integratedSource, patches: [] });
  // Preserve the running frame when this only saves applied work.
});
```

Without an open preview, a patch can be saved untried; the agent is explicitly told. When a live patch throws, it is not kept and the saved page is reloaded. A patch that makes no observed change is not kept either; starting a timer or listener counts as a change. Values/functions-only answers take a narrower route: replace their parsed declarations in HTML immediately, if unambiguous, rather than leaving a log entry. Other patches remain the agent's folding job.

## What runs where

The browser owns the preview and its live-edit bridge. Git holds the HTML, prompts and any pending patch log. A processor on each agent's event stream owns the fast request and records what was asked, what came back and whether it was committed, late, unchanged or failed. Cerebras inference needs its provider credential; the regular agent needs its normal model access. The fast pass is triggered by messages, not by a polling schedule.

Building this requires a member-authenticated outer app, per-canvas repositories and agents, a second durable processor, and a browser-to-agent live-edit bridge. Cheerio supplies the file-side jQuery implementation; Acorn supplies structural script edits. Provider credentials stay in egress headers pinned to the provider host, never in generated HTML or the preview.

The frame uses `sandbox="allow-scripts"`, deliberately without `allow-same-origin`: generated code cannot inherit the outer app's sign-in or reach its capability client. **That is not a network jail**—the frame can fetch external resources. Generated code is still code; prompts and pages go to the model provider, and the preview must not contain credentials or sensitive material. Source history permits recovery, but there is no dedicated Undo or saved-versions interface.

Late or failed answers are dropped, and the agent proceeds. A new message can interrupt the agent's current request so the fast pass gets a go without waiting for that turn to finish. The point of the experiment is not to replace the agent with a cheaper model: it is to separate the speed of showing a plausible change from the slower work of making the saved page right.

## What broke when a save tried to update the preview

The first in-place update treated the saved HTML as the whole page. On a scripted canvas, that removed elements that the running page had created. Now a save leaves the frame alone when it only records a change already shown. The preview can also apply a change confined to editable functions or values; if it can’t tell that a patch is equivalent to loading the new file, it loads a fresh frame. A brief refresh is better than silently losing part of the page.
