Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 33 additions & 12 deletions DEMO.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
# Demo video: draft script

**Due:** Oct 14, 2026, 11:59 PM PDT. The video must be 5–10 min, in MP4, WebM or MOV, under 2 GiB. Target **8:00** so there's room to spare. Form answers are drafted in [docs/submission.md](docs/submission.md).
**Due:** Oct 14, 2026, 11:59 PM PDT. The video must be 5–10 min, in MP4, WebM or MOV, under 2 GiB. Currently **~5:15**: the rules require 5–10 min. Form answers are drafted in [docs/submission.md](docs/submission.md).

## The one-two punch

**Thesis (the opening line):** what if Cloudflare Artifacts could make Code Mode self-improving?


1. **Code Mode (Cloudflare's insight).** Models are better at writing code than at calling tools one at a time. In Code Mode the agent writes one function that chains tool calls, and Cloudflare calls that code "a compact plan" ([Code Mode MCP post](https://blog.cloudflare.com/code-mode-mcp/)). Each snippet runs in a fresh isolate, which is then thrown away ([Dynamic Workers post](https://blog.cloudflare.com/dynamic-workers/)).
2. **Code memory (ours).** If the code is the plan, then the code an agent writes over time is its experience, and today it's thrown away with the isolate. We keep it:
- **Phase 1, durable:** every Code Mode execution is saved to the agent's own Cloudflare Artifacts repo.
- **Phase 2, learning:** Workers AI embeddings and Vectorize let the next agent start from the closest code other agents already ran. That measurably improves agent outcomes.

**Tagline:** throw away the isolate, keep the code.
**Title:** Self-Improving Code Mode Workers, with Artifacts Memory. The package stays `codemode-git`.

**Tagline:** keep the code, and your Workers get smarter over time.

**Vocabulary:** say "Cloudflare Artifacts" and "code memory", not "git". Artifacts speaks Git, so mention once that any git client can read it, and move on. We are not pitching a reimagined GitHub.

Expand All @@ -21,18 +26,34 @@
| Concurrency, coordination, context preservation, review, conflict handling | 25% | Context preservation is Phase 1. Concurrency: the swarm, with one writer per Artifacts repo and no conflicts. Coordination: retrieval plus provenance. Review: memory is shown as unverified, and every example links to its source |
| Ease of use and product experience | 25% | Three lines in an existing Code Mode agent, `npm install`, the Deploy button |

## Run of show (~8:00)
## Run of show (~5:15)

The video is code: [demo/video](demo/video). [transcript.md](demo/video/transcript.md) holds every voiceover line, so treat it as the source of truth for the narration. Edit it and run `npm run voiceover`.

**Style:** a keynote talk, not a slide deck. Each scene is one idea, shown as an animated diagram, often a before and after. On-screen text is a few words at most, the voiceover carries the detail, and animations are timed to the spoken word. Keep the technical depth (outbox, isomorphic-git, embeddings), because the audience is technical.

| Time | Beat | On screen | Voiceover (draft) |
| # | Scene | Diagram | Point |
|---|---|---|---|
| 0:00–0:30 | **Cold open** | Cloudflare's lava lamp wall (LavaRand), then split screen. Agent michelle: "How many lava lamps on the wall are flowing right now?", taking [N] executions to work out that the wall is paginated. Agent matthew: "How many red lava lamps are flowing?", taking one execution | "Cloudflare's lobby has a wall of about a hundred lava lamps, and a camera turns the moving wax into randomness for encryption. Here are two Code Mode agents checking on that wall, with two similar questions. The first one figures it out the hard way. The second gets it right the first time, because it can read the code the first one wrote. This is codemode-git: code memory for Code Mode agents, on Cloudflare Artifacts." |
| 0:30–1:30 | **Punch 1: why Code Mode** | Left: the same task as a chain of individual tool calls, each result going back through the model. Right: one function that walks every page of `lamps.wall` and returns a number | "Cloudflare's Code Mode insight: models are much better at writing code than at calling tools one at a time. They've seen millions of real programs. So instead of ten tool calls, the agent writes one function: loop over every page of the wall, filter, count, return. Cloudflare calls that code a compact plan." |
| 1:30–2:00 | **The gap** | The isolate lifecycle: load → run → discard. The code fades out with it | "Each plan runs in a fresh isolate that's thrown away afterward, which is exactly right for the sandbox. But the plan goes too. The next agent with the same kind of question starts from zero." |
| 2:00–3:15 | **Punch 2, Phase 1: code memory on Artifacts** | The three-line diff. michelle's Artifacts repo: `run.js`, `calls.jsonl`, `result.json`, with the `Codemode-*` trailers in the commit message. One shot of `git clone` | "Add one connector. Every execution is saved to that agent's own Cloudflare Artifacts repo: the code it ran, every tool call with its result, and the outcome. Artifacts gives every agent its own repo, at any scale. It speaks Git, so any git client can read it, but nobody has to. Agents read their own history back with two tools." |
| 3:15–3:45 | **Memory at fleet scale** | `scripts/swarm.mjs` summary. Artifacts dashboard metrics | "[1,000] agents at once: [1,000] Durable Objects, each writing to its own Artifacts repo, [N] runs saved per second, zero conflicts. Each agent is the only writer to its repo, so there's nothing to lock and nothing to merge." |
| 3:45–5:00 | **Phase 2: learning from code memory** | Diagram: saved run → Workers AI embedding of question + code → Vectorize. matthew's question → nearest runs → prompt, labeled unverified. matthew's commit with `Codemode-Examples: agent-michelle@<sha>`, then michelle's run it points to | "When a run produces an answer, Workers AI embeds the question and the code into Vectorize. matthew's question is similar to michelle's, so matthew starts with michelle's code, labeled unverified. matthew still writes and runs its own code, but already knows the wall is paginated. Its saved run records exactly which memory it used, so every answer traces back to the code that informed it." |
| 5:00–6:50 | **Deep dive: the benchmark** | DABstep: 450 payments-analysis tasks from Adyen. Learning-curve chart. Official accuracy by level. Small table: code runs 13.8 → 9.4, step-limit exhaustion 13% → 7%, Workers AI spend $26.76. Then a two-column slide: distilled skills vs raw runs | "Does it hold up on real investigations? DABstep is 450 data-analysis tasks over Adyen's payments data, the kind of work Code Mode is built for. Same model, same prompt, scored by Adyen's official scorer. Accuracy goes from 32 to 46 percent, and from 23.5 to 38.6 on hard tasks. The curve shows the learning. For the first eight tasks there's no memory, and both arms cost the same. Within about 25 tasks, the memory arm's median cost falls to about a third of baseline and stays there. One more finding: we first distilled runs into verified, shared skills. That made agents wrong together, because one bad skill spread. Raw runs, labeled unverified, worked better." |
| 6:50–8:00 | **Use it, what's next, close** | `npm install @smithclay/codemode-git`, the three lines, the Deploy to Cloudflare button. An architecture slide: Workers, Worker Loader, Durable Objects, Artifacts, Workers AI, Vectorize, cf CLI, Workers Builds. Closing line | "It's on npm. It's three lines in a Code Mode agent, plus a Deploy to Cloudflare button. Next: index runs as they're pushed, using Artifacts events, and record outcomes alongside the code. Code Mode made code the way agents act. Artifacts makes it the way they remember. Throw away the isolate. Keep the code." |
| 1 | **Thesis** | "What if Cloudflare Artifacts could make Code Mode self-improving?", built phrase by phrase, then the name | The hook is the thesis |
| 2 | **We tried it** | 32.2% → 46.2% counter. "Hard tasks: 23.5% → 38.6%". "+ memory" | The result, as proof of the thesis: same model, same prompt |
| 3 | **Every agent starts from zero** | A grid of agents, each writing code that dissolves | The problem |
| 4 | **Code Mode** | Before: model ⇄ tools ping-pong. After: one program in an isolate | Brief context; the code is the plan |
| 5 | **The gap** | The isolate collapses, and the code falls away | The plan is thrown away |
| 6 | **Phase 1: code memory** | Agents → their own Artifacts repos, with commits stacking up | 1 repo per agent, 1 writer per repo, 0 merges |
| 7 | **Under the hood** | execution ends → Durable Object SQLite outbox → isomorphic-git → Artifacts | How the write path works |
| 8 | **Every attempt, in git** (≥30s) | `git log` of an agent: error, fix, answer | Slot for a VHS recording |
| 9 | **One repo per agent** (≥25s) | 1,000 squares lighting up | Slot for the swarm recording |
| 10 | **Phase 2: learning** | michelle's repo → Workers AI → Vectorize → matthew. A provenance arrow back | Retrieval and `Codemode-Examples` |
| 11 | **Lava lamp wall** (≥60s) | michelle and matthew lanes: runs ✓/✗ and token bars | Slot for the real `walkthrough.mjs` run |
| 12 | **Learning curve** | Median tokens by run position, baseline vs memory | Cold start, then about a third |
| 13 | **Accuracy** | Overall 32.2 → 46.2, hard 23.5 → 38.6 | Right more often, not just cheaper |
| 14 | **Which memory works** | A shared skill hub spreading red to every agent, vs independent raw runs | The skills finding |
| 15 | **Next steps** | Three cards: record outcomes (git notes), index on push (Artifacts events), learn between tasks | What's next |
| 16 | **A new Worker** (≥40s) | VHS recording: `cf init` → install → connector and bindings → `cf deploy --dry-run` | How to start |
| 17 | **Close** | `npm install`, three lines of code, the tagline over the lava wall | Use it |
| 18 | **Credits** | Built by Clay Smith; tech stack credits for the code, benchmark and presentation | Exit slide |

**Recording slots:** scenes 8, 9 and 11 show placeholders until a recording is added. To add one, put it at `demo/video/public/clips/<scene>.mp4` and add the scene id to `public/clips/index.json`. Without recordings the video runs about 3:45. The three recordings add about 80s, which brings it just over the 5-minute minimum; `npm run voiceover` prints the current runtime.

## The walkthrough (michelle → matthew)

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# codemode-git
# Self-Improving Code Mode Workers, with Artifacts Memory

[![CI](https://github.com/smithclay/codemode-git/actions/workflows/ci.yml/badge.svg)](https://github.com/smithclay/codemode-git/actions/workflows/ci.yml)
[![npm](https://img.shields.io/npm/v/@smithclay/codemode-git)](https://www.npmjs.com/package/@smithclay/codemode-git)
Expand All @@ -7,7 +7,7 @@

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/smithclay/codemode-git/tree/main/examples/agent)

**Code memory for Code Mode agents, on Cloudflare Artifacts.** Throw away the isolate, keep the code.
**`codemode-git` gives Code Mode agents code memory on Cloudflare Artifacts.** Keep the code, and your Workers get smarter over time.

Every [Code Mode](https://www.npmjs.com/package/@cloudflare/codemode) execution becomes a git commit on that agent's own [Cloudflare Artifacts](https://developers.cloudflare.com/artifacts/) repo. Clone it with plain `git` and `git log -p run.js` is the agent's trajectory.

Expand Down
5 changes: 5 additions & 0 deletions demo/video/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules/
out/
.wrangler/
.cloudflare/
frames-*/
25 changes: 25 additions & 0 deletions demo/video/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Demo video

The competition demo, built with [Remotion](https://www.remotion.dev/). The voiceover is generated on Workers AI with Deepgram Aura-2 (`@cf/deepgram/aura-2-en`), and Whisper (`@cf/openai/whisper`) supplies word timings for the captions. The narration is in [transcript.md](transcript.md), one `## <scene>` section per scene. Scene order, diagrams and recording slots are in [src/script.ts](src/script.ts). The run of show it follows is in [DEMO.md](../../DEMO.md).

This package sits outside the repo's npm workspaces, so Remotion's headless Chrome doesn't affect CI or the library install.

```bash
npm install
npm run tts-worker # terminal 1: local Worker with a Workers AI binding, using your cf login
npm run voiceover # terminal 2: regenerates audio for edited sections of transcript.md, then prints the runtime
npm run studio # preview and scrub in the browser
npm run render # out/demo.mp4
```

To skip the local Worker, set `CLOUDFLARE_API_TOKEN` (with Workers AI access) and `CLOUDFLARE_ACCOUNT_ID`, and `npm run voiceover` calls the REST API instead.

**How timing works:**
- Each scene lasts as long as its voiceover, plus a 0.2s lead-in and a 0.6s hold (`LEAD_IN` and `HOLD` in `src/script.ts`). Keep them small, or they read as dead air.
- Captions use the transcript text the audio was generated from, with Whisper's timings, because Whisper mishears names like "Cloudflare".

**Cost:** a full regeneration of the voiceover is about 2,850 characters, roughly $0.09 at Aura-2's $0.03 per 1,000 characters. Whisper adds a fraction of a cent.

**Recordings:** a scene shows `public/clips/<scene>.mp4` instead of its diagram when the scene id is listed in `public/clips/index.json`. Scenes with `minSeconds` in the script stretch to that length once their recording exists (the git log, the swarm, and the michelle → matthew run). Until then they last only as long as their narration, so there's no silent padding.

**Terminal recordings:** `npm run record` records [terminal/new-worker.tape](terminal/new-worker.tape) with [VHS](https://github.com/charmbracelet/vhs): `cf init`, installing Code Mode and codemode-git, the connector and bindings, and `cf deploy --dry-run` (nothing is deployed). [scripts/record.mjs](scripts/record.mjs) then encodes the clip to `public/clips/new-worker.mp4` and lists it in `public/clips/index.json`. VHS's own encoding fails silently with ffmpeg 9, so VHS writes frames and ffmpeg does the encoding. The recording turns off npm's minimum-release-age check for its own shell only, because the `cf init` template pins a `cf` beta that is less than a week old.
15 changes: 15 additions & 0 deletions demo/video/cloudflare.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { bindings, defineConfig } from "cf/config";

// A local helper Worker for the video pipeline: `cf dev` runs it with your cf
// login, and scripts/voiceover.mjs calls it for text-to-speech and captions.
// The Workers AI binding always runs remotely, so no API token is needed.
export default defineConfig({
worker: {
name: "codemode-git-voiceover",
compatibilityDate: "2026-09-30",
entrypoint: "worker/index.ts",
env: {
AI: bindings.ai()
}
}
});
Loading
Loading