# Make your own event-sourced agent harness using stream processors

Misha Kaletsky · Jonas Templestein

AI Engineer Europe 2026

[Talk page](https://ai.engineer/talks/vi-2nasppAg-make-your-own-event-sourced-agent-harness) · [Video](https://www.youtube.com/watch?v=vi-2nasppAg)

## Make your own event-sourced agent harness using stream processors

An append-only log, synchronous reducers, and explicit side effects provide the building blocks for a debuggable agent harness whose extensions can run on different machines.

Familiarity with TypeScript, HTTP requests, and streaming API responses will help; event sourcing and processor runtimes are explained as they appear.

### What happened outside the agent’s log?

[0:16](https://www.youtube.com/watch?v=vi-2nasppAg&t=16s)

An agent already keeps a history of messages and actions. Why should debugging it require finding a side effect that appears only in an OpenTelemetry trace? The starting problem for Jonas Templestein and Misha Kaletsky’s workshop is that an agent’s existing log often stops short of describing everything it does. **Make every occurrence an event**, and that log becomes the place to reconstruct what happened and decide what happens next. The Iterate team is exploring that idea with an experimental SDK pushed immediately before the session.

The next requirement is extensibility. Pi provides an example of how useful extensions can be when both people and agents can write them. Jonas wants independently developed extensions to compose without all running in one process on one computer. An agent should also receive a URL as soon as it exists: a Slack webhook or a human’s web-form submission can then become ordinary HTTP input. The workshop deployment has no authentication, so participants can inspect one another’s streams and agents. Event payloads must not contain secrets; exposed credentials need rotation.

Distribution follows from that interface. One processor might run on a server, another on a laptop; one can be written in Rust and another in TypeScript. They coordinate through events rather than shared process memory. That freedom also admits race conditions and feedback loops: two plugins can keep responding to one another forever. Those failure modes must become part of the harness design.

![GitHub document headed “What are we doing here?” lists harness goals, a durable stream API, and stream processors.](https://ai.engineer/api/talk-essay-media/d72f988c4a29e50a5dccf48c17ce6046f47b44f523baf8e1abba7d85528cae5a)

Workshop goals and the two ingredients for an event-sourced agent harness.

### Append Hello World, then watch it arrive

[5:18](https://www.youtube.com/watch?v=vi-2nasppAg&t=318s)

The primitive is a hosted event store at `events.iterate.com`. Its web interface displays raw events as YAML beneath hierarchical paths, much like files in a filesystem. Paths begin with `/`, and the service tolerates URL-encoded slashes. The [workshop repository](https://github.com/iterate/ai-engineer-workshop) and its [workshop instructions](https://github.com/iterate/ai-engineer-workshop/blob/main/workshop.md) supply the cURL exercises. They target the live proof of concept; participants do not deploy a server of their own. A project slug, also passable through an HTTP header, selects a separate database namespace when participants need isolation from one another’s experiments.

Jonas appends Hello World to his stream. The returned envelope establishes the data model:

| Field | Meaning |
| --- | --- |
| `type` | Required event discriminator |
| `payload` | Optional event data |
| Stream path | Taken from the request URL |
| Offset | Server-assigned integer, starting at 1 |
| Creation time | Timestamp assigned when the event is created |

The server is the serialization point: it assigns increasing offsets as events enter the log. A processor can therefore refer to a definite position in the stream rather than infer order from message contents.

A second terminal observes `/jonas-templestein/hello-world` through server-sent events. With `curl -N`, cURL does not buffer the arriving output; with `?live=true`, the connection remains open for subsequent appends. Another Hello World appears in that same subscription. The API draws inspiration from [Durable Streams](https://github.com/durable-streams/durable-streams), but Iterate does not implement that specification exactly. Extracting SSE `data` elements with `sed` and formatting them with `jq .` makes the raw stream easier to inspect. If Misha were watching the input and appending replies, the transport would already support the response loop that an agent will later automate.

### Errors and controls are events too

[10:34](https://www.youtube.com/watch?v=vi-2nasppAg&t=634s)

A permissive ingestion interface makes third-party webhooks easier to accept. Jonas’s premise is that an LLM can often interpret a webhook’s raw contents without a bespoke connector. When the submitted object lacks the required `type`, however, the server records an invalid-event error in the stream. Its own event types use documentation URLs as identifiers; callers can still use ordinary strings. An idempotency key handles a different problem: submitting the same key twice does not append the event twice.

Feedback loops require a stronger control. Jonas describes the workshop circuit breaker as pausing a stream at roughly more than 100 events per second. A pause can also be requested explicitly by appending a pause event. His first attempt needs a reason; adding `reason: demo` makes it succeed. A subsequent Hello World is rejected. **That rejection does not append an error event**, because doing so would let a runaway writer continue growing the supposedly paused log through errors. Processing can resume after an explicit resume event.

The same configuration-by-event pattern supports several other behaviors:

- **Transformation:** a JSONata transformer configuration tells a plugin which events to observe and how to rewrite them into new events.
- **Scheduling:** after resuming the paused stream, Jonas configures a heartbeat every five seconds. Scheduling can also target a future delay or a specific time, and a later event can cancel it.
- **Subscriptions:** an appended configuration can request delivery to a server or a Slack API endpoint. A pull subscriber opens an SSE connection; a push subscriber receives outbound notifications for all events or a filtered subset.

The stream now supplies inputs, timers, transformations, and notifications through one interface.

### Turn a subscription into a processor

[15:57](https://www.youtube.com/watch?v=vi-2nasppAg&t=957s)

Existing harnesses are already event-driven in many respects. The proposed difference is the API boundary. OpenCode, Pi, and Claude expose extension interfaces in which streaming chunks or other operations may have separate treatment. Here, even a few letters of a partial completion are ordinary events. A processor reduces those events into state and occasionally performs a side effect. Iterate has no launched product at this point; this is an experiment in making that interface sufficient for a harness.

The hosted service is storage—closer to a database than to an LLM response pipe. Jonas compares the programmable experience to Convex: a stream could receive an event containing processor source code and run that processor on later events. To support this architecture, the infrastructure must also wake external programs and APIs when they have work. The wire interface is language-independent, with API documentation and an OpenAPI specification; TypeScript is simply the workshop’s chosen client language.

The quick start uses the repository’s small example file and published npm client. Misha pushes a client-side type fix while participants follow along, and additional processor examples are copied into the repository during the session. The repository screenshot shows the starting files, including `00-example.ts`, `README.md`, `package.json`, and `workshop.md`. The linked repository has since evolved, so its current runtime names and commands should not be read as an exact snapshot of the code on screen.

![GitHub repository ai-engineer-workshop showing 00-example.ts, README.md, package.json, and workshop.md above the README.](https://ai.engineer/api/talk-essay-media/1d754d7c4d786936ed553b80d758cce94d041f031456b7f6b3a065750494e6d5)

The workshop repository includes an example file and workshop instructions.

The local response loop is small:

1. Install the dependencies with `pnpm install`.
2. Call `createEventsClient` with the server base URL and a path prefix.
3. Subscribe to a stream with `live: true`.
4. Ignore events whose type is not `ping`.
5. Use `client.append` to emit a `pong` for each relevant input.

The presenter’s initial Node attempt reports invalid TypeScript syntax, amid editor and terminal problems. Participants confirm ping/pong works, and after switching laptops the hello-world example runs successfully. That establishes the working baseline before the session attempts an agent processor using the OpenAI SDK.

### Reconstruct state before performing side effects

[30:17](https://www.youtube.com/watch?v=vi-2nasppAg&t=1817s)

The hello-world processor begins with a question: what state does this feature need? In this case, it needs the number of Hello World events encountered. A synchronous `reduce` function takes the current state and an event, then returns the next state. The processor abstraction can also treat no returned value as an ignored event. Side effects belong in `afterAppend`, outside the reducer.

![Code editor showing a hello-world processor with a count state, reduce function, and afterAppend function.](https://ai.engineer/api/talk-essay-media/585d05ab45b121c9dbfe44b355b889c338b948f6591e257fa5b0ae80c43978c3)

A hello-world stream processor separates state reduction from an after-append hook.

That separation matters during recovery. Close a laptop, allow 100 events to accumulate, then restart the processor. Issuing an LLM request while reducing each historical event could trigger a burst of obsolete work. Instead, the runtime first catches up to the end of the available log and then lets the effect hook decide what the reconstructed state requires. **Replay rebuilds knowledge; the effect hook acts on that knowledge.**

The counting part can be expressed independently of the subscription machinery:

```typescript
type StreamEvent = {
  type: string;
  payload?: unknown;
};

type CountState = {
  count: number;
};

function reduce(state: CountState, event: StreamEvent): CountState {
  if (event.type !== "hello-world") return state;
  return { count: state.count + 1 };
}

const events: StreamEvent[] = [
  { type: "hello-world" },
  { type: "ping" },
  { type: "hello-world" },
];

const state = events.reduce(reduce, { count: 0 });
// state.count is 2; reduction performs no external actions.
```

Appends performed by the effect hook need not target the same stream. Filesystem-like addressing allows a parent processor to append work to `./Boris`, then subscribe to a result event from that child path. Boris becomes a sub-agent through a routing and response convention; its result can wake the parent.

An exported processor is inert until a runtime drives it. The pull-subscription runtime owns the stream-consumption boilerplate, invokes the reducer, and runs `afterAppend`. Live wiring runs into a mismatch between older workshop-one examples and the intended workshop-two files, some of which are not yet committed. The test at `jonas/example` fails; a machine-derived `mmkal` path is suggested as one possible cause. With dependencies still installing, Jonas switches to a walkthrough instead of establishing a successful run of the more complex processor.

### Derive the LLM request from state

[38:30](https://www.youtube.com/watch?v=vi-2nasppAg&t=2310s)

The next feature starts from the desired action: when someone adds agent input, make an LLM request. The UI shortcut creates an agent-input-added event with a string payload. An OpenAI client’s `openai.responses.create` call needs a model, instructions, and input history, so those become the processor’s initial state fields.

| State | Role in the request |
| --- | --- |
| Model string | Selects the model |
| System prompt | Supplies `instructions` |
| History | Supplies conversation input |

A proposed model-change event would update the model field through a small reducer branch. Additional capabilities could introduce state such as compaction status or a tool call in progress. The walkthrough initializes an empty history, a system prompt, and **GPT-5.4**.

Next come the facts needed to derive that state. A Zod schema describes the string input event. Everything returned by OpenAI—including a small streaming fragment—is stored as another event. The log therefore retains more detail than the finished conversation view needs.

A last-minute rewrite by a coding agent has changed the displayed examples substantially, but the input transformation remains straightforward. The walkthrough uses a Zod matching helper credited to Misha for payload type safety. An agent input string becomes a Responses API history item with `role: "user"` and the string in `content`. This small reducer expresses that transformation for the input `hi`:

```typescript
type HistoryItem = {
  role: "user";
  content: string;
};

type AgentState = {
  model: string;
  systemPrompt: string;
  history: HistoryItem[];
};

type InputAdded = {
  type: "agent-input-added";
  payload: string;
};

function addInput(state: AgentState, event: InputAdded): AgentState {
  return {
    ...state,
    history: [
      ...state.history,
      { role: "user", content: event.payload },
    ],
  };
}

const initial: AgentState = {
  model: "gpt-5.4",
  systemPrompt: "Respond helpfully.",
  history: [],
};

const next = addInput(initial, {
  type: "agent-input-added",
  payload: "hi",
});
```

The model and prompt stay unchanged; the history gains one user item. Making the request remains a separate side effect.

Response handling is less settled in the live example. Streaming produces many events, followed by an end event, but the walkthrough does not finish the completion-handling branch or establish its exact event identifier. The screenshot retains the visible TODO. Workshop two is pushed largely as-is; Misha subsequently encounters insufficient quota, and the full live agent build is abandoned. The working baseline remains ping/pong, while the architecture still permits processors to run on separate servers or in dynamic workers.

![Code editor showing history updates in a reducer, a TODO in response handling, and an afterAppend block below.](https://ai.engineer/api/talk-essay-media/434f1ee4c14d2b3775a22efd6340eadd402e6a4370a57891642b1a03efd1ca5d)

Agent history reduction with unfinished response-event handling.

### One persisted stream, many derived views

[46:50](https://www.youtube.com/watch?v=vi-2nasppAg&t=2810s)

An audience question separates two concepts that are easy to conflate: are streaming chunks persisted, or does a client materialize them first? Every chunk enters the event stream. Reducers can then run in many places and build the state each consumer needs. Persisting the raw facts does not require every derived view to become another persisted event.

The service’s circuit breaker provides a concrete example. Jonas shows a processor he describes as running in the live service, initialized with `paused: false` and a null pause reason. Its reducer retains the last 100 event timestamps; its effect hook trips the breaker when that window fits within approximately one second. The reducer accumulates evidence, and `afterAppend` acts on it.

The UI follows the same pattern. It projects selected events into more readable feed items. A feed item is derived state, not the underlying event itself. Because a reducer is a synchronous function, another processor can import and reuse it, then build additional behavior on the same event types. Jonas extends this idea to Pi, Claude, and OpenCode: their events could enter the shared log, with other processors interpreting or extending them. He also describes source-code events as a route to automatically hosted, horizontally scalable processing and promises a fuller demonstration later.

### Deploy behavior by appending JavaScript

[50:28](https://www.youtube.com/watch?v=vi-2nasppAg&t=3028s)

The dynamic-worker demonstration makes the deployment mechanism visible. Posting to an unused path implicitly creates a stream. In the UI, Jonas chooses a Dynamic Worker Configured preset containing a `script` string; that string holds a reducer and an after-append hook. Appending the configuration installs the ping-pong worker in the stream.

![Events interface showing a “Dynamic Worker Configured” card labeled ping-pong, script text in the composer, and an “Event appended” notification.](https://ai.engineer/api/talk-essay-media/8e536236dc7d1203152f0701e47b41b23497a57188151c0d63a53037196fbee3)

The stream displays a configured ping-pong worker after the event is appended.

He then submits `ping`, and the stream produces `pong`. The stream began with no response behavior; an event containing JavaScript supplied it. This is the successful live code-as-event demonstration. Processor files can also be bundled into an event rather than entered directly into the UI. Jonas reports having run an AI agent this way previously, but the full AI version is not demonstrated here.

Credentials introduce a boundary the event log should not cross. Jonas describes keeping the OpenAI key outside the stream in environment variables, then substituting the secret into the header of an outgoing fetch request. He characterizes a basic agent as roughly 40 lines that can be appended to turn a stream into an agent. Directly entered scripts cannot depend on separately installed npm packages: those dependencies must be bundled into the script string.

A URL-safe slug identifies the worker configuration, allowing a later configuration event to replace it. That also gives an agent a path to self-extension: append different JavaScript under the configuration identifier. Jonas proposes a further layer in which an unbundled-worker event carries a `package.json` field and a script field. A separate bundling processor would turn that input into the complete executable configuration event. Such a workflow could resemble an IDE built from cooperating processors, though that bundling extension remains a proposal.

### Error events and execution locations

[54:31](https://www.youtube.com/watch?v=vi-2nasppAg&t=3271s)

What happens when the appended JavaScript is wrong? The current evaluator runs JavaScript without TypeScript checking; Jonas says execution failures should produce error events. A proposed compilation stage could emit TypeScript diagnostics in the same way, after which an LLM could consume the error and append corrected code. The settled interface shown during this discussion contains the configured ping-pong worker, ping and pong entries, and an error card reading `Failed to fetch remote state.` That card illustrates an error appearing in the stream, without establishing a completed compiler-and-repair loop.

![Events interface showing a configured ping-pong worker, ping and pong entries, and an error card reading “Failed to fetch remote state.”](https://ai.engineer/api/talk-essay-media/5e760e49e6e48525db87efa1c09bde802410caeda8b08b9052773f9bc734085c)

An error appears as an event in the stream.

For hosted execution, this implementation uses [Cloudflare Dynamic Workers](https://developers.cloudflare.com/dynamic-workers/getting-started/). The processor can move through three execution arrangements:

| Arrangement | How work reaches the processor |
| --- | --- |
| Local process | It subscribes through SSE |
| Hosted HTTP service | The stream pushes notifications |
| Dynamic worker | A configuration event supplies the code |

A developer can experiment locally, then host the processor on Cloudflare Workers, Vercel, or another service, or package it into the dynamic-worker configuration. The event interface stays central while the execution location changes.

### Let remote plugins contribute without blocking forever

[56:30](https://www.youtube.com/watch?v=vi-2nasppAg&t=3390s)

A remote prompt-injection checker illustrates why push notifications matter. Rather than require the model to explicitly call every plugin, the stream could notify an independently operated service that a new request is being prepared. Jonas proposes waiting up to 200 milliseconds before an LLM request for a checker’s contribution. His MCP comparison concerns the proactive agent-loop integration he wanted at the time, rather than all forms of server-initiated interaction. The checker could run elsewhere and charge for its service, initially billing the human.

The Claude Code plugin example makes the integration burden concrete: a service may otherwise need instructions prompting the model to call an MCP tool, or an authenticated CLI that the model must invoke. Event-stream participation gives the service another route. It observes that the agent is about to act and appends information for the loop to consume.

There is a deliberate limit: third-party processors have no before-append hook. Built-in processors can prevent an event from entering the stream, which is why a third party cannot enforce the same pause behavior. Jonas prefers this boundary to broadly available before hooks, citing OpenClaw caching, performance, and cost problems he attributes to them.

The alternative is an eventually consistent loop with a bounded contribution window. Once the wait expires, the LLM request proceeds even if a plugin has not responded. A processor holding an indexed Notion knowledge base could opportunistically add relevant retrieval context; arriving late would not hold the agent indefinitely. This is a useful resilience policy for optional context. Applied to the earlier safety-checker example, however, it does not guarantee that a safety check finishes before the request proceeds.

### Who tracks delivery, and who may submit work?

[1:00:16](https://www.youtube.com/watch?v=vi-2nasppAg&t=3616s)

The architecture does not settle whether everyone should run their own event service or share a central one. Jonas expects it could use other infrastructure shaped like a durable stream. The desired primitive combines an append-only database, a queue, pub/sub delivery, and code execution. Electric’s Durable Streams and [NATS JetStream](https://docs.nats.io/learn/jetstream/pull-consumers) provide reference points, with push subscriptions especially useful for waking processors.

Offset ownership determines how a consumer resumes:

| Delivery model | Who manages the consumption position? |
| --- | --- |
| Client-driven replay | The client tracks its last consumed offset |
| Managed subscription | The service tracks delivery progress |

Jonas uses Durable Streams and Kafka to illustrate client-controlled consumption, then contrasts Google Cloud and AWS pub/sub services that manage delivery position for subscribers. These are different responsibilities around an ordered log, not interchangeable delivery guarantees.

The final audience example exposes the consequence of making agents publicly reachable. Suppose an `images` child path forwards requests to a local image-generating model and returns results. Anyone able to append could consume that machine’s resources. Asked how to prevent flooding, Jonas says authentication is necessary and agrees that this should not yet be exposed that way. A disposable public namespace cleared periodically is floated as an experimental convenience, not a protection for valuable computation.

A more complete design would attach client provenance to each event: who submitted it, what capabilities they had, and the basis for believing they were authorized. Access-policy changes could themselves be events. Jonas proposes creator-only writes by default, followed by an explicit event making the stream public. Those controls are future work, but they identify the boundary the public demo leaves open: **a stream can make useful computation easy to reach only if the service also decides who is entitled to trigger it.**

## Resources

- [AI Engineer workshop repository](https://github.com/iterate/ai-engineer-workshop) — Experimental event-sourced harness examples, TypeScript client usage, processor structure, and deployment instructions.
- [Workshop walkthrough](https://github.com/iterate/ai-engineer-workshop/blob/main/workshop.md) — cURL exercises and a progression from ping/pong to conversation history, catch-up processing, and LLM requests. Includes the public-server security warning.
- [Durable Streams](https://github.com/durable-streams/durable-streams) — HTTP streaming protocol and implementations supporting ordered replay, resumable reads, and live tailing.
- [Dynamic Workers getting started](https://developers.cloudflare.com/dynamic-workers/getting-started/) — Current instructions for loading code into sandboxed Workers at runtime and controlling available bindings and network access.
- [JetStream pull consumers](https://docs.nats.io/learn/jetstream/pull-consumers) — Batch and continuous message consumption with explicit acknowledgments and consumer cursor tracking.

## Slides

### AI Engineer Europe

[0:00](https://www.youtube.com/watch?v=vi-2nasppAg&t=0s) [AI Engineer Europe logo in white on black.](https://assets.ai.engineer/sites/aiecode2025/sha256/aab59c7da120f8504a96c9b8622254406bbff88706e2388a912d6dcc744c1118.webp)

AI Engineer
EUROPE

### Presenting sponsor

Google DeepMind is the presenting sponsor.

[0:05](https://www.youtube.com/watch?v=vi-2nasppAg&t=5s) [Google DeepMind named as presenting sponsor.](https://assets.ai.engineer/sites/aiecode2025/sha256/22e8cb940ef752894fb0f47ce4cfbb7a04b212fd252bdf1347f3f5879fa393f3.webp)

PRESENTING SPONSOR

Google DeepMind

### Platinum sponsors

[0:10](https://www.youtube.com/watch?v=vi-2nasppAg&t=10s) [Braintrust, WorkOS and OpenAI listed as platinum sponsors.](https://assets.ai.engineer/sites/aiecode2025/sha256/67ab02436dd05f7c1485033a65722f97f0b078c42a9d9d476423e5326db72811.webp)

PLATINUM SPONSORS

Braintrust
WorkOS
OpenAI

### Workshop overview

The workshop builds an event-sourced agent from two ingredients: a stream API for appending and reading events, and processors that reduce events into state and run after an append.

[1:05](https://www.youtube.com/watch?v=vi-2nasppAg&t=65s) [Workshop README describes event-sourced agent harnesses, a durable stream API and stream processors.](https://assets.ai.engineer/sites/aiecode2025/sha256/8c83b830fb933bd8e6d7cd5f5f801ec0f7eb9caca6d7ece9718f593e73016422.webp)

What are we doing here?

I love making agent harnesses

And this is how I'd like to make them

• Purely event sourced (aka "Debuggable")
• Extensible with good composability
• On the edge / publicly routable
• Distributed

In this workshop we will build an AI agent entirely from scratch using only two ingredients:

1. A durable stream API that supports
• .append({ path, event })
• .stream({ path })

2. Stream processors that implement
• .reduce({ event, state })
• .afterAppend({ append, event, state })

WARNING!

Interface text:
Chrome  File  Edit  View  History  Bookmarks  Profiles  Tab  Window  Help
Wed 8 Apr 10:44
iterate/ai-engineer-workshop
github.com/iterate/iterate/tree/main/ai-engineer-workshop
New Chrome available
Files
main
Go to file
.agents
.claude
.cursor
.github
.husky
.opencode
.superset
.vscode
ai-engineer-workshop
deploy
deployed-processor
lib
workshop
workshop2
AGENTS.md
README.md
cli.ts
contract.ts
events-client.ts
iterate / ai-engineer-workshop /
Top

### Stream hello world

The README shows curl commands to append a hello-world event and read its stream. It warns that the service currently has no authentication, so don't put secrets in streams.

[5:04](https://www.youtube.com/watch?v=vi-2nasppAg&t=304s) [Workshop README shows an authentication warning and commands for a hello-world stream.](https://assets.ai.engineer/sites/aiecode2025/sha256/e5e4e0729cad7be5b827cf1744ee6a628e46e3f8f077825b3d6f1cf41ec5e18b.webp)

• .append({ path, event })
• .stream({ path })

2. Stream processors that implement
• .reduce({ event, state })
• .afterAppend({ append, event, state })

WARNING!

You'll be able to play with this events.iterate.com service - it currently has no authentication. Don't put any secrets in your streams!

Hello world

export PATH_PREFIX="/$(id -un)"
export BASE_URL="https://events.iterate.com"
export STREAM_PATH="${PATH_PREFIX}/hello-world"

curl --json '{"type":"hello-world"}' \
  "${BASE_URL}/api/streams${STREAM_PATH}"

curl -N "${BASE_URL}/api/streams${STREAM_PATH}"

The thesis

Interface text:
Chrome  File  Edit  View  History  Bookmarks  Profiles  Tab  Window  Help
Wed 8 Apr 10:47
iterate/ai-engineer-workshop
github.com/iterate/iterate/tree/main/ai-engineer-workshop
New Chrome available
iterate / ai-engineer-workshop /  Top
Files
main
Go to file
.agents
.claude
.cursor
.github
.husky
.opencode
.superset
.vscode
ai-engineer-workshop
  deploy
  deployed-processor
  lib
  workshop
  workshop2
  AGENTS.md
  README.md
  cli.ts
  contract.ts
  events-client.ts

### Stream features and examples

The workshop starts with one stream and one event type, then introduces a processor that watches for ping and appends pong. The README also lists deduplication, pausing, transformations, schedules and child-stream observation.

[5:10](https://www.youtube.com/watch?v=vi-2nasppAg&t=310s) [Workshop README lists stream features, a script-form hello world and a ping-pong processor.](https://assets.ai.engineer/sites/aiecode2025/sha256/719bb78e55b120029c2b7200fca80e69987c4093081e886504834aeb072d3917.webp)

Nice stream features

• idempotencyKey prevents duplicate appends
• Pause and resume a stream
• JSONata transformers can derive new events
• Schedules can append future events
• Parent paths observe child-stream creation

Hello world in script form

• Start with one stream
• One process
• One event type
• No runtime yet

The goal is to get comfortable with the raw API shape first.

Ping pong

• Watch a stream
• If an event is ping, append pong
• This is the first "derived event" processor shape

That tiny loop is enough to explain the whole architecture.

Interface text:
Chrome  File  Edit  View  History  Bookmarks  Profiles  Tab  Window  Help
Wed 8 Apr 10:47
iterate/ai-engineer-workshop
github.com/iterate/iterate/tree/main/ai-engineer-workshop
New Chrome available
Files
main
Go to file
.agents
.claude
.cursor
.github
.husky
.opencode
.superset
.vscode
ai-engineer-workshop
deploy
deployed-processor
lib
workshop
workshop2
AGENTS.md
README.md
cli.ts
contract.ts
events-client.ts
iterate / ai-engineer-workshop /  Top

### Playing with streams

The workshop uses cURL with events.iterate.com to append a hello-world event, read it back, and live-tail the stream. A user-specific path prefix helps keep streams apart.

[5:17](https://www.youtube.com/watch?v=vi-2nasppAg&t=317s) [Editor showing shell commands for creating and reading a stream, alongside a terminal and assistant panel.](https://assets.ai.engineer/sites/aiecode2025/sha256/c8eb87094c8bfbd4e816763426da93a50201171d24342045903eaf8b7752a3a8.webp)

# Playing with streams

Here's how you use them:

# Like files, a "stream" is identified by a "path" that starts with a slash
# Let's give ourselves a unique path prefix so we don't collide with other people
# My prefix will be /jonastemplestein
export PATH_PREFIX="/$(id -un)"
export BASE_URL="https://events.iterate.com"
export STREAM_PATH="${PATH_PREFIX}/hello-world"

# Let's create our first event
curl --json '{"type": "hello-world"}' \
  "${BASE_URL}/api/streams${STREAM_PATH}"

# Let's see if it's there
curl -N "${BASE_URL}/api/streams${STREAM_PATH}"

# We can also live tail the stream with pretty printing (start this in a new tab)
curl -sN "${BASE_URL}/api/streams${STREAM_PATH}?live=true" | sed -nu 's/^data: //p' | jq .

# Can also append hogwash!

Interface text:
Cursor: workshop.md; bashmode.ts; README.md; 06-nano-agent-with-streaming-llm-processor.ts
ai-engineer-workshop > workshop.md > # Playing with streams
Review Next File; Preview; Markdown

Terminal:
create mode 100644 ai-engineer-workshop/workshop2/bashmode.test.ts
create mode 100644 ai-engineer-workshop/workshop2/bashmode.ts
secretive-waiter on git secretive-waiter via docker orbstack via nodejs v24.4.0
> git push origin
To https://github.com/iterate/iterate.git
! [rejected] secretive-waiter -> secretive-waiter (non-fast-forward)
error: failed to push some refs to 'https://github.com/iterate/iterate.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Assistant panel: Commit and force push process
commit and push everything - force push it
Checking git status and current branch, then staging, committing, and force-pushing.
Staging all changes, committing, and force-pushing branch secretive-waiter (diverged from origin).
Here's what ran:
1. git add -A — staged everything (there were 5 modified files under ai-engineer-workshop/workshop2/).
2. Commit — a9e40d7f with message: Update workshop2 nano-agent and LLM processor scripts (lint-staged ran oxfmt on those files).
3. Push — git push --force-with-lease origin secretive-waiter so secretive-waiter on GitHub matches your local branch (replacing the previous remote tip).
I used --force-with-lease instead of bare --force so the push still fails if the remote moved in a way you haven't fetched; the update went through successfully. If you strictly need git push --force, say so and we can use that next time.

### Streams overview

The Events interface shows a hierarchy of stream paths beside child-stream creation and durable-object wake-up events. A JSON composer at the bottom is ready to append an event.

[5:25](https://www.youtube.com/watch?v=vi-2nasppAg&t=325s) [Events interface showing a stream tree and child-stream creation events.](https://assets.ai.engineer/sites/aiecode2025/sha256/f996a923eb77d13f627d4c58d27df2a72994105d1a2440b788fb91b548b2eef9.webp)

Events
durable streams

Streams
Env vars
Streams

Create stream
Filter streams
/  6
  /boop
  /jonas  2
  /workshop2  1

CHILD STREAM CREATED
./jonas/00
https://events.iterate.com/events/stream/child-stream-created · +9ms · 10:37:43

CHILD STREAM CREATED
./jonas
https://events.iterate.com/events/stream/durable-object-constructed · +2m8s · 10:39:51

DURABLE OBJECT WOKE UP
https://events.iterate.com/events/stream/child-stream-created · +902ms · 10:39:52

CHILD STREAM CREATED
./boop
https://events.iterate.com/events/stream/durable-object-constructed · +5m56s · 10:45:49

DURABLE OBJECT WOKE UP
https://events.iterate.com/events/stream/child-stream-created · +36.1s · 10:46:25

CHILD STREAM CREATED
./workshop2/sdk-smoke-1775641583878
https://events.iterate.com/events/stream/child-stream-created · +906ms · 10:46:26

CHILD STREAM CREATED
./workshop2

{
  "type": "https://events.iterate.com/manual-event-appended",
  "payload": {
    "message": "hello"
  }
}

JSON  YAML  Agent  Manual Event Appended

PROJECT SLUG
public
Apply

Interface text:
Chrome  File  Edit  View  History  Bookmarks  Profiles  Tab  Window  Help
Wed 8 Apr 10:48
iterate/ai-engineer-workshop
Events
events.iterate.com/streams/?renderer=raw-pretty&composer=json&projectSlug=public
New Chrome available
Raw 10  Semantic 10  Raw + Pretty

### Raw parent-stream events

The parent path /jonas/00 contains YAML events for initialization, child-stream creation, and durable-object construction. The speaker presents events at hierarchical paths as the primitive for building the agent.

[5:50](https://www.youtube.com/watch?v=vi-2nasppAg&t=350s) [Raw YAML view of initialization, child creation, and durable-object events in a parent stream.](https://assets.ai.engineer/sites/aiecode2025/sha256/62a3425c26e71115a078276f1ebcfd83f904550721dbaba301d03fbeba4f508c.webp)

Streams / jonas / 00

- streamPath: /jonas/00
  type: https://events.iterate.com/events/stream/initialized
  payload:
    projectSlug: public
    path: /jonas/00
  offset: 1
  createdAt: 2026-04-08T09:37:43.672Z
- streamPath: /jonas/00
  type: https://events.iterate.com/events/stream/child-stream-created
  payload:
    childPath: /jonas/00/main-pin-check-20260408-3
  offset: 2
  createdAt: 2026-04-08T09:37:43.693Z
- streamPath: /jonas/00
  type: https://events.iterate.com/events/stream/durable-object-constructed
  payload: {}
  offset: 3
  createdAt: 2026-04-08T09:48:15.673Z

{
  "type": "https://events.iterate.com/manual-event-appended",
  "payload": {
    "message": "hello"
  }
}

Interface text:
Chrome  File  Edit  View  History  Bookmarks  Profiles  Tab  Window  Help
Wed 8 Apr 10:48
iterate/ai-engineer-workshop
Events
events.iterate.com/streams/jonas/00/?renderer=raw&composer=json&projectSlug=public
New Chrome available
Events
durable streams
Env vars
Streams
Create stream
Filter streams
/  6
/boop
/jonas  2
/00  1
/main-pin-check-20260408-3
/workshop2  1
Raw 3
Semantic 3
Raw
YAML
PROJECT SLUG
public
Apply
JSON  YAML  Agent
Manual Event Appended

### Raw child-stream events

The selected child path contains four YAML-formatted raw events: initialization, ping, pong, and durable-object construction. The speaker introduces these path-based events as the primitive for building the agent.

[5:55](https://www.youtube.com/watch?v=vi-2nasppAg&t=355s) [Raw YAML view of a child stream containing initialization, ping, pong, and durable-object events.](https://assets.ai.engineer/sites/aiecode2025/sha256/f9206660496bcf1fc758a91b988dd0e986a9830f182f75e913f4bd09d9950e4b.webp)

- streamPath: /jonas/00/main-pin-check-20260408-3
  type: https://events.iterate.com/events/stream/initialized
  payload:
    projectSlug: public
    path: /jonas/00/main-pin-check-20260408-3
  offset: 1
  createdAt: 2026-04-08T09:37:39.753Z
- streamPath: /jonas/00/main-pin-check-20260408-3
  type: ping
  payload: {}
  offset: 2
  createdAt: 2026-04-08T09:37:43.675Z
- streamPath: /jonas/00/main-pin-check-20260408-3
  type: pong
  payload: {}
  offset: 3
  createdAt: 2026-04-08T09:37:43.902Z
- streamPath: /jonas/00/main-pin-check-20260408-3
  type: https://events.iterate.com/events/stream/durable-object-constructed
  payload: {}
  offset: 4
  createdAt: 2026-04-08T09:48:22.714Z

{
  "type": "https://events.iterate.com/manual-event-appended",
  "payload": {
    "message": "hello"
  }
}

Interface text:
Events
durable streams
Env vars
Streams
Create stream
Filter streams
/  6
/boop
/jonas  2
/00  1
/main-pin-check-20260408-3
/workshop2  1
PROJECT SLUG
public
Apply
Streams / jonas / 00 / main-pin-check-20260408-3
Raw 4
Semantic 2
Raw
YAML
JSON
YAML
Agent
Manual Event Appended
Chrome
File Edit View History Bookmarks Profiles Tab Window Help
iterate/ai-engineer-workshop
Events
https://events.iterate.com/streams/jonas/00/main-pin-check-20260408-3/?renderer=raw&composer=json&projectSlug=public
New Chrome available
Wed 8 Apr 10:48

### Set up stream variables

The demo sets a path prefix from the current username, combines it with /hello-world for the stream path, and prints the prefix to check it.

[6:19](https://www.youtube.com/watch?v=vi-2nasppAg&t=379s) [Split terminal showing environment variable assignments and a printed path prefix.](https://assets.ai.engineer/sites/aiecode2025/sha256/09803af09ab72caf35bb623595b9589f87b62b8de22afa481f4ccc9573e1b922.webp)

export PATH_PREFIX="/$(id -un)"
export BASE_URL="https://events.iterate.com"
export STREAM_PATH="${PATH_PREFIX}/hello-world"

echo $PATH_PREFIX
/jonastemplestein

Interface text:
Ghostty  File  Edit  View  Window  Help
Wed 8 Apr 10:49
.../github.com/iterate/iterate
iterate on git main [$<] via docker orbstack via nodejs v24.4.0
9% >
5% >

### Workshop repository

Open workshop.md in the repository to copy and paste the curl commands used in the demo.

[7:02](https://www.youtube.com/watch?v=vi-2nasppAg&t=422s) [GitHub repository file list with workshop.md highlighted and the README below.](https://assets.ai.engineer/sites/aiecode2025/sha256/124ee4a83fd786d6f7dab4303dc7cee526b3cb900ed784f07a543c43b291f706.webp)

main
2 Branches
0 Tags
Go to file
Add file
Code

mmkal  add workshop.md
5064f05 · now
12 Commits

.gitignore  gitignore  7 minutes ago
00-example.ts  Reduce repo to one workshop example  9 minutes ago
README.md  add readme  7 minutes ago
package.json  Reduce repo to one workshop example  9 minutes ago
pnpm-lock.yaml  Reduce repo to one workshop example  9 minutes ago
tsconfig.json  Reduce repo to one workshop example  9 minutes ago
workshop.md  add workshop.md  now

README

AI engineer workshop

This directory is the publishable workshop package.

It intentionally does not contain the main workshop script collection anymore. The real scripts live in the separate workshop repo, while this package keeps a few tiny local examples and a scratch script.ts for experimentation.

• sdk.ts re-exports the shared runtime/client SDK from apps/events-contract/src/sdk.ts
• sdk.ts also exports lightweight network test helpers for workshop e2e tests
• contract.ts re-exports the shared contract from apps/events-contract/src/index.ts
• [illegible] workshop scripts from the current working directory

About
No description, website, or topics provided.
Readme
Activity
Custom properties
3 stars
0 watching
0 forks
Audit log
Report repository

Releases
No releases published
Create a new release

Packages
No packages published
Publish your first package

Contributors 2
jonastemplestein Jonas Templest...
mmkal Misha Kaletsky

Languages

Interface text:
Chrome  File  Edit  View  History  Bookmarks  Profiles  Tab  Window  Help
Wed 8 Apr 10:49
iterate/ai-engineer-workshop
Events
https://github.com/iterate/ai-engineer-workshop/blob/main/workshop.md
New Chrome available

### Creating and reading stream events

The workshop uses curl to append and read events at a unique stream path, then live-tail the stream. The server has no authentication, so the instructions warn against putting secrets in streams.

[7:15](https://www.youtube.com/watch?v=vi-2nasppAg&t=435s) [Workshop instructions show a server authentication warning and commands to create, read, and live-tail events.](https://assets.ai.engineer/sites/aiecode2025/sha256/1ca8d7a61c60104d90181398157befd75ef0c4aabfa666a589abf3e66256ef3c.webp)

WARNING: There is no authentication on this server, so please don't stick any secrets in your streams.

Let's play with this together!

# Streams are structured into paths. Let's give ourselves a unique path prefix
# My prefix will be /jonastemplestein — paths start with a slash!
export PATH_PREFIX="/$(id -un)"
export BASE_URL="https://events.iterate.com"
export STREAM_PATH="${PATH_PREFIX}/hello-world"

# Let's create our first event
curl --json '{"type": "hello-world"}' \
  "${BASE_URL}/api/streams${STREAM_PATH}"

# Let's see if it's there
curl -N "${BASE_URL}/api/streams${STREAM_PATH}"

# We can also live tail the stream
# With pretty printing
curl -sN "${BASE_URL}/api/streams${STREAM_PATH}?live=true" | sed -nu 's/^data: //p' | jq .

Now let's in another tab append another event

curl --json '{"type": "hello-world"}' \
  "${BASE_URL}/api/streams${STREAM_PATH}"

# Can also append hogwash!
curl --json '{"hogwash": "yes!"}' \
  "${BASE_URL}/api/streams${STREAM_PATH}"

Some notes / observations:

Interface text:
github.com/iterate/ai-engineer-workshop/blob/main/workshop.md
ai-engineer-workshop / workshop.md
Files
main
Go to file
.gitignore
00-example.ts
README.md
package.json
pnpm-lock.yaml
tsconfig.json
workshop.md
Preview  Code  Blame
223 lines (134 loc) · 6.53 KB
Raw
Top
New Chrome available
Wed 8 Apr 10:49

### Streams viewer and project namespace

The viewer shows an initialized root stream and a JSON event composer. The speaker says changing the project slug gives participants a separate database namespace if they get in each other's way.

[8:25](https://www.youtube.com/watch?v=vi-2nasppAg&t=505s) [An events interface shows an initialized stream, a project slug control, and an event composer.](https://assets.ai.engineer/sites/aiecode2025/sha256/b39dee7aa4dd4295b4ea738bfbf8199524f103ac1efd1016476655afb121d021.webp)

Events
durable streams

Env vars
Streams

Streams
+ Create stream
Filter streams
/

PROJECT SLUG
publicasdasda
Apply

Streams
Raw 1
Semantic 1
Raw

- streamPath: /
  type: https://events.iterate.com/events/stream/initialized
  payload:
    projectSlug: publicasdasda
    path: /
  offset: 1
  createdAt: 2026-04-08T09:50:54.017Z
YAML

{
  "type": "https://events.iterate.com/manual-event-appended",
  "payload": {
    "message": "hello"
  }
}
JSON  YAML  Agent  Manual Event Appended

Interface text:
Chrome  File  Edit  View  History  Bookmarks  Profiles  Tab  Window  Help
iterate/ai-engineer-workshop
Events
ai-engineer-workshop/works[illegible]
events.iterate.com/streams/?projectSlug=publicasdasda&renderer=raw&composer=json
New Chrome available
Wed 8 Apr 10:50

### Creating and reading stream events

A curl request appends a hello-world event; a second terminal reads the stream with curl -N and displays the initialized event, the new event, and a construction event in offset order.

[9:17](https://www.youtube.com/watch?v=vi-2nasppAg&t=557s) [A split terminal shows an event creation response on the left and a stream read command on the right.](https://assets.ai.engineer/sites/aiecode2025/sha256/552372341074da5281294aca9dd170af87589b60a3a5644615a26ca690754263.webp)

export PATH_PREFIX="/$(id -un)"
export BASE_URL="https://events.iterate.com"
export STREAM_PATH="${PATH_PREFIX}/hello-world"

echo $PATH_PREFIX
/jonastemplestein

curl --json '{"type": "hello-world"}' \
  "${BASE_URL}/api/streams${STREAM_PATH}"

{
  "event": {
    "streamPath": "/jonastemplestein/hello-world",
    "type": "hello-world",
    "payload": {},
    "offset": 2,
    "createdAt": "2026-04-08T09:51:13.097Z"
  }
}

[WARN] - (starship::utils): Executing command "/usr/bin/git" timed out.

curl -N "${BASE_URL}/api/streams/jonastemplestein/hello-world"

Interface text:
Ghostty  File  Edit  View  Window  Help
.../github.com/iterate/iterate
iterate on git main [$<] via docker orbstack via nodejs v24.4.0
iterate on git main [$] via docker orbstack via nodejs
9%  5%
Wed 8 Apr 10:52

[9:33](https://www.youtube.com/watch?v=vi-2nasppAg&t=573s) [Split terminal showing an event append on the left and streamed messages on the right.](https://assets.ai.engineer/sites/aiecode2025/sha256/f3f6bf542ca18b4c8f650b76961422bb7bef1a70c1a731c8bd41782c06cad089.webp)

export PATH_PREFIX="/$(id -un)"
export BASE_URL="https://events.iterate.com"
export STREAM_PATH="${PATH_PREFIX}/hello-world"

echo $PATH_PREFIX
/jonastemplestein

curl --json '{"type": "hello-world"}' \
  "${BASE_URL}/api/streams${STREAM_PATH}"

{
  "event": {
    "streamPath": "/jonastemplestein/hello-world",
    "type": "hello-world",
    "payload": {},
    "offset": 2,
    "createdAt": "2026-04-08T09:51:13.097Z"
  }
}

[WARN] - (starship::utils): Executing command "/usr/bin/git" timed out.

curl -N "${BASE_URL}/api/streams/jonastemplestein/hello-world"

:

event: message
data: {"streamPath":"/jonastemplestein/hello-world","type":"https://events.iterate.com/events/stream/initialized","payload":{"projectSlug":"public","path":"/jonastemplestein/hello-world"},"offset":1,"createdAt":"2026-04-08T09:51:13.080Z"}

event: message
data: {"streamPath":"/jonastemplestein/hello-world","type":"hello-world","payload":{},"offset":2,"createdAt":"2026-04-08T09:51:13.097Z"}

event: message
data: {"streamPath":"/jonastemplestein/hello-world","type":"https://events.iterate.com/events/stream/durable-object-constructed","payload":{},"offset":3,"createdAt":"2026-04-08T09:52:01.151Z"}

Interface text:
Ghostty  File  Edit  View  Window  Help
.../github.com/iterate/iterate
iterate on git main [$<] via docker orbstack via nodejs v24.4.0
iterate on git main [$] via docker orbstack via nodejs
9%  5%
Wed 8 Apr 10:52

### Read the updated stream

A second hello-world event is appended on the left. Re-running the stream read on the right returns the earlier messages and the new event at offset 4.

[9:40](https://www.youtube.com/watch?v=vi-2nasppAg&t=580s) [Split terminal showing a second event append and the updated stream output.](https://assets.ai.engineer/sites/aiecode2025/sha256/81297253dfaf1452c32ef4a95efa20930b313c057d167212aab63fbad4bb9f85.webp)

Left terminal:
export PATH_PREFIX="/$(id -un)"
export BASE_URL="https://events.iterate.com"
export STREAM_PATH="${PATH_PREFIX}/hello-world"

echo $PATH_PREFIX
/jonastemplestein

curl --json '{"type": "hello-world"}' \
  "${BASE_URL}/api/streams${STREAM_PATH}"

{
  "event": {
    "streamPath": "/jonastemplestein/hello-world",
    "type": "hello-world",
    "payload": {},
    "offset": 2,
    "createdAt": "2026-04-08T09:51:13.097Z"
  }
}
[WARN] - (starship::utils): Executing command "/usr/bin/git" timed out.

curl --json '{"type": "hello-world"}' \
  "${BASE_URL}/api/streams${STREAM_PATH}"

{
  "event": {
    "streamPath": "/jonastemplestein/hello-world",
    "type": "hello-world",
    "payload": {},
    "offset": 4,
    "createdAt": "2026-04-08T09:52:05.508Z"
  }
}

Right terminal:
curl -N "${BASE_URL}/api/streams/jonastemplestein/hello-world"
:
event: message
data: {"streamPath":"/jonastemplestein/hello-world","type":"https://events.iterate.com/events/stream/initialized","payload":{"projectSlug":"public","path":"/jonastemplestein/hello-world"},"offset":1,"createdAt":"2026-04-08T09:51:13.080Z"}

event: message
data: {"streamPath":"/jonastemplestein/hello-world","type":"hello-world","payload":{},"offset":2,"createdAt":"2026-04-08T09:51:13.097Z"}

event: message
data: {"streamPath":"/jonastemplestein/hello-world","type":"https://events.iterate.com/events/stream/durable-object-constructed","payload":{},"offset":3,"createdAt":"2026-04-08T09:52:01.151Z"}

curl -N "${BASE_URL}/api/streams/jonastemplestein/hello-world"
:
event: message
data: {"streamPath":"/jonastemplestein/hello-world","type":"https://events.iterate.com/events/stream/initialized","payload":{"projectSlug":"public","path":"/jonastemplestein/hello-world"},"offset":1,"createdAt":"2026-04-08T09:51:13.080Z"}

event: message
data: {"streamPath":"/jonastemplestein/hello-world","type":"hello-world","payload":{},"offset":2,"createdAt":"2026-04-08T09:51:13.097Z"}

event: message
data: {"streamPath":"/jonastemplestein/hello-world","type":"https://events.iterate.com/events/stream/durable-object-constructed","payload":{},"offset":3,"createdAt":"2026-04-08T09:52:01.151Z"}

event: message
data: {"streamPath":"/jonastemplestein/hello-world","type":"hello-world","payload":{},"offset":4,"createdAt":"2026-04-08T09:52:05.508Z"}

[WARN] - (starship::utils): Executing command "/usr/bin/git" timed out.
[WARN] - (starship::utils): You can set command_timeout in your config to a higher value to allow longer-running commands to keep executing.

Interface text:
Ghostty  File  Edit  View  Window  Help
.../github.com/iterate/iterate
Wed 8 Apr 10:52
Terminal prompts: iterate on git main [$<] via docker orbstack via nodejs v24.4.0; 9%; 5%

### Follow a live event stream

The live=true request keeps the stream open. As the presenter appends hello-world events in the left terminal, the right terminal receives them with matching offsets.

[10:04](https://www.youtube.com/watch?v=vi-2nasppAg&t=604s) [Split terminal showing event append responses on the left and live stream messages on the right.](https://assets.ai.engineer/sites/aiecode2025/sha256/2df40a599410e57398fc138a5f39fa02ad253de864ac6a8ae19f27fd49cef98b.webp)

Left terminal:
{
  "event": {
    "streamPath": "/jonastemplestein/hello-world",
    "type": "hello-world",
    "payload": {},
    "offset": 7,
    "createdAt": "2026-04-08T09:52:29.057Z"
  }
}
^[[A

curl --json '{"type": "hello-world"}' \
  "${BASE_URL}/api/streams${STREAM_PATH}"

{
  "event": {
    "streamPath": "/jonastemplestein/hello-world",
    "type": "hello-world",
    "payload": {},
    "offset": 8,
    "createdAt": "2026-04-08T09:52:29.873Z"
  }
}
^[[A

curl --json '{"type": "hello-world"}' \
  "${BASE_URL}/api/streams${STREAM_PATH}"

{
  "event": {
    "streamPath": "/jonastemplestein/hello-world",
    "type": "hello-world",
    "payload": {},
    "offset": 9,
    "createdAt": "2026-04-08T09:52:30.872Z"
  }
}

Right terminal:
[WARN] - (starship::utils): You can set command_timeout in your config to a higher value to allow longer-running commands to keep executing.

curl -N "${BASE_URL}/api/streams/jonastemplestein/hello-world?live=true"

:

event: message
data: {"streamPath":"/jonastemplestein/hello-world","type":"https://events.iterate.com/events/stream/initialized","payload":{"projectSlug":"public","path":"/jonastemplestein/hello-world"},"offset":1,"createdAt":"2026-04-08T09:51:13.080Z"}

event: message
data: {"streamPath":"/jonastemplestein/hello-world","type":"hello-world","payload":{},"offset":2,"createdAt":"2026-04-08T09:51:13.097Z"}

event: message
data: {"streamPath":"/jonastemplestein/hello-world","type":"https://events.iterate.com/events/stream/durable-object-constructed","payload":{},"offset":3,"createdAt":"2026-04-08T09:52:01.151Z"}

event: message
data: {"streamPath":"/jonastemplestein/hello-world","type":"hello-world","payload":{},"offset":4,"createdAt":"2026-04-08T09:52:05.508Z"}

event: message
data: {"streamPath":"/jonastemplestein/hello-world","type":"https://events.iterate.com/events/stream/durable-object-constructed","payload":{},"offset":5,"createdAt":"2026-04-08T09:52:25.812Z"}

event: message
data: {"streamPath":"/jonastemplestein/hello-world","type":"hello-world","payload":{},"offset":6,"createdAt":"2026-04-08T09:52:27.702Z"}

event: message
data: {"streamPath":"/jonastemplestein/hello-world","type":"hello-world","payload":{},"offset":7,"createdAt":"2026-04-08T09:52:29.057Z"}

event: message
data: {"streamPath":"/jonastemplestein/hello-world","type":"hello-world","payload":{},"offset":8,"createdAt":"2026-04-08T09:52:29.873Z"}

event: message
data: {"streamPath":"/jonastemplestein/hello-world","type":"hello-world","payload":{},"offset":9,"createdAt":"2026-04-08T09:52:30.872Z"}

Interface text:
Ghostty  File  Edit  View  Window  Help
.../github.com/iterate/iterate
iterate on git main via docker orbstack via nodejs v24.4.0
Wed 8 Apr 10:52

### Following a live event stream

The demo appends hello-world events in one terminal while another follows the stream. Piping the live response through sed and jq extracts and formats each event’s data.

[10:16](https://www.youtube.com/watch?v=vi-2nasppAg&t=616s) [Editor displaying workshop examples for appending, reading, and following an event stream.](https://assets.ai.engineer/sites/aiecode2025/sha256/8d2a5c7b387ba68ed5b0484d80baa69674955993d0e2608e0acc7fb8e41b140a.webp)

# Playing with streams

# Let's create our first event
curl --json '{"type": "hello-world"}' \
  "${BASE_URL}/api/streams${STREAM_PATH}"

# Let's see if it's there
curl -N "${BASE_URL}/api/streams${STREAM_PATH}"

# We can also live tail the stream with pretty printing (start this in a new tab)
curl -sN "${BASE_URL}/api/streams${STREAM_PATH}?live=true" | sed -nu 's/^data: //p' | jq .

# Can also append hogwash!
curl --json '{"hogwash": "yes!"}' \
  "${BASE_URL}/api/streams${STREAM_PATH}"

# Use an idempotency key to prevent duplicate appends — run this twice!
curl --json '{"type": "hello-world", "idempotencyKey": "boop"}' \
  "${BASE_URL}/api/streams${STREAM_PATH}"

# You can get the "reduced state" of a stream
curl "${BASE_URL}/api/streams/__state${STREAM_PATH}" | jq .

Interface text:
Cursor; workshop.md; ai-engineer-workshop; Review Next File; Preview; Markdown
Add to Chat; Quick Edit
You, 17 hours ago • [codex] add tiny composable workshop agent kern...

Commit and force push process
commit and push everything - force push it
Checking git status and current branch, then staging, committing, and force-pushing.
Staging all changes, committing, and force-pushing branch secretive-waiter (diverged from origin).
Here's what ran:
1. git add -A — staged everything (there were 5 modified files under ai-engineer-workshop/workshop2/).
2. Commit — a9e40d7f with message: Update workshop2 nano-agent and LLM processor scripts (lint-staged ran oxfmt on those files).
3. Push — git push --force-with-lease origin secretive-waiter so secretive-waiter on GitHub matches your local branch (replacing the previous remote tip).
I used --force-with-lease instead of bare --force so the push still fails if the remote moved in a way you haven’t fetched; the update went through successfully. If you strictly need git push --force, say so and we can use that next time.

Terminal:
create mode 100644 ai-engineer-workshop/workshop2/bashmode.test.ts
create mode 100644 ai-engineer-workshop/workshop2/bashmode.ts
git push origin
To https://github.com/iterate/iterate.git
! [rejected] secretive-waiter -> secretive-waiter (non-fast-forward)
error: failed to push some refs to 'https://github.com/iterate/iterate.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Problems 3; Output; Debug Console; Terminal; GitLens; Playwright; Effect Tracer; Comments 3

[10:23](https://www.youtube.com/watch?v=vi-2nasppAg&t=623s) [A split terminal shows event requests and their corresponding live stream output.](https://assets.ai.engineer/sites/aiecode2025/sha256/a57c4316e1f850a16d00f2dca208cbeec1a597a48f4d4a59ff796b0cb037aad7.webp)

Left terminal:
{
  "event": {
    "streamPath": "/jonastemplestein/hello-world",
    "type": "hello-world",
    "payload": {},
    "offset": 7,
    "createdAt": "2026-04-08T09:52:29.057Z"
  }
}

curl --json '{"type": "hello-world"}' \
  "${BASE_URL}/api/streams${STREAM_PATH}"
{
  "event": {
    "streamPath": "/jonastemplestein/hello-world",
    "type": "hello-world",
    "payload": {},
    "offset": 8,
    "createdAt": "2026-04-08T09:52:29.873Z"
  }
}

curl --json '{"type": "hello-world"}' \
  "${BASE_URL}/api/streams${STREAM_PATH}"
{
  "event": {
    "streamPath": "/jonastemplestein/hello-world",
    "type": "hello-world",
    "payload": {},
    "offset": 9,
    "createdAt": "2026-04-08T09:52:30.872Z"
  }
}

Right terminal:
"offset": 3,
"createdAt": "2026-04-08T09:52:01.151Z"
}
{
  "streamPath": "/jonastemplestein/hello-world",
  "type": "hello-world",
  "payload": {},
  "offset": 4,
  "createdAt": "2026-04-08T09:52:05.508Z"
}
{
  "streamPath": "/jonastemplestein/hello-world",
  "type": "https://events.iterate.com/events/stream/durable-object-constructed",
  "payload": {},
  "offset": 5,
  "createdAt": "2026-04-08T09:52:25.812Z"
}
{
  "streamPath": "/jonastemplestein/hello-world",
  "type": "hello-world",
  "payload": {},
  "offset": 6,
  "createdAt": "2026-04-08T09:52:27.702Z"
}
{
  "streamPath": "/jonastemplestein/hello-world",
  "type": "hello-world",
  "payload": {},
  "offset": 7,
  "createdAt": "2026-04-08T09:52:29.057Z"
}
{
  "streamPath": "/jonastemplestein/hello-world",
  "type": "hello-world",
  "payload": {},
  "offset": 8,
  "createdAt": "2026-04-08T09:52:29.873Z"
}
{
  "streamPath": "/jonastemplestein/hello-world",
  "type": "hello-world",
  "payload": {},
  "offset": 9,
  "createdAt": "2026-04-08T09:52:30.872Z"
}

Interface text:
Ghostty; File; Edit; View; Window; Help
curl -sN "${BASE_URL}/api/streams${STREAM_PATH}?live=true" | sed -nu 's/^data: //p' | jq .
iterate on git main via docker orbstack via nodejs v24.4.0

### Ping-pong stream example

The TypeScript example follows a live stream, skips events that are not pings, and appends a pong for each ping.

[27:56](https://www.youtube.com/watch?v=vi-2nasppAg&t=1676s) [TypeScript code reads live events and appends a pong for each ping.](https://assets.ai.engineer/sites/aiecode2025/sha256/4d68b772cbfa304a5364d83f0b280cee8ac58b1449cfdc4c4d967082faa51cd0.webp)

00-example.ts

console.log(`Append {"type":"ping"} to trigger a pong.`);

for await (const event of await client.stream({ path: streamPath, live: true }, {})) {
  if (event.type !== "ping") {
    continue;
  }

  console.log(`ping offset=${event.offset}`);
  await client.append({ path, event: { type: "pong", payload: {}}})
}

async function appendEvent(path: string, body: EventInput) {
  await client.append({ path, event: body });
}

Interface text:
Cursor  File  Edit  Selection  View  Go  Run  Terminal  Window  Help
AI-ENGINEER-WORKSHOP
node_modules
.gitignore
00-example.ts
package.json
pnpm-lock.yaml
README.md
tsconfig.json
workshop.md
New Chat
Plan, @ for context, / for commands
Agent  Composer 2 Fast  Local
Problems  Output  Terminal  GitLens  Playwright  Effect Tracer
TERMINAL  zsh
⌘K to generate command
Ln 22, Col 14  Spaces: 2  UTF-8  LF  TypeScript

### Workshop stream configuration

The example configures the event service URL, normalizes a path prefix, and constructs a hello-world stream path. Each can be supplied through an environment variable.

[28:56](https://www.youtube.com/watch?v=vi-2nasppAg&t=1736s) [Cursor displays TypeScript imports and configuration for an event stream.](https://assets.ai.engineer/sites/aiecode2025/sha256/c5b968c5b6e7f0a5ac937b5bfe87e52a4b87693cbda19badc007456855445ae0.webp)

import {
  createEventsClient,
  type EventInput,
  getDefaultWorkshopPathPrefix,
  normalizePathPrefix,
} from "ai-engineer-workshop";

const baseUrl = process.env.BASE_URL || "https://events.iterate.com";
const pathPrefix = normalizePathPrefix(process.env.PATH_PREFIX || getDefaultWorkshopPathPrefix());
const streamPath = process.env.STREAM_PATH || `${pathPrefix}/00-hello-world`;
const client = createEventsClient({ baseUrl });

Terminal:
ai-engineer-workshop ⚡ pnpm

Interface text:
Cursor  File  Edit  Selection  View  Go  Run  Terminal  Window  Help
ai-engineer-workshop
EXPLORER
AI-ENGINEER-WORKSHOP
examples
01-hello-world
append-hello-world.ts
subscribe-hello-world.ts
02-stream-processor
hello-world-processor.ts
node_modules
.gitignore
00-example.ts
package.json
pnpm-lock.yaml
README.md
tsconfig.json
workshop.md
README.md  00-example.ts (Working Tree)  workshop.md  package.json  subscribe-hello-world.ts  00-example.ts  .gitignore
00-example.ts > streamPath
You, 19 minutes ago | 2 authors (Jonas Templestein and one other)
live=true  No results
Output  Terminal
node  zsh
Search Agents...  New Agent  Agents
OUTLINE  TIMELINE  Browse Marketplace

### Hello-world stream processor

The processor counts hello-world events and, when the count is 1, appends a hello-world-seen event containing the source offset. The terminal shows an appended hello-world event.

[29:17](https://www.youtube.com/watch?v=vi-2nasppAg&t=1757s) [A TypeScript processor counts hello-world events and appends a derived event; the terminal shows an example result.](https://assets.ai.engineer/sites/aiecode2025/sha256/368be7d1625b644e2dce6ef15823e5c75aaf65a00322de326934e48343937b49.webp)

const initialState: HelloWorldState = { count: 0 };

export default defineProcessor(() => ({
  slug: "hello-world",
  initialState,

  reduce: ({ event, state }) => {
    if (event.type !== "hello-world") return state;
    return { count: state.count + 1 };
  },

  afterAppend: async ({ append, event, state }) => {
    if (event.type !== "hello-world" || state.count !== 1) return;

    await append({
      event: {
        type: "hello-world-seen",
        payload: { sourceOffset: event.offset },
      },
    });
  },
}));

Terminal:
node examples/01-hello-world/append-hello-world.ts
{
  "event": {
    "streamPath": "/mmkal/hello-world",
    "type": "hello-world",
    "payload": {
      "message": "hello world"
    },
    "offset": 5,
    "createdAt": "2026-04-08T10:11:36.518Z"
  }
}
node examples/01-hello-world/appe

Interface text:
Cursor  File  Edit  Selection  View  Go  Run  Terminal  Window  Help
ai-engineer-workshop
EXPLORER
AI-ENGINEER-WORKSHOP
examples
01-hello-world
append-hello-world.ts
subscribe-hello-world.ts
02-stream-processor
hello-world-processor.ts
node_modules
.gitignore
00-example.ts
package.json
pnpm-lock.yaml
README.md
tsconfig.json
workshop.md
examples > 02-stream-processor > hello-world-processor.ts
live=true
No results
Output  Terminal
node  zsh
Search Agents...
New Agent
Agents
OUTLINE
TIMELINE
Browse Marketplace

### Requesting an agent processor

The presenter asks the coding agent to install the OpenAI SDK and create an agent processor based on the hello-world processor, which counts events and appends a derived event on the first one.

[29:27](https://www.youtube.com/watch?v=vi-2nasppAg&t=1767s) [The hello-world processor remains open above a coding-agent request to create a third example using the OpenAI SDK.](https://assets.ai.engineer/sites/aiecode2025/sha256/dd120ca18cf4e93d7109f3359e75a5d1c2a62ca87666bee9a9ecf3574ace5503.webp)

const initialState: HelloWorldState = { count: 0 };

export default defineProcessor(() => ({
  slug: "hello-world",
  initialState,

  reduce: ({ event, state }) => {
    if (event.type !== "hello-world") return state;
    return { count: state.count + 1 };
  },

  afterAppend: async ({ append, event, state }) => {
    if (event.type !== "hello-world" || state.count !== 1) return;

    await append({
      event: {
        type: "hello-world-seen",
        payload: { sourceOffset: event.offset },
      },
    });
  },
}));

- then append hello-world
- or use a seeded stream if you need to avoid the catch-up edge case

Hey, I would like to make a third example uh called agent processor and for that we need to install uh just the normal OpenAI SDK. Please uh do that and just make me a new file that looks like the Hello World processor.

Interface text:
ai-engineer-workshop
EXPLORER
AI-ENGINEER-WORKSHOP
examples
01-hello-world
append-hello-world.ts
subscribe-hello-world.ts
02-stream-processor
hello-world-processor.ts
node_modules
.gitignore
00-example.ts
package.json
pnpm-lock.yaml
README.md
tsconfig.json
workshop.md
examples > 02-stream-processor > hello-world-processor.ts
live=true
No results
Output
Terminal
Build · GPT-5.4 · 1m 37s
Build · GPT-5.4
Build  GPT-5.4  OpenAI
esc interrupt
90.6K (9%)  ctrl+p commands
Urgent pkg.pr.new SDK demo troubleshooting
Context
90,621 tokens
9% used
$0.00 spent
MCP
cloudflare_logs Connected
context7 Connected
exa Connected
grep Connected
playwriter Connected
~/src/ai-engineer-workshop:main
OpenCode 1.4.0
node
zsh
Search Agents...
New Agent
Agents
OUTLINE
TIMELINE
Browse Marketplace

### Appending a hello-world event

The TypeScript example creates an events client, appends a hello-world event to a stream path, and logs the result. The coding agent is also working on a requested agent processor example.

[30:01](https://www.youtube.com/watch?v=vi-2nasppAg&t=1801s) [TypeScript code creates an events client, appends a hello-world event and logs the result.](https://assets.ai.engineer/sites/aiecode2025/sha256/e9713bb937d71683b578e3a690669cdf8120c3cf4519270d48b3d22d5f8eceb7.webp)

append-hello-world.ts

import { createEventsClient, runWorkshopMain } from "ai-engineer-workshop";

export async function run() {
  const client = createEventsClient();
  const streamPath = `${process.env.PATH_PREFIX}/hello-world`;

  const result = await client.append({
    path: streamPath,
    event: { type: "hello-world", payload: { message: "hello world" } },
  });

  console.log(JSON.stringify(result, null, 2));
}

runWorkshopMain(import.meta.url, run);

Terminal:
- then append hello-world
- or use a seeded stream if you need to avoid the catch-up edge case

Hey, I would like to make a third example uh called agent processor and for that we need to install uh just the normal OpenAI SDK. Please uh do that and just make me a new file that looks like the Hello World processor.

Interface text:
Cursor · ai-engineer-workshop
EXPLORER
AI-ENGINEER-WORKSHOP
examples
01-hello-world
append-hello-world.ts
subscribe-hello-world.ts
02-stream-processor
hello-world-processor.ts
node_modules
.gitignore
00-example.ts
package.json
pnpm-lock.yaml
README.md
tsconfig.json
workshop.md
examples > 01-hello-world > append-hello-world.ts > run
live=true · No results
Output · Terminal
Build · GPT-5.4 · 1m 37s
Urgent pkg.pr.new SDK demo troubleshooting
Context: 90,621 tokens · 9% used · $0.00 spent
MCP: cloudflare_logs, context7, exa, grep, playwriter Connected
OpenCode 1.4.0
Search Agents... · New Agent · Agents

[30:23](https://www.youtube.com/watch?v=vi-2nasppAg&t=1823s) [TypeScript example appends a hello-world event to a stream.](https://assets.ai.engineer/sites/aiecode2025/sha256/b6fe242c7e68d8c691a393b492a3e55486cc9de8dad7e55a525cf72d9fd88df9.webp)

append-hello-world.ts

import { createEventsClient, runWorkshopMain } from "ai-engineer-workshop";

export async function run() {
  const client = createEventsClient();
  const streamPath = `${process.env.PATH_PREFIX}/hello-world`;

  const result = await client.append({
    path: streamPath,
    event: { type: "hello-world", payload: { message: "hello world" } },
  });

  console.log(JSON.stringify(result, null, 2));
}

runWorkshopMain(import.meta.url, run);

Terminal:
- then append hello-world
- or use a seeded stream if you need to avoid the catch-up edge case

Hey, I would like to make a third example uh called agent processor and for that we need to install uh just the normal OpenAI SDK. Please uh do that and just make me a new file that looks like the Hello World processor.

Interface text:
Cursor · ai-engineer-workshop
EXPLORER
AI-ENGINEER-WORKSHOP
examples
01-hello-world
append-hello-world.ts
subscribe-hello-world.ts
02-stream-processor
hello-world-processor.ts
node_modules
.gitignore
00-example.ts
package.json
pnpm-lock.yaml
README.md
tsconfig.json
workshop.md
examples > 01-hello-world > append-hello-world.ts > run
live=true · No results
Output · Terminal
Build · GPT-5.4 · 1m 37s
Urgent pkg.pr.new SDK demo troubleshooting
Context: 90,621 tokens · 9% used · $0.00 spent
MCP: cloudflare_logs, context7, exa, grep, playwriter Connected
OpenCode 1.4.0
Search Agents... · New Agent · Agents

### Subscribing to a hello-world stream

The example opens a live stream, appends a hello-world event, and reads until its offset matches or the stream ends. It then aborts the subscription and calls the iterator’s return method if available.

[30:30](https://www.youtube.com/watch?v=vi-2nasppAg&t=1830s) [TypeScript example opens a live stream and waits for an appended event.](https://assets.ai.engineer/sites/aiecode2025/sha256/f4c3cb02bb7b828c66d9070542f70594aad6df8831ab3c127263cdab93f314e1.webp)

subscribe-hello-world.ts

import { createEventsClient, runWorkshopMain } from "ai-engineer-workshop";

export async function run() {
  const client = createEventsClient();
  const streamPath = `${process.env.PATH_PREFIX}/hello-world`;

  const controller = new AbortController();
  const stream = await client.stream(
    { path: streamPath, live: true },
    { signal: controller.signal },
  );
  const iterator = stream[Symbol.asyncIterator]();

  const appendResult = await client.append({
    path: streamPath,
    event: { type: "hello-world", payload: { message: `hello world ${new Date().toISOString()}` } },
  });

  let streamed = await iterator.next();
  while (!streamed.done && streamed.value.offset !== appendResult.event.offset) {
    streamed = await iterator.next();
  }

  controller.abort();
  await iterator.return?.();

Interface text:
Cursor  File  Edit  Selection  View  Go  Run  Terminal  Window  Help
Wed 8 Apr 11:13
ai-engineer-workshop
EXPLORER
AI-ENGINEER-WORKSHOP
examples
01-hello-world
append-hello-world.ts
subscribe-hello-world.ts
02-stream-processor
hello-world-processor.ts
node_modules
.gitignore
00-example.ts
package.json
pnpm-lock.yaml
README.md
tsconfig.json
workshop.md
README.md  00-example.ts (Working Tree)  workshop.md  package.json  00-example.ts  subscribe-hello-world.ts  .gitignore
examples > 01-hello-world > subscribe-hello-world.ts > ...
You, 7 minutes ago | 1 author (You)
live=true  No results
Search Agents...  New Agent  Agents
Output  Terminal
Progress: resolved 179, reused 153, downloaded 1, added 11, done
dependencies:
- @mariozechner/pi-agent-core 0.64.0
- @mariozechner/pi-ai 0.64.0
...
Click to expand
Build · GPT-5.4
Build  GPT-5.4  OpenAI
esc interrupt  90.6K (9%)  ctrl+p commands
Urgent pkg.pr.new SDK demo troubleshooting
Context
90,625 tokens
9% used
$0.00 spent
MCP
cloudflare_logs Connected
context7 Connected
exa Connected
grep Connected
playwriter Connected
~/src/ai-engineer-workshop:main
OpenCode 1.4.0
node  zsh
OUTLINE  TIMELINE  Browse Marketplace
main+  Launchpad  ai-engineer-workshop  Git Graph  You, 7 minutes ago  Cursor Tab  Ln 1, Col 1  Spaces: 2  UTF-8  LF  TypeScript  oxc  Prettier

### Hello-world stream processor

The processor derives a count from hello-world events. When the count reaches one, it appends a hello-world-seen event carrying the original event’s offset.

[30:39](https://www.youtube.com/watch?v=vi-2nasppAg&t=1839s) [Processor code counts hello-world events and appends a seen event.](https://assets.ai.engineer/sites/aiecode2025/sha256/9546ae0bac10c7ea18ae750e64aafc3bddfeaa49c5b429abc970f6a0a8b0b7d5.webp)

import { defineProcessor } from "ai-engineer-workshop";

type HelloWorldState = { count: number };
const initialState: HelloWorldState = { count: 0 };

export default defineProcessor(() => ({
  slug: "hello-world",
  initialState,

  reduce: ({ event, state }) => {
    if (event.type !== "hello-world") return state;
    return { count: state.count + 1 };
  },

  afterAppend: async ({ append, event, state }) => {
    if (event.type !== "hello-world" || state.count !== 1) return;

    await append({
      event: {
        type: "hello-world-seen",
        payload: { sourceOffset: event.offset },
      },
    });
  },
}));

Terminal:
some transitive ones from earlier. I need to check the package.json file. It might be okay since I think OpenAI only added something without Zod. However, the bash output indicates that dependencies were actually removed from the list, so I really need to inspect the package.json to understand what happened. Let's take a closer look!

pnpm add openai completed, but it also normalized a few dependency versions in this sample package. I’m checking the manifest/lockfile and then I’ll add the new processor file.

Read package.json [offset=1, limit=120]
Grep ""openai"|"zod"|"@tanstack/ai"|"@mariozechner/pi"" in pnpm-lock.yaml

Interface text:
ai-engineer-workshop
EXPLORER
AI-ENGINEER-WORKSHOP
examples
01-hello-world
append-hello-world.ts
subscribe-hello-world.ts
02-stream-processor
hello-world-processor.ts
node_modules
.gitignore
00-example.ts
package.json
pnpm-lock.yaml
README.md
tsconfig.json
workshop.md
README.md; 00-example.ts (Working Tree); workshop.md; package.json; 00-example.ts; hello-world-processor.ts; .gitignore
examples > 02-stream-processor > hello-world-processor.ts
You, 4 minutes ago | 1 author (You)
live=true
No results
Output; Terminal
Build · GPT-5.4
Build GPT-5.4 OpenAI
esc interrupt
91.2K (9%)
ctrl+p commands
Urgent pkg.pr.new SDK demo troubleshooting
Context
91,231 tokens
9% used
$0.00 spent
MCP
cloudflare_logs Connected
context7 Connected
exa Connected
grep Connected
playwriter Connected
~/src/ai-engineer-workshop:main
OpenCode 1.4.0
node; zsh
Search Agents...
New Agent
Agents
Browse Marketplace
OUTLINE
TIMELINE
main*+
Launchpad
ai-engineer-workshop
Git Graph
Cursor Tab
Ln 5, Col 1
Spaces: 2
UTF-8
LF
TypeScript
oxc
Prettier

### Agent processor type-check error

The hello-world processor counts matching events with a reducer and appends a seen event on the first match. Meanwhile, the terminal reports a type error in the separate agent processor.

[30:48](https://www.youtube.com/watch?v=vi-2nasppAg&t=1848s) [The hello-world processor remains open while the terminal reports a TypeScript error in the agent processor.](https://assets.ai.engineer/sites/aiecode2025/sha256/35f40c580255d88adb401223a6848a9feaf3737819b0ea0b4f91b4bcc63bb129.webp)

import { defineProcessor } from "ai-engineer-workshop";

type HelloWorldState = { count: number };
const initialState: HelloWorldState = { count: 0 };

export default defineProcessor(() => ({
  slug: "hello-world",
  initialState,

  reduce: ({ event, state }) => {
    if (event.type !== "hello-world") return state;
    return { count: state.count + 1 };
  },

  afterAppend: async ({ append, event, state }) => {
    if (event.type !== "hello-world" || state.count !== 1) return;

    await append({
      event: {
        type: "hello-world-seen",
        payload: { sourceOffset: event.offset },
      },
    });
  },
}));

Terminal:
examples/03-agent-processor/agent-processor.ts(22,32): error TS2345: Argument of type 'object | Record<string, never> | { projectSlug: string; path: string; } | { childPath: string; } | { metadata: Record<string, JSONType>; } | { slug: string; callbackUrl: string; type: "websocket"; jsonataFilter?: string | undefined; jsonataTransform?: string | undefined; } | ... 11 more ... | { ...; }' is not assignable to parameter of type 'Record<string, unknown>'.
  Type 'object' is not assignable to type 'Record<string, unknown>'.
    Index signature for type 'string' is missing in type '{}'.
ELIFECYCLE Command failed with exit code 2.

Interface text:
Cursor  File  Edit  Selection  View  Go  Run  Terminal  Window  Help
ai-engineer-workshop
EXPLORER
AI-ENGINEER-WORKSHOP
examples
01-hello-world
append-hello-world.ts
subscribe-hello-world.ts
02-stream-processor
hello-world-processor.ts
03-agent-processor
node_modules
.gitignore
00-example.ts
package.json
pnpm-lock.yaml
README.md
tsconfig.json
workshop.md
README.md  00-example.ts (Working Tree)  workshop.md  package.json  00-example.ts  hello-world-processor.ts  .gitignore
examples > 02-stream-processor > hello-world-processor.ts
You, 4 minutes ago | 1 author (You)
live=true  No results
Search Agents...  New Agent  Agents
Output  Terminal
Urgent pkg.pr.new SDK demo troubleshooting
Context
92,584 tokens
9% used
$0.00 spent
MCP
cloudflare_logs Connected
context7 Connected
exa Connected
grep Connected
playwriter Connected
~/src/ai-engineer-workshop:main
OpenCode 1.4.0
Build · GPT-5.4
Build  GPT-5.4  OpenAI
esc interrupt  92.6K (9%)  ctrl+p commands
node  zsh
OUTLINE  TIMELINE  Browse Marketplace

### Agent processor type check passes

The open hello-world processor counts matching events in reduce and appends a follow-up event in afterAppend. The speaker places side effects in afterAppend; the terminal separately reports that the agent processor typecheck passes.

[31:29](https://www.youtube.com/watch?v=vi-2nasppAg&t=1889s) [The hello-world processor remains open while the terminal reports that the agent processor type check passed.](https://assets.ai.engineer/sites/aiecode2025/sha256/efc0fcffabe439fe9de15aa746693069b6236830b7a2ae7cf65305979ab340f8.webp)

hello-world-processor.ts

import { defineProcessor } from "ai-engineer-workshop";

type HelloWorldState = { count: number };
const initialState: HelloWorldState = { count: 0 };

export default defineProcessor(() => ({
  slug: "hello-world",
  initialState,

  reduce: ({ event, state }) => {
    if (event.type !== "hello-world") return state;
    return { count: state.count + 1 };
  },

  afterAppend: async ({ append, event, state }) => {
    if (event.type !== "hello-world" || state.count !== 1) return;

    await append({
      event: {
        type: "hello-world-seen",
        payload: { sourceOffset: event.offset },
      },
    });
  },
}));

Terminal:
- sourceOffset

File:
- examples/03-agent-processor/agent-processor.ts

Verification:
- pnpm typecheck passes

If you want, I can also add a tiny run-agent-processor.ts or a matching prove-* script next so you can demo it immediately.

Interface text:
Cursor  File  Edit  Selection  View  Go  Run  Terminal  Window  Help
Wed 8 Apr 11:14
ai-engineer-workshop
EXPLORER
AI-ENGINEER-WORKSHOP
examples
01-hello-world
append-hello-world.ts
subscribe-hello-world.ts
02-stream-processor
hello-world-processor.ts
03-agent-processor
node_modules
.gitignore
00-example.ts
package.json
pnpm-lock.yaml
README.md
tsconfig.json
workshop.md
README.md  00-example.ts (Working Tree)  workshop.md  package.json  00-example.ts  hello-world-processor.ts  .gitignore
examples > 02-stream-processor > hello-world-processor.ts > default > defineProcessor() callback
live=true
No results
You, 5 minutes ago • Uncommitted changes
Output  Terminal
Build · GPT-5.4 · 1m 35s
Build  GPT-5.4  OpenAI
93.3K (9%)  ctrl+p commands
Urgent pkg.pr.new SDK demo troubleshooting
Context
93,332 tokens
9% used
$0.00 spent
MCP
cloudflare_logs Connected
context7 Connected
exa Connected
grep Connected
playwriter Connected
~/src/ai-engineer-workshop:main
OpenCode 1.4.0
node
zsh
Search Agents...
New Agent
Agents
OUTLINE
TIMELINE
Browse Marketplace
main*+
Launchpad
ai-engineer-workshop
Git Graph
You, 5 minutes ago
Cursor Tab
Ln 10, Col 1
Spaces: 2
UTF-8
LF
TypeScript
oxc
Prettier

### Hello-world stream processor

The reducer increments a count; afterAppend emits hello-world-seen with the source offset when the event is hello-world and the count is 1. The speaker separates state reduction from side effects.

[32:13](https://www.youtube.com/watch?v=vi-2nasppAg&t=1933s) [Editor showing a processor that counts hello-world events and appends a follow-up event.](https://assets.ai.engineer/sites/aiecode2025/sha256/9ca1a8319fd5e64ecb89759ee7ec55d5c86ba611c1116ab07345123b2e322bf7.webp)

export default defineProcessor(() => ({
  [lines 7–9 not visible]
  reduce: ({ event, state }) => {
    [line 11 not visible]
    return { count: state.count + 1 };
  },

  afterAppend: async ({ append, event, state }) => {
    if (event.type !== "hello-world" || state.count !== 1) return;

    await append({
      event: {
        type: "hello-world-seen",
        payload: { sourceOffset: event.offset },
      },
    });
  },
}));

Terminal:
- sourceOffset

File:
- examples/03-agent-processor/agent-processor.ts

Verification:
- pnpm typecheck passes

If you want, I can also add a tiny run-agent-processor.ts or a matching prove-* script next so you can demo it immediately.

Build · GPT-5.4 · 1m 35s
Build GPT-5.4 OpenAI

Urgent pkg.pr.new SDK demo troubleshooting
Context
93,332 tokens
9% used
$0.00 spent
MCP
cloudflare_logs Connected
context7 Connected
exa Connected
grep Connected
playwriter Connected
~/src/ai-engineer-workshop:main
OpenCode 1.4.0
93.3K (9%) ctrl+p commands

Interface text:
Cursor  File  Edit  Selection  View  Go  Run  Terminal  Window  Help
Wed 8 Apr 11:14
ai-engineer-workshop
EXPLORER
AI-ENGINEER-WORKSHOP
examples
01-hello-world
append-hello-world.ts
subscribe-hello-world.ts
02-stream-processor
hello-world-processor.ts
03-agent-processor
node_modules
.gitignore
00-example.ts
package.json
pnpm-lock.yaml
README.md
tsconfig.json
workshop.md
README.md  00-example.ts (Working Tree)  workshop.md  package.json  00-example.ts  hello-world-processor.ts  .gitignore
examples > 02-stream-processor > hello-world-processor.ts > default > defineProcessor() callback
live=true  No results
You, 5 minutes ago • Uncommitted changes
Search Agents...
New Agent
Agents
Output  Terminal
node  zsh
OUTLINE  TIMELINE
Browse Marketplace
main*+  Launchpad  ai-engineer-workshop  Git Graph
Cursor Tab  Ln 10, Col 1  Spaces: 2  UTF-8  LF  TypeScript  oxc  Prettier

### Appending to a child path

The processor adds a relative path to its append call and emits a follow-up event after the first hello-world event. The speaker sketches using paths and subscriptions to coordinate sub-agents.

[32:17](https://www.youtube.com/watch?v=vi-2nasppAg&t=1937s) [Editor showing a child path added to the processor's append call.](https://assets.ai.engineer/sites/aiecode2025/sha256/4449ccf84987a4fb37879fbf647bcb09dda86ca6514002569a42c5c615aa57b9.webp)

import { defineProcessor } from "ai-engineer-workshop";

type HelloWorldState = { count: number };
const initialState: HelloWorldState = { count: 0 };

export default defineProcessor(() => ({
  slug: "hello-world",
  initialState,

  reduce: ({ event, state }) => {
    if (event.type !== "hello-world") return state;
    return { count: state.count + 1 };
  },

  afterAppend: async ({ append, event, state }) => {
    if (event.type !== "hello-world" || state.count !== 1) return;

    await append({
      path: "../child-path",
      event: {
        type: "hello-world-seen",
        payload: { sourceOffset: event.offset },
      },
    });
  },
}));

Interface text:
ai-engineer-workshop
EXPLORER
AI-ENGINEER-WORKSHOP
examples
01-hello-world
append-hello-world.ts
subscribe-hello-world.ts
02-stream-processor
hello-world-processor.ts
03-agent-processor
node_modules
.gitignore
00-example.ts
package.json
pnpm-lock.yaml
README.md
tsconfig.json
workshop.md

README.md
00-example.ts (Working Tree)
workshop.md
package.json
00-example.ts
hello-world-processor.ts
.gitignore
examples > 02-stream-processor > hello-world-processor.ts > default > defineProcessor() callback > afterAppend > path
live=true
No results
Search Agents...
New Agent
Agents

Output
Terminal
- sourceOffset
File:
- examples/03-agent-processor/agent-processor.ts
Verification:
- pnpm typecheck passes
If you want, I can also add a tiny run-agent-processor.ts or a matching prove-* script next so you can demo it immediately.
Build · GPT-5.4 · 1m 35s
Build GPT-5.4 OpenAI
93.3K (9%) ctrl+p commands

Urgent pkg.pr.new SDK demo troubleshooting
Context
93,332 tokens
9% used
$0.00 spent
MCP
cloudflare_logs Connected
context7 Connected
exa Connected
grep Connected
playwriter Connected
~/src/ai-engineer-workshop:main
OpenCode 1.4.0
node
zsh
OUTLINE
TIMELINE
Browse Marketplace

### Workshop example files

The speakers browse workshop2 examples and locate the LLM processor file as they look for a runtime snippet.

[34:05](https://www.youtube.com/watch?v=vi-2nasppAg&t=2045s) [GitHub directory listing workshop examples and processor files.](https://assets.ai.engineer/sites/aiecode2025/sha256/dcad7b5966e3b4d33308b987d35caa293924e843a697a2b677a00a21a45467e5.webp)

iterate / ai-engineer-workshop / workshop2

jonastemplestein  [codex] refine workshop events processor runtime (#1255)
eca55ad · 43 minutes ago

Name | Last commit message | Last commit date
00-example-script.ts | [codex] refine workshop events processor runtime (#1255) | 43 minutes ago
01-ping-pong.ts | [codex] refine workshop events processor runtime (#1255) | 43 minutes ago
02-nano-agent.ts | [codex] refine workshop events processor runtime (#1255) | 43 minutes ago
03-nano-agent-with-persistent-history.ts | [codex] refine workshop events processor runtime (#1255) | 43 minutes ago
04-nano-agent-with-persistent-history.ts | [codex] refine workshop events processor runtime (#1255) | 43 minutes ago
05-nano-agent-with-llm-processor.ts | [codex] refine workshop events processor runtime (#1255) | 43 minutes ago
06-nano-agent-with-streaming-llm-processor.ts | [codex] refine workshop events processor runtime (#1255) | 43 minutes ago
07-bashmode-agent.ts | [codex] refine workshop events processor runtime (#1255) | 43 minutes ago
agent-processor.test.ts | [codex] refine workshop events processor runtime (#1255) | 43 minutes ago
agent-processor.ts | [codex] refine workshop events processor runtime (#1255) | 43 minutes ago
bashmode.test.ts | [codex] refine workshop events processor runtime (#1255) | 43 minutes ago
bashmode.ts | [codex] refine workshop events processor runtime (#1255) | 43 minutes ago

Interface text:
github.com/iterate/iterate/tree/main/ai-engineer-workshop/workshop2
'Playwriter' started debugging this browser
Cancel
Files
main
Go to file
Add file
History
.cursor
.github
.husky
.opencode
.superset
.vscode
ai-engineer-workshop
deploy
deployed-processor
lib
workshop
workshop2

### Configure the hello-world processor runtime

The demo wires the hello-world processor into a runtime with an events client and stream path. The processor counts hello-world events and appends a follow-up when the count reaches one.

[34:16](https://www.youtube.com/watch?v=vi-2nasppAg&t=2056s) [GitHub code view with the processor runtime configuration highlighted.](https://assets.ai.engineer/sites/aiecode2025/sha256/a54cb22bcdfcf25854e86c69012962092a001071d95aac86f489b381d2cdbad9.webp)

05-nano-agent-with-llm-processor.ts

import {
  createEventsClient,
  PullSubscriptionProcessorRuntime,
  workshopLogger,
  workshopPathPrefix,
} from "ai-engineer-workshop";
import { agentProcessor } from "./agent-processor.ts";

try {
  const pathPrefix = workshopPathPrefix();
  const streamPath = `${pathPrefix}/nano-agent`;

  console.log(`Watching ${streamPath}`);

  await new PullSubscriptionProcessorRuntime({
    eventsClient: createEventsClient(),
    logger: workshopLogger,
    processor: agentProcessor,
    streamPath,
  }).run();
} catch (error: unknown) {
  console.log(error);
  process.exitCode = 1;
}

Interface text:
github.com/iterate/iterate/blob/main/ai-engineer-workshop/workshop2/05-nano-agent-with-llm-processor.ts
'Playwriter' started debugging this browser
Files · main · Go to file
iterate / ai-engineer-workshop / workshop2 / 05-nano-agent-with-llm-processor.ts
jonastemplestein · [codex] refine workshop events processor runtime (#1255) · eca55ad · 43 minutes ago · History
Code · Blame · 24 lines (21 loc) · 584 Bytes · Raw
workshop2: 00-example-script.ts, 01-ping-pong.ts, 02-nano-agent.ts, 03-nano-agent-with-persistent..., 04-nano-agent-with-persistent..., 05-nano-agent-with-llm-proce..., 06-nano-agent-with-streaming..., 07-bashmode-agent.ts, agent-processor.test.ts, agent-processor.ts, bashmode.test.ts, bashmode.ts

[34:53](https://www.youtube.com/watch?v=vi-2nasppAg&t=2093s) [Editor showing a hello-world processor and its runtime configuration.](https://assets.ai.engineer/sites/aiecode2025/sha256/d6d58a3ea6a205737bc7bf568458fca27029e5a35550665e7f64a28d3a6098e1.webp)

hello-world-processor.ts

const processor = defineProcessor(() => ({
[lines 7–9 not visible]
  reduce: ({ event, state }) => {
    if (event.type !== "hello-world") return state;
    return { count: state.count + 1 };
  },

  afterAppend: async ({ append, event, state }) => {
    if (event.type !== "hello-world" || state.count !== 1) return;

    await append({
      path: "../child-path",
      event: {
        type: "hello-world-seen",
        payload: { sourceOffset: event.offset },
      },
    });
  },
}));

await new PullSubscriptionProcessorRuntime({
  eventsClient: createEventsClient(),
  processor,
  streamPath: "/jonas/example",
}).run();

Terminal:
- sourceOffset

File:
- examples/03-agent-processor/agent-processor.ts

Verification:
- pnpm typecheck passes

If you want, I can also add a tiny run-agent-processor.ts or a matching prove-* script next so you can demo it immediately.

Interface text:
ai-engineer-workshop
EXPLORER
examples / 02-stream-processor / hello-world-processor.ts / eventsClient
examples: 01-hello-world, append-hello-world.ts, subscribe-hello-world.ts, 02-stream-processor, hello-world-processor.ts, 03-agent-processor
node_modules · .gitignore · 00-example.ts · package.json · pnpm-lock.yaml · README.md · tsconfig.json · workshop.md
Search: live=true · No results
Output · Terminal
Urgent pkg.pr.new SDK demo troubleshooting
Context · 93,332 tokens · 9% used · $0.00 spent
MCP: cloudflare_logs Connected, context7 Connected, exa Connected, grep Connected, playwriter Connected
Build · GPT-5.4 · 1m 35s
OpenCode 1.4.0

### Run the processor

The processor catches up to one event on /jonas/example and reports a count of zero. The earlier hello-world append shown in the terminal targets /mmkal/hello-world.

[35:21](https://www.youtube.com/watch?v=vi-2nasppAg&t=2121s) [Editor and terminal showing the processor catching up and reporting a count of zero.](https://assets.ai.engineer/sites/aiecode2025/sha256/c75e9e3d353df4288ca8018384cbe778567c26ae8305d8151f05a35825cf40b9.webp)

hello-world-processor.ts

const processor = defineProcessor(() => ({
  [lines obscured]
  reduce: ({ event, state }) => {
    if (event.type !== "hello-world") return state;
    return { count: state.count + 1 };
  },

  afterAppend: async ({ append, event, state }) => {
    if (event.type !== "hello-world" || state.count !== 1) return;

    await append({
      path: "../child-path",
      event: {
        type: "hello-world-seen",
        payload: { sourceOffset: event.offset },
      },
    });
  },
}));

await new PullSubscriptionProcessorRuntime({
  eventsClient: createEventsClient(),
  [rest obscured]

Terminal:
node examples/01-hello-world/append-hello-world.ts
{
  "event": {
    "streamPath": "/mmkal/hello-world",
    "type": "hello-world",
    "payload": {
      "message": "hello world"
    },
    "offset": 5,
    "createdAt": "2026-04-08T10:11:36.518Z"
  }
}

node examples/02-stream-processor/hello-world-processor.ts
[stream:hello-world] Catching up to stream /jonas/example.
[stream:hello-world] Reduced 1 event up to offset 1.
Reduced state:
  {
    "count": 0
  }

Interface text:
AI-ENGINEER-WORKSHOP
EXPLORER
examples
01-hello-world
append-hello-world.ts
subscribe-hello-world.ts
02-stream-processor
hello-world-processor.ts
03-agent-processor
node_modules
.gitignore
00-example.ts
package.json
pnpm-lock.yaml
README.md
tsconfig.json
workshop.md
README.md
00-example.ts (Working Tree)
workshop.md
package.json M
00-example.ts
hello-world-processor.ts M
.gitignore
examples > 02-stream-processor > hello-world-processor.ts > eventsClient
live=true
No results
Output
Terminal
node
Search Agents...
New Agent
Agents
OUTLINE
TIMELINE
Browse Marketplace

### Hello-world stream processor

The processor counts hello-world events and appends a hello-world-seen event when the count is 1. A runtime consumes /jonas/example and runs the reducer and after-append hook; the displayed catch-up leaves the count at 0.

[35:53](https://www.youtube.com/watch?v=vi-2nasppAg&t=2153s) [Editor showing the processor append call without an explicit destination and the runtime configuration below it.](https://assets.ai.engineer/sites/aiecode2025/sha256/289447c5f8422690edac681a2ffb7351ed6773a4de3ba66e497af20e0bff8671.webp)

type HelloWorldState = { count: number };
const initialState: HelloWorldState = { count: 0 };

const processor = defineProcessor(() => ({
  slug: "hello-world",
  initialState,

  reduce: ({ event, state }) => {
    if (event.type !== "hello-world") return state;
    return { count: state.count + 1 };
  },

  afterAppend: async ({ append, event, state }) => {
    if (event.type !== "hello-world" || state.count !== 1) return;

    await append({
      event: {
        type: "hello-world-seen",
        payload: { sourceOffset: event.offset },
      },
    });
  },
}));

await new PullSubscriptionProcessorRuntime({
  eventsClient: createEventsClient(),
  processor,
  streamPath: "/jonas/example",
}).run();

Terminal:
"payload": {
  "message": "hello world"
},
"offset": 5,
"createdAt": "2026-04-08T10:11:36.518Z"
}
}
node examples/02-stream-processor/hello-world-processor.ts
[stream:hello-world] Catching up to stream /jonas/example.
[stream:hello-world] Reduced 1 event up to offset 1.
Reduced state:
{
  "count": 0
}

Interface text:
Cursor — ai-engineer-workshop
EXPLORER
AI-ENGINEER-WORKSHOP
examples
01-hello-world
append-hello-world.ts
subscribe-hello-world.ts
02-stream-processor
hello-world-processor.ts
03-agent-processor
node_modules
.gitignore
00-example.ts
package.json
pnpm-lock.yaml
README.md
tsconfig.json
workshop.md
README.md | 00-example.ts (Working Tree) | workshop.md | package.json | 00-example.ts | hello-world-processor.ts | .gitignore
live=true
No results
Search Agents...
New Agent
Agents
Output | Terminal
node
OUTLINE
TIMELINE
Browse Marketplace

[36:13](https://www.youtube.com/watch?v=vi-2nasppAg&t=2173s) [A code editor shows a stream processor that counts hello-world events and appends a response.](https://assets.ai.engineer/sites/aiecode2025/sha256/b12aebf6a0a1a2b5dc9a77f553bdd36e562511879dfb8c3be07f2035130595b4.webp)

import { createEventsClient, defineProcessor, PullSubscriptionProcessorRuntime } from "ai-engineer-workshop";

type HelloWorldState = { count: number };
const initialState: HelloWorldState = { count: 0 };

const processor = defineProcessor(() => ({
  slug: "hello-world",
  initialState,

  reduce: ({ event, state }) => {
    if (event.type !== "hello-world") return state;
    return { count: state.count + 1 };
  },

  afterAppend: async ({ append, event, state }) => {
    if (event.type !== "hello-world" || state.count !== 1) return;

    await append({
      event: {
        type: "hello-world-seen",
        payload: { sourceOffset: event.offset },
      },
    });
  },
}));

await new PullSubscriptionProcessorRuntime({
  eventsClient: createEventsClient(),
  processor,
  streamPath: "/jonas/example",
}).run();

Terminal:
"payload": {
  "message": "hello world"
},
"offset": 5,
"createdAt": "2026-04-08T10:11:36.518Z"
}
}
node examples/02-stream-processor/hello-world-processor.ts
[stream:hello-world] Catching up to stream /jonas/example.
[stream:hello-world] Reduced 1 event up to offset 1.
Reduced state:
{
  "count": 0
}

Interface text:
Cursor — ai-engineer-workshop
EXPLORER
AI-ENGINEER-WORKSHOP
examples
01-hello-world
append-hello-world.ts
subscribe-hello-world.ts
02-stream-processor
hello-world-processor.ts
03-agent-processor
node_modules
.gitignore
00-example.ts
package.json
pnpm-lock.yaml
README.md
tsconfig.json
workshop.md
README.md | 00-example.ts (Working Tree) | workshop.md | package.json | 00-example.ts | hello-world-processor.ts | .gitignore
live=true
No results
Search Agents...
New Agent
Agents
Output | Terminal
Add to Chat
node
OUTLINE
TIMELINE
Browse Marketplace

### Submit a hello-world event

A hello-world event is appended to /jonas/example. The presenter expects a processor response, but none is visible in the stream view.

[36:37](https://www.youtube.com/watch?v=vi-2nasppAg&t=2197s) [The stream interface shows a hello-world event and an event-appended confirmation.](https://assets.ai.engineer/sites/aiecode2025/sha256/95bdd028ba9432d76588ac323aaa4e9e709f231da1f23596e22bfe031bdfa5c2.webp)

Streams / jonas / example
Raw 3
Semantic 1
Raw + Pretty

https://events.iterate.com/events/stream/initialized · 11:17:58
DURABLE OBJECT INITIALIZED
https://events.iterate.com/manual-event-appended · +1m13s · 11:19:11
hello-world · +11.7s · 11:19:23

{
  "type": "hello-world"
}

JSON  YAML  Agent
Manual Event Appended
Event appended

Interface text:
Events
durable streams
Env vars
Streams
Create stream
Filter streams
/ 65
/alberto 1
/api 1
/boop
/dbanga 2
/docs
/hans 1
/hello-world
/hjelter 1
/jaro 1
/jonas 4
/00 1
/child-path
/example
/jonastemplestein 1
/marcogallo 1
/mgallo 1
/mike 3
/mikebell 1
PROJECT SLUG
public
Apply

Wednesday, 8 April 2026 at 11:19:23 BST
Click to see raw payload

events.iterate.com/streams/jonas/example/?renderer=raw-pretty&composer=json&projectSlug=public
'Playwriter' started debugging this browser
Cancel
Relaunch to update

## Full transcript

[0:00](https://www.youtube.com/watch?v=vi-2nasppAg&t=0s) [upbeat music] Welcome to, to the workshop.

[0:16](https://www.youtube.com/watch?v=vi-2nasppAg&t=16s) Uh, I am Jonas, um, and this is Misha. We both work at Iterate.

[0:20](https://www.youtube.com/watch?v=vi-2nasppAg&t=20s) Hi.

[0:20](https://www.youtube.com/watch?v=vi-2nasppAg&t=20s) And the, um, this is gonna be, uh, chaos. I think pure chaos. [laughs] First of all, because we only, we only decided, uh, last Monday to do this, and then there was, uh, uh, like, um, bunch of personal stuff, and half-term, and the kids were sick.

[0:35](https://www.youtube.com/watch?v=vi-2nasppAg&t=35s) And then this morning we came here, and I thought this was gonna be like a, like a hour and 20 hackathon or something like that. And then we came here, and we're told, "You're gonna do it without an audience because of some fire thing."

[0:46](https://www.youtube.com/watch?v=vi-2nasppAg&t=46s) Uh, and now there's an audience again, which is amazing. So we're gonna do, uh, gonna try and do this as like a improvised hackathon, but I've only just pushed the SDK literally one minute ago.

[0:56](https://www.youtube.com/watch?v=vi-2nasppAg&t=56s) Uh, and Misha is gonna try and, and sort of like live fix it. But I, I hope it'll still be worth your time, because I think there's sort of some, uh, hopefully at least some interesting ideas.

[1:04](https://www.youtube.com/watch?v=vi-2nasppAg&t=64s) Or, or maybe, like one way to put it is, I would like to find out whether this is like dumb or cool. Uh, and, and the, um... And, and you can help me with that.

[1:12](https://www.youtube.com/watch?v=vi-2nasppAg&t=72s) So please also just like ask clarifying questions, because part of this, the reason we said last week, "Okay, let's do this workshop," is because these have been ideas that have been kind of noodling around over the last year, but we haven't really actually done anything with.

[1:24](https://www.youtube.com/watch?v=vi-2nasppAg&t=84s) It's not really like a commercial v-value to it necessarily. But I think, um, it's, it's basically how I would like to build agent harnesses. So, you know, I've been noodling with this, uh, uh, for a while now.

[1:36](https://www.youtube.com/watch?v=vi-2nasppAg&t=96s) And, and, you know, obviously you've got like Claude and you've got Pi now, but back in the day you didn't, and so you make your own coding harness, and there's all these different ways to do it.

[1:44](https://www.youtube.com/watch?v=vi-2nasppAg&t=104s) And I think, um, the way I would like to do it is I would like to do it purely event-sourced. Um, and, uh, I say here, AKA debuggable, and that is because everything kind of skirts around of being event-sourced, like all these things, without quite being event-sourced.

[1:59](https://www.youtube.com/watch?v=vi-2nasppAg&t=119s) There's always something that has a side effect that you later can't tell, and then you can only see it in the OTel traces or something. Which doesn't really make sense to me, because normally these, these, these agents, the way they work, and we'll see that in a second, is they already have a log of events, right?

[2:12](https://www.youtube.com/watch?v=vi-2nasppAg&t=132s) So you, so if you just say everything that could possibly happen is in there, it'll be really easy to debug. Um, and as we'll see, hopefully, a little bit strange, but potentially in other ways also really easy to, to extend.

[2:24](https://www.youtube.com/watch?v=vi-2nasppAg&t=144s) Um, and then the second thing is I want, I want this to be extensible. And, and we've seen this, I think, with Pi, which is, which is incredible, um, how valuable it is to make an agent extensible, not just by humans, but also extensible by itself.

[2:36](https://www.youtube.com/watch?v=vi-2nasppAg&t=156s) Um, and, um, one thing that I want in the extensibility is, is I want, I want it to be composable. Like, I don't think we'll get there within one hour with all of you, but, but maybe afterwards if you say, "Oh, this is actually cool and not dumb," we'll keep working on this.

[2:51](https://www.youtube.com/watch?v=vi-2nasppAg&t=171s) And you can say, "Oh, I made this extension," "You made that extension," and you can combine them. And, um, um, because I think we don't really yet know what is the best recipe for, for, for agents, basically, uh, for agent harnesses, and it's been too hard to experiment.

[3:04](https://www.youtube.com/watch?v=vi-2nasppAg&t=184s) Even in Pi, like everything has to run in a single thread in, in, in, in like one process over here on this particular computer, and so on and so forth.

[3:11](https://www.youtube.com/watch?v=vi-2nasppAg&t=191s) So I think, I think we, we can maybe do a little bit better than that. Uh, then I think it should be on the edge, publicly routable. Um,

[3:19](https://www.youtube.com/watch?v=vi-2nasppAg&t=199s) like the way I think of it is basically an intelligent entity, like a digital one that's not a robot in the future. It's just internet connected, uh, basically server program, right?

[3:27](https://www.youtube.com/watch?v=vi-2nasppAg&t=207s) Like it just speaks HTTP, so the slice, broadly speaking, that should be sufficient for almost anything. And then I would just put these agents on the edge speaking to the internet straight away. [laughs]

[3:37](https://www.youtube.com/watch?v=vi-2nasppAg&t=217s) Uh, this is not very safe. None of what we're doing today is safe, by the way. There's no authentication you'll see. You'll all be able to see everybody else's event streams and agents and, and whatever else.

[3:45](https://www.youtube.com/watch?v=vi-2nasppAg&t=225s) You should not put any secrets in the actual payloads of the events or rotate them afterwards, right? So we can, um, you know, those things can be solved. But broadly speaking, the moment an agent exists, it should have a URL.

[3:57](https://www.youtube.com/watch?v=vi-2nasppAg&t=237s) That's just like, uh, uh, that's just my opinion. Uh, because otherwise, like you end up making all these things, and then you tie yourself backwards inventing a connector concept just so you can get Slack messages in or, or God knows what.

[4:08](https://www.youtube.com/watch?v=vi-2nasppAg&t=248s) And that, I think that should be really easy. Um, uh, or like maybe like a human should fill in a web form, and the result of the web form should be input for the agent again or, or something like that.

[4:17](https://www.youtube.com/watch?v=vi-2nasppAg&t=257s) That's kind of like the same thing as, as a Slack webhook. And then it should be distributed. And this is potentially, uh, like a very double-edged sword, uh, as we'll see.

[4:24](https://www.youtube.com/watch?v=vi-2nasppAg&t=264s) Like, right? But, but by distributed, I mean you should be able to have, uh, an agent, um, running, uh, sort of on one computer here on the server and my, my plugin running over here and your plugin running over there, and yours is written in Rust and mine is written in, in, in TypeScript, and it all just

[4:38](https://www.youtube.com/watch?v=vi-2nasppAg&t=278s) doesn't really matter. Um, and, um, the reason, uh, that is bad is because you will eventually get, uh, race conditions and loops, right? Like sort of like two plugins kind of sending messages back and forth, creating like an endless stream of events in your agent.

[4:52](https://www.youtube.com/watch?v=vi-2nasppAg&t=292s) Um, uh, but on the flip side, uh, you have those issues normally anyway in, in, in, uh, most agent harnesses I've seen. So it's, it's quite good if you, if you can kind of preempt that a little bit.

[5:02](https://www.youtube.com/watch?v=vi-2nasppAg&t=302s) Okay. So let's, um, let's talk about this, uh, thing that we have invented for, um... Oh my gosh. Um, what is this? This isn't the same as in my file system, so I'll, I'll use the one in my file system.

[5:18](https://www.youtube.com/watch?v=vi-2nasppAg&t=318s) Um, basically, uh, we have created this, this, uh, service over the last week called events.iterate.com. It has a web UI, um, and, uh, we can, um, uh, we- you can use that.

[5:30](https://www.youtube.com/watch?v=vi-2nasppAg&t=330s) I, I think you'll certainly use it. But for now, we'll just play with it with cURL because I think it's, it makes it, uh, in some sense more, more, uh, tractable.

[5:38](https://www.youtube.com/watch?v=vi-2nasppAg&t=338s) Um, in the, in the agents', um, uh, in the events, uh, app, we have this concept of agent paths. So just like a file in a file system, every agent has a path as a hierarchy, and you just have, uh, here, let me show this here.

[5:51](https://www.youtube.com/watch?v=vi-2nasppAg&t=351s) You just have raw events. This is YAML-formatted raw events in each of these paths. And, uh, that is basically the, the, the entire, uh, the entire primitive that we're gonna be building our agent on.

[6:02](https://www.youtube.com/watch?v=vi-2nasppAg&t=362s) And so we can start by playing with this. We can say, okay, we, we have a path prefix. If you copy this and, uh, uh, from the repo that Misha is gonna put it in the README in a second.

[6:10](https://www.youtube.com/watch?v=vi-2nasppAg&t=370s) I'll, I'll add workshop.md as well.

[6:12](https://www.youtube.com/watch?v=vi-2nasppAg&t=372s) Yeah. Uh, yeah, okay. May- uh, oh yeah, maybe that's why. Um-

[6:15](https://www.youtube.com/watch?v=vi-2nasppAg&t=375s) I, I added the README but not the workshop.

[6:17](https://www.youtube.com/watch?v=vi-2nasppAg&t=377s) Yeah. So, uh, basically, um- Let's set ourselves a path prefix here. In my case, that is just gonna be, uh, Jonas Templestein or something. Um, they start with forward slash, by the way, which is a little bit, um, awkward potentially.

[6:31](https://www.youtube.com/watch?v=vi-2nasppAg&t=391s) Uh, but the, uh, but the service is very tolerant of U- URL encoding your slashes or doing whatever you want. But I wa- I, I wanted good cURL ergonomics, uh, but I also wanted them to start with a forward slash, so you have, like, a well-defined root.

[6:44](https://www.youtube.com/watch?v=vi-2nasppAg&t=404s) Mm-hmm.

[6:44](https://www.youtube.com/watch?v=vi-2nasppAg&t=404s) Then for the base, you-

[6:44](https://www.youtube.com/watch?v=vi-2nasppAg&t=404s) It is now pushed to the repo, but have you sh- have you shared the repo?

[6:47](https://www.youtube.com/watch?v=vi-2nasppAg&t=407s) Oh, yeah, because now you could actually do this on your computer. Uh, let's do that, actually. If you go to, um, [REDACTED:url], there is an, an ai-engineer-workshop. Um,

[7:00](https://www.youtube.com/watch?v=vi-2nasppAg&t=420s) uh, and in there you should be able to ... If you click on this workshop.md file, that's what we're now going through. So you should be able to copy and paste the cURLs from there.

[7:10](https://www.youtube.com/watch?v=vi-2nasppAg&t=430s) And again, there's no authentication, so you can just do this. And, uh, in, in fact, why, why don't a couple-

[7:16](https://www.youtube.com/watch?v=vi-2nasppAg&t=436s) These are hit- hitting our live deploy-

[7:18](https://www.youtube.com/watch?v=vi-2nasppAg&t=438s) Yeah, yeah, yeah. [laughs]

[7:18](https://www.youtube.com/watch?v=vi-2nasppAg&t=438s) ... events.iterate.com.

[7:19](https://www.youtube.com/watch?v=vi-2nasppAg&t=439s) Yeah.

[7:20](https://www.youtube.com/watch?v=vi-2nasppAg&t=440s) So.

[7:20](https://www.youtube.com/watch?v=vi-2nasppAg&t=440s) Uh, like, like, like this, this is entirely just sort of like a proof of concept of, um, uh,

[7:25](https://www.youtube.com/watch?v=vi-2nasppAg&t=445s) how I think this should work. Um, what basically what we're gonna do is we're gonna turn this simple event stream into a fully-fledged agent without, like, really deploying any server software, uh, or, or anything like that.

[7:37](https://www.youtube.com/watch?v=vi-2nasppAg&t=457s) Um, maybe, uh, yeah, I should be able to see if anybody, if anybody has managed to do it. I'll wait until two or three people have managed to successfully cURL something, um, and then I'll carry on.

[7:48](https://www.youtube.com/watch?v=vi-2nasppAg&t=468s) Because I think it'll be, it'll be good if you, if you, if you cURL, uh, it yourself. So it's here in this ai-engineer-workshop, workshop.md.

[7:58](https://www.youtube.com/watch?v=vi-2nasppAg&t=478s) If two people have the same name- [laughs] ... then that's gonna cause problems, so.

[8:02](https://www.youtube.com/watch?v=vi-2nasppAg&t=482s) Same username. It doesn't matter. Um, it's, that's fine. Uh,

[8:10](https://www.youtube.com/watch?v=vi-2nasppAg&t=490s) okay, there we go. Got a few people.

[8:12](https://www.youtube.com/watch?v=vi-2nasppAg&t=492s) Nice.

[8:13](https://www.youtube.com/watch?v=vi-2nasppAg&t=493s) Um, okay, so this is pretty good. Um,

[8:16](https://www.youtube.com/watch?v=vi-2nasppAg&t=496s) by the way, uh, the ... you might see this here and there. There's also this thing down here called project slug. If you really start stepping on each other's toes, you can just type what- uh, like use a different project slug, and it's like a completely new database, a new namespace.

[8:29](https://www.youtube.com/watch?v=vi-2nasppAg&t=509s) Um, you can pass that in as an HTTP header. If anybody needs that later, you can, you can ask me. Uh, okay, so now we have a few people cURLing things.

[8:37](https://www.youtube.com/watch?v=vi-2nasppAg&t=517s) I will also for, uh, uh, start cURLing things. So, uh, now I'm just gonna say, "Hello, world," uh, here to my stream.

[8:46](https://www.youtube.com/watch?v=vi-2nasppAg&t=526s) And it'll come back, and, and, and we straight away we notice, like, a few things. There's a basic, uh, event envelope shape. We have a, uh, type that I've just invented here.

[8:54](https://www.youtube.com/watch?v=vi-2nasppAg&t=534s) Events don't need to have anything but a type, but most of them also have a payload. Uh, then, um, the, uh, there is the stream path, which, uh, came from the URL that we posted this to.

[9:03](https://www.youtube.com/watch?v=vi-2nasppAg&t=543s) And there's an offset. This is just an auto-incrementing integer that starts at one. Uh, and so there's basically, like, a point of serialization at the server that just increments them, and you get a created, created at.

[9:13](https://www.youtube.com/watch?v=vi-2nasppAg&t=553s) Uh, and then in here what we can do with cURL, which is quite nice, uh, if you do -N, you can do, uh, streaming, uh, streaming SSE. So this here is literally nothing magical.

[9:22](https://www.youtube.com/watch?v=vi-2nasppAg&t=562s) This is literally just, you know, /jonas-templestein, uh, /hello-world. This is literally the cURL that we're doing right here. Um,

[9:31](https://www.youtube.com/watch?v=vi-2nasppAg&t=571s) and, um, boop. There I can see the messages coming through. Very nice. And I can, um, I can add another message, and now, um,

[9:43](https://www.youtube.com/watch?v=vi-2nasppAg&t=583s) basically, uh, all the, all the messages will show up there. And there's also a, um,

[9:48](https://www.youtube.com/watch?v=vi-2nasppAg&t=588s) uh ... Oh, if you do ?live=true, this is, uh, inspired by the durable stream standard, but, like, ever so slightly different. But if you do, uh, live=true, the connection will stay open, and it'll just keep sending you more events as you, as you put them through.

[10:02](https://www.youtube.com/watch?v=vi-2nasppAg&t=602s) So this is sort of already, you know, um ... Like you could say this is an AI agent if Misha was simultaneously, uh, giving responses to my Hello, World.

[10:11](https://www.youtube.com/watch?v=vi-2nasppAg&t=611s) Uh, uh, th- this would already be an agent. And then there's, uh, my, my AI has told me you can, um, if you're gonna be doing that a lot, uh, you can pipe this, uh, through sed, get just the data elements, and then pipe it through jq ., and then you get a little bit nicer formatting.

[10:25](https://www.youtube.com/watch?v=vi-2nasppAg&t=625s) So this is sort of like, uh, this is so trivial that y- I actually do spend a lot of time in cURL, just curling it. Uh, then what can you do?

[10:34](https://www.youtube.com/watch?v=vi-2nasppAg&t=634s) Um, the thing is very tolerant, just in general, of, of stuff you post to it, and this will become relevant if you wanted to, say, send webhooks from random third parties there.

[10:42](https://www.youtube.com/watch?v=vi-2nasppAg&t=642s) Like, my theory is always that, like, the LLMs are good enough. They can basically just consume raw webhooks from anywhere, uh, and, and they'll roughly do the right thing.

[10:49](https://www.youtube.com/watch?v=vi-2nasppAg&t=649s) So what the, what specifically the, uh, server will do is if you send it something that doesn't, um, validate, like hogwash here, it says there's, there's no, uh, type property, so there's not actually a valid event.

[10:59](https://www.youtube.com/watch?v=vi-2nasppAg&t=659s) Then you can see here what it has appended is basically an error. But it, because we're event sourcing, the error is also just an event, and it just says here, "Okay, um, you have, uh, an invalid event appended, um, event."

[11:12](https://www.youtube.com/watch?v=vi-2nasppAg&t=672s) Oh, another thing, uh, that we, we will notice is that the type here, uh, that our server has created, it starts with https, uh, events.iterate.com. You don't have to do that, uh, but that is something that we like to do because that literally leads to the documentation for that event type.

[11:27](https://www.youtube.com/watch?v=vi-2nasppAg&t=687s) And if it's gonna be an opaque string, like, why not make it, make it something, uh, like that? But, uh, obviously you can, you can just do, you know, single words or two words or whatever.

[11:37](https://www.youtube.com/watch?v=vi-2nasppAg&t=697s) Um, but you will see these URLs, and they're just, they're just types. Um, then, uh, what else is interesting that we can do? I mean, this is kind of boring, but, you know, it ...

[11:46](https://www.youtube.com/watch?v=vi-2nasppAg&t=706s) Again, if you're gonna do webhooks, you have kind of put an idempotency key in, which just means if you have the same idempotency k- key twice, you don't get, um, you don't get the e- event appended twice.

[11:55](https://www.youtube.com/watch?v=vi-2nasppAg&t=715s) You can pause a stream. I think in the interest of time we can skip that. You can resume a stream. The reason that pausing is important and is, we put this in even though we literally just made this a couple days ago, is because of the infinite loops.

[12:07](https://www.youtube.com/watch?v=vi-2nasppAg&t=727s) Like it's very, very easy to accidentally put like, you know, thousands and thousands of events in a, in a infinite loop in the thing. And so if you put more than 100 events in a second or something, it is just gonna circuit break, and then the stream will be paused until somebody unpauses it.

[12:21](https://www.youtube.com/watch?v=vi-2nasppAg&t=741s) So basically, if you try to, um... Here, actually, let's do that. Because again, like for those of you who haven't seen event sourcing, this might be a bit weird.

[12:27](https://www.youtube.com/watch?v=vi-2nasppAg&t=747s) Like, how do you pause a stream? Well, you pause a stream by, uh... Whoa, oops, this is the wrong one. You pause a stream by appending an event that, uh, says you're, you're paused.

[12:37](https://www.youtube.com/watch?v=vi-2nasppAg&t=757s) The, the only external interface to the agent is... Oh, um, now it's complaining. Uh, why is it complaining?

[12:47](https://www.youtube.com/watch?v=vi-2nasppAg&t=767s) Ah, because I think there needs to be a reason or something maybe.

[12:53](https://www.youtube.com/watch?v=vi-2nasppAg&t=773s) Uh. Yeah. Reason demo. Yeah, there you go. So now this thing is paused, so now if I, um, you know, try to send it the "Hello, World" event from earlier, it's just gonna barf and then say, "No, no more events allowed."

[13:15](https://www.youtube.com/watch?v=vi-2nasppAg&t=795s) And that is one th- like, that is one thing that doesn't appear as an error in the stream because otherwise you would still get infinite numbers of error events.

[13:22](https://www.youtube.com/watch?v=vi-2nasppAg&t=802s) Um, uh, then, I mean, there's other weird and wonderful things you can do. I, [laughs] I don't even know if you really have to do this, but, uh, there's like, um, the...

[13:33](https://www.youtube.com/watch?v=vi-2nasppAg&t=813s) I have made a plugin for this already, uh, that makes it so that if I put this JSONata transformer configured event in, what it'll do is it'll just observe certain events, rewrite them a little bit, and make a new event out of it.

[13:44](https://www.youtube.com/watch?v=vi-2nasppAg&t=824s) But I think that's a bit advanced, so we'll, we'll do it later. Um, um, it can also do weird things like it can, uh, you, you can schedule, you can schedule things.

[13:53](https://www.youtube.com/watch?v=vi-2nasppAg&t=833s) Like some agent SDKs you'll, you'll know can do this, but, uh, here, you know, if you want like an, like a heartbeat event every five seconds. Uh, oh. Oh, God.

[14:03](https://www.youtube.com/watch?v=vi-2nasppAg&t=843s) Now I need to resume the stream because it's paused. Uh, let's see. Stream resumed.

[14:14](https://www.youtube.com/watch?v=vi-2nasppAg&t=854s) Okay. So now I am just creating, uh, this heartbeat event every five seconds, which can be quite handy. Or you can schedule something for 10 minutes in the future or at a certain time, and again, it's just an event that says, "Do this thing in the future."

[14:27](https://www.youtube.com/watch?v=vi-2nasppAg&t=867s) Um. Mm, mm, mm. Um, I think I will skip over these, but, um, you can cancel the schedule. You can tell the stream by appending an event to send your server or some third-party server or your, y- you know, your Slack API endpoint or whatever an event every time an event gets added.

[14:48](https://www.youtube.com/watch?v=vi-2nasppAg&t=888s) Uh, so you can basically, uh, subscribe to the stream. Uh, here we're subscribing in our, in our terminal. We're doing a pull subscription, right? We're doing, we're, we're connecting to, uh, an HTTP server and we're getting, uh, we're pulling, uh, pulling, um, we're the HTTP client and they're the HTTP server, and we're getting an SSE, uh, response

[15:04](https://www.youtube.com/watch?v=vi-2nasppAg&t=904s) stream of, of streaming events. But, uh, it can also do the other way around where it will push you the stuff that gets appended or push you a filtered stream, um,

[15:13](https://www.youtube.com/watch?v=vi-2nasppAg&t=913s) uh, which can be quite handy. Okay. So, um, let's maybe stop there because I know also, um, it wasn't really clear from the session description how deeply technical this was. [laughs]

[15:24](https://www.youtube.com/watch?v=vi-2nasppAg&t=924s) And so let's take any questions on what is even this thing that we're gonna be using for, for the next 45 minutes.

[15:30](https://www.youtube.com/watch?v=vi-2nasppAg&t=930s) But questions have to be submitted as an event to the question stream. So- [laughs]

[15:36](https://www.youtube.com/watch?v=vi-2nasppAg&t=936s) Yeah, exactly.

[15:36](https://www.youtube.com/watch?v=vi-2nasppAg&t=936s) If you have any trouble using it-

[15:37](https://www.youtube.com/watch?v=vi-2nasppAg&t=937s) Oh, that can be the queue

[15:38](https://www.youtube.com/watch?v=vi-2nasppAg&t=938s) ... you're out of luck. [laughs]

[15:41](https://www.youtube.com/watch?v=vi-2nasppAg&t=941s) Um, does... I, I assume lots of things don't make sense, so please do ask them because I think this will be extremely s- like random and strange so far.

[15:55](https://www.youtube.com/watch?v=vi-2nasppAg&t=955s) What does Iterate do, your company?

[15:57](https://www.youtube.com/watch?v=vi-2nasppAg&t=957s) Oh, uh, we, we're like a, we're like a, a hacker hobby club at this point to be quite honest. Like, uh, we, we, we are, uh, we have not got a launch product.

[16:06](https://www.youtube.com/watch?v=vi-2nasppAg&t=966s) Um, but if we did, it would be, um, I think based on this architecture. It's like, uh... Anyway, I'll te- [laughs] I can talk about it afterwards.

[16:15](https://www.youtube.com/watch?v=vi-2nasppAg&t=975s) Okay, okay, okay. [laughs]

[16:17](https://www.youtube.com/watch?v=vi-2nasppAg&t=977s) But it's, uh, yeah. It's more, it's more homebrew hacker club than, than like commercial enterprise at the minute, but it'll get there.

[16:26](https://www.youtube.com/watch?v=vi-2nasppAg&t=986s) Yeah.

[16:27](https://www.youtube.com/watch?v=vi-2nasppAg&t=987s) Uh, I have a question. So, uh, I know that we'll be b- building, uh, event-based, uh, agents-

[16:33](https://www.youtube.com/watch?v=vi-2nasppAg&t=993s) Yeah

[16:34](https://www.youtube.com/watch?v=vi-2nasppAg&t=994s) ... now. Any, like, uh, maybe that's a, a basic question, but for like, uh, agents that are on the market right now, are, aren't they event-based? What's the, like, the different architectures?

[16:44](https://www.youtube.com/watch?v=vi-2nasppAg&t=1004s) It's just, um, I think it's just the API. Like, if you, um, have you tried to make, uh, you know, like a, like an OpenCode extension or plugin or a Pi extension or a Claude ex- uh, Claude extension?

[16:58](https://www.youtube.com/watch?v=vi-2nasppAg&t=1018s) And they all have like an API surface that is a little bit bigger than what you would have or what we're gonna have in, in a minute. It's not like by much, right?

[17:05](https://www.youtube.com/watch?v=vi-2nasppAg&t=1025s) But like, okay, like maybe the streaming chunks for partial completions are a different kind of thing for some reason, rather than just an event of type, "I've received, you know, like five letters of a streaming response."

[17:16](https://www.youtube.com/watch?v=vi-2nasppAg&t=1036s) To me, that's a perfectly valid event and, and, and the benefit then is that you can, uh, that can, you, you j- I'm, I'm kind of like a one abstraction kind of guy, right?

[17:23](https://www.youtube.com/watch?v=vi-2nasppAg&t=1043s) Like this, this should be like a, like web standards-based, there should be, there should only be one thing, which is an event. And then as you'll see, like the, the thing, um, at, uh, that was at the top of this file, I think you can build a super expressive state-of-the-art coding agent by just implementing, uh, like a

[17:38](https://www.youtube.com/watch?v=vi-2nasppAg&t=1058s) stream processor that reduces over the event stream and occasionally enact side effects. That's, that's all it does, right? Like, it, it just sort of sits there and says, "Okay."

[17:46](https://www.youtube.com/watch?v=vi-2nasppAg&t=1066s) And w- I'll, I'll show you that in a second. Like it's, it's a bit weird, um, uh, I would say, a weird way of programming. Um.

[17:57](https://www.youtube.com/watch?v=vi-2nasppAg&t=1077s) So if I understand correctly, you're sort of saying you take events that you get generated from an, uh, AI model, and then you're basically gonna pipe them through this stream processor.

[18:06](https://www.youtube.com/watch?v=vi-2nasppAg&t=1086s) Uh, is that the idea?

[18:08](https://www.youtube.com/watch?v=vi-2nasppAg&t=1088s) The stream processor is, is, or like the, the events.iterate.com is the storage. Like, you can almost think of it as a database. Like one, one, um, you know, do you know Convex?

[18:16](https://www.youtube.com/watch?v=vi-2nasppAg&t=1096s) Is like a sort of, you know, they, they kind of give you the illusion that they're running TypeScript in the database. You, you could almost think of this, this could be like a programmable stream or something, right?

[18:24](https://www.youtube.com/watch?v=vi-2nasppAg&t=1104s) Because actually one thing that you can also do, we'll, we'll see later, once you hack on your stream processors, you can also make an event that contains the source code of your stream processor, and then it'll just run on every event.

[18:36](https://www.youtube.com/watch?v=vi-2nasppAg&t=1116s) A-a-and so, like, it's basically, it is like, it is like the... Y- I think you can experiment with a huge array of different kinds of agent harness implementations,

[18:47](https://www.youtube.com/watch?v=vi-2nasppAg&t=1127s) uh, that can respond to real events on the internet and make real API requests without deploying your service or something like that. All you need is th-this sort of, um, streaming, streaming service that, um, uh, has some of, has some of these, um, things.

[19:01](https://www.youtube.com/watch?v=vi-2nasppAg&t=1141s) Like specifically, it needs to be able to wake up, you know, like other, other APIs and, and programs and so on. I don't know if that... Yeah. Um, that-- Does that answer your question at all or [chuckles]?

[19:13](https://www.youtube.com/watch?v=vi-2nasppAg&t=1153s) Yeah, I think so, yeah.

[19:14](https://www.youtube.com/watch?v=vi-2nasppAg&t=1154s) Okay. Shall we try and make, uh, now a, um, like a, like a slightly more serious version of these cURLs? Um, so does anybody here not know TypeScript?

[19:27](https://www.youtube.com/watch?v=vi-2nasppAg&t=1167s) I think, so I think the, like one of the arguments in favor of this architecture that I also put in that, um, in that, uh, in the, in the blurb, I think, is this is, in principle, polyglot, right?

[19:37](https://www.youtube.com/watch?v=vi-2nasppAg&t=1177s) And there is a, uh, like in, in any language, there is actually at events.iterate.com/uh, api[REDACTED:url], you have

[19:45](https://www.youtube.com/watch?v=vi-2nasppAg&t=1185s) just... I mean, this is an exceedingly simple API, right? Um, uh, you c- you can make yourself, there's an OpenAPI spec, you can make yourself a client, and so on.

[19:52](https://www.youtube.com/watch?v=vi-2nasppAg&t=1192s) But for the purpose of this, uh, this, um, uh, workshop here, we'll just do a TypeScript version, and we've shipped a client in a, in a, uh, npm package already.

[20:01](https://www.youtube.com/watch?v=vi-2nasppAg&t=1201s) But I, I, I just wanted to point out, like even though we're doing everything in TypeScript, the whole point is that we wouldn't have to [chuckles] right? But we just have to do one thing, uh, uh, for this workshop.

[20:10](https://www.youtube.com/watch?v=vi-2nasppAg&t=1210s) Um, okay. So let's, uh, let's do, do something pretty simple. Um,

[20:16](https://www.youtube.com/watch?v=vi-2nasppAg&t=1216s) uh, is the, uh, ai-engineer-workshop, um, package, uh, now up to date and working? I think it is, right?

[20:23](https://www.youtube.com/watch?v=vi-2nasppAg&t=1223s) I think so, yeah. Uh, you might need to pull your repo 'cause there was a client-side type error.

[20:29](https://www.youtube.com/watch?v=vi-2nasppAg&t=1229s) In the Iterate repo?

[20:30](https://www.youtube.com/watch?v=vi-2nasppAg&t=1230s) Uh, no, the, in the ai-engineer-workshop.

[20:33](https://www.youtube.com/watch?v=vi-2nasppAg&t=1233s) Okay, that's fine. Um-

[20:34](https://www.youtube.com/watch?v=vi-2nasppAg&t=1234s) It's in example.ts.

[20:35](https://www.youtube.com/watch?v=vi-2nasppAg&t=1235s) Yeah, but, uh, I'm... Oh, maybe I will actually use that. Then, then I'll be able to experience, uh, the same, the same bugs if there are any.

[20:44](https://www.youtube.com/watch?v=vi-2nasppAg&t=1244s) Sure.

[20:44](https://www.youtube.com/watch?v=vi-2nasppAg&t=1244s) Yeah, that's probably better. Okay. Um, okay. So, uh, y- I think, um, if you wanted to just have a quick start, you can, uh, you can just pull, uh, clone the ai-engineer-workshop repo.

[20:54](https://www.youtube.com/watch?v=vi-2nasppAg&t=1254s) Um, there's already a teeny-tiny example file in there, and then we'll just add a couple more, um, as we go along.

[21:01](https://www.youtube.com/watch?v=vi-2nasppAg&t=1261s) And the workshop.md has runnable cURL as well.

[21:05](https://www.youtube.com/watch?v=vi-2nasppAg&t=1265s) Nice. Yeah.

[21:06](https://www.youtube.com/watch?v=vi-2nasppAg&t=1266s) That does work.

[21:07](https://www.youtube.com/watch?v=vi-2nasppAg&t=1267s) Um, if you wanted, you could put a coup- like a, a couple of the follow-on examples that are in the Iterate repo that have actual processors, um.

[21:17](https://www.youtube.com/watch?v=vi-2nasppAg&t=1277s) Yeah.

[21:18](https://www.youtube.com/watch?v=vi-2nasppAg&t=1278s) Hmm.

[21:18](https://www.youtube.com/watch?v=vi-2nasppAg&t=1278s) I can take a look.

[21:21](https://www.youtube.com/watch?v=vi-2nasppAg&t=1281s) Um, bum, bum, bum, bum. Hmm. I don't know what's going on here.

[21:31](https://www.youtube.com/watch?v=vi-2nasppAg&t=1291s) Aha. There we go. Hmm. [in background] My computer seems to have, uh, slowed to a crawl trying to open a Cursor window, um [chuckles]

[21:48](https://www.youtube.com/watch?v=vi-2nasppAg&t=1308s) . This has been unfortunately like a, a somewhat regular occurrence recently. [in background]

[21:56](https://www.youtube.com/watch?v=vi-2nasppAg&t=1316s) Uh, okay. Okay. Or, oh, no, I think this might be what you mentioned about the internet.

[22:15](https://www.youtube.com/watch?v=vi-2nasppAg&t=1335s) I think it's just struggling because it can't open a terminal because the,

[22:19](https://www.youtube.com/watch?v=vi-2nasppAg&t=1339s) my, my terminal tries to connect with the internet.

[22:21](https://www.youtube.com/watch?v=vi-2nasppAg&t=1341s) It does?

[22:22](https://www.youtube.com/watch?v=vi-2nasppAg&t=1342s) Hmm. Oh, well. Then let's do the... Um...

[22:42](https://www.youtube.com/watch?v=vi-2nasppAg&t=1362s) No, it's not the internet. Or is it?

[22:46](https://www.youtube.com/watch?v=vi-2nasppAg&t=1366s) There we go. Okay. Okay. So we have here,

[23:00](https://www.youtube.com/watch?v=vi-2nasppAg&t=1380s) um, we have packaged up an SDK here to this, uh, ai-engineer-workshop, um, package that you should be able to just pnpm install or you just use, uh, use this example here.

[23:10](https://www.youtube.com/watch?v=vi-2nasppAg&t=1390s) And then basically, uh, what did, what did we need in our cURL? Right? Like, we needed a base URL, which is just events.iterate.com. That's where our server is. Uh, we can use a path prefix.

[23:19](https://www.youtube.com/watch?v=vi-2nasppAg&t=1399s) Um, and, um, then we can, uh, run this function here called createEventsClient. That is from our SDK. And then y- this is under the hood. This is... Oh. Hmm.

[23:31](https://www.youtube.com/watch?v=vi-2nasppAg&t=1411s) I really don't know what's going on with this terminal. It's very strange.

[23:40](https://www.youtube.com/watch?v=vi-2nasppAg&t=1420s) Hmm. Hmm. Okay, maybe, um, everything is just incredibly slow.

[23:53](https://www.youtube.com/watch?v=vi-2nasppAg&t=1433s) Do you want to try mine? Mine is-

[23:55](https://www.youtube.com/watch?v=vi-2nasppAg&t=1435s) Um.

[23:56](https://www.youtube.com/watch?v=vi-2nasppAg&t=1436s) Okay.

[23:57](https://www.youtube.com/watch?v=vi-2nasppAg&t=1437s) Maybe, but there's nothing actually hogging the CPU. It's just, I th- I do think it might be actually the network, but we'll see. Um,

[24:04](https://www.youtube.com/watch?v=vi-2nasppAg&t=1444s) so here. So here you have, um- [coughing] I don't think this has picked up the... Anyway, okay. So this is basically what we were doing just now, right? Like we, we say, "Okay, we're making ourself a client," uh, and then, um, here there is a function called stream This is basically the, um, the, the, the right-hand side of

[24:28](https://www.youtube.com/watch?v=vi-2nasppAg&t=1468s) the, of the terminal that we had earlier, and then you say live true and give them the stream path. And we can say, okay, if, if, uh, if the event is not of type ping, we will do nothing.

[24:37](https://www.youtube.com/watch?v=vi-2nasppAg&t=1477s) But if the event is of type ping, then we will... I mean, this is a completely unnecessary helper down there. Uh, then we can just do client.append. I don't understand why the, um,

[24:50](https://www.youtube.com/watch?v=vi-2nasppAg&t=1490s) the, the TypeScript language server isn't picking up any of the types for me, but I can't tell if that's just, um-

[24:55](https://www.youtube.com/watch?v=vi-2nasppAg&t=1495s) Cursor being weird again

[24:57](https://www.youtube.com/watch?v=vi-2nasppAg&t=1497s) ... your own example. Let me see.

[24:58](https://www.youtube.com/watch?v=vi-2nasppAg&t=1498s) Yeah.

[24:59](https://www.youtube.com/watch?v=vi-2nasppAg&t=1499s) Anyway, um-

[25:03](https://www.youtube.com/watch?v=vi-2nasppAg&t=1503s) Could quickly switch IDEs.

[25:05](https://www.youtube.com/watch?v=vi-2nasppAg&t=1505s) No, it's fine.

[25:06](https://www.youtube.com/watch?v=vi-2nasppAg&t=1506s) It is working for me.

[25:07](https://www.youtube.com/watch?v=vi-2nasppAg&t=1507s) Okay. Yeah. I think this is unfortunately like a, a sort of Cursor. [chuckles]

[25:13](https://www.youtube.com/watch?v=vi-2nasppAg&t=1513s) Okay. And then you should be able to, uh, just if you have a modern version of Node, you should be able to just run, um,

[25:19](https://www.youtube.com/watch?v=vi-2nasppAg&t=1519s) uh, or maybe not. Did I make it?

[25:23](https://www.youtube.com/watch?v=vi-2nasppAg&t=1523s) Um, uh, uh, uh. It says invalid TypeScript syntax.

[25:32](https://www.youtube.com/watch?v=vi-2nasppAg&t=1532s) You know what, I'm just gonna, I'm just gonna restart Cursor. I think that is worth it.

[25:39](https://www.youtube.com/watch?v=vi-2nasppAg&t=1539s) Is anyone, uh, able to run this example.ts on their computer? There you go.

[25:43](https://www.youtube.com/watch?v=vi-2nasppAg&t=1543s) I am.

[25:44](https://www.youtube.com/watch?v=vi-2nasppAg&t=1544s) Hmm. Okay. Um, and are you able to send a ping to it and get a pong out of it? Okay, very cool. [keyboard clicking]

[26:15](https://www.youtube.com/watch?v=vi-2nasppAg&t=1575s) Okay. [keyboard clicking] Hmm. Um, yeah.

[26:43](https://www.youtube.com/watch?v=vi-2nasppAg&t=1603s) I don't... Yeah. I wonder if we used, use-- I don't know if you can see this, but basically all my commands, they have like a several second delay, which is-

[26:52](https://www.youtube.com/watch?v=vi-2nasppAg&t=1612s) Yeah, it's looking okay to me if you wanna just swap laptops.

[26:56](https://www.youtube.com/watch?v=vi-2nasppAg&t=1616s) Um, hmm. Maybe.

[27:12](https://www.youtube.com/watch?v=vi-2nasppAg&t=1632s) I had to pnpm that package, the one that you imported.

[27:16](https://www.youtube.com/watch?v=vi-2nasppAg&t=1636s) Yeah, no, I know, but it, it's just... Yeah. It's just my editor doesn't work, and I also have several non-responsive, uh, Cursor sort of... [chuckles] I feel like this is, uh, unfortunately a pattern with Cursor recently.

[27:30](https://www.youtube.com/watch?v=vi-2nasppAg&t=1650s) Hmm.

[27:32](https://www.youtube.com/watch?v=vi-2nasppAg&t=1652s) I-

[27:32](https://www.youtube.com/watch?v=vi-2nasppAg&t=1652s) If you wanna swap laptops, my... It does seem to be working okay from, on mine.

[27:36](https://www.youtube.com/watch?v=vi-2nasppAg&t=1656s) I would just give everybody 60 more seconds to just get, get the basic demo working, and then-

[27:40](https://www.youtube.com/watch?v=vi-2nasppAg&t=1660s) Just let me know.

[27:41](https://www.youtube.com/watch?v=vi-2nasppAg&t=1661s) Yeah, because I think using some... You know, this is still almost an hour to go. It's not good to use somebody else's computer.

[28:05](https://www.youtube.com/watch?v=vi-2nasppAg&t=1685s) Uh. Maybe I will continue on yours, and I'll just restart my computer.

[28:21](https://www.youtube.com/watch?v=vi-2nasppAg&t=1701s) I think that's a good idea because we can... Yeah.

[28:27](https://www.youtube.com/watch?v=vi-2nasppAg&t=1707s) Dum, bum, bum.

[28:29](https://www.youtube.com/watch?v=vi-2nasppAg&t=1709s) I also have examples zero one and zero two-

[28:31](https://www.youtube.com/watch?v=vi-2nasppAg&t=1711s) Oh, really? Oh, brilliant

[28:32](https://www.youtube.com/watch?v=vi-2nasppAg&t=1712s) ... I think working with some-

[28:33](https://www.youtube.com/watch?v=vi-2nasppAg&t=1713s) What's your keyboard layout?

[28:35](https://www.youtube.com/watch?v=vi-2nasppAg&t=1715s) Uh, probably the same as yours.

[28:37](https://www.youtube.com/watch?v=vi-2nasppAg&t=1717s) One can, [chuckles] one can, one can hope. Uh, okay. And entire screen.

[28:43](https://www.youtube.com/watch?v=vi-2nasppAg&t=1723s) Looks the same.

[28:44](https://www.youtube.com/watch?v=vi-2nasppAg&t=1724s) Uh, it looks pretty good so far. Um,

[28:54](https://www.youtube.com/watch?v=vi-2nasppAg&t=1734s) what have you got a terminal? Uh, so

[29:01](https://www.youtube.com/watch?v=vi-2nasppAg&t=1741s) let's Node examples zero one hello world. Okay, perfect. Yeah. Well, this w- works flawlessly. Uh, so, um,

[29:18](https://www.youtube.com/watch?v=vi-2nasppAg&t=1758s) has everybody got that more or less working? Because then we can just make an OpenAI coding agent now. Um, I think that's all we need.

[29:27](https://www.youtube.com/watch?v=vi-2nasppAg&t=1767s) Let's maybe... I'll ask, um, do you have, uh, speech control in here?

[29:32](https://www.youtube.com/watch?v=vi-2nasppAg&t=1772s) Uh, yeah. It's Control and Option. It's Kit's one.

[29:36](https://www.youtube.com/watch?v=vi-2nasppAg&t=1776s) Yeah? And then?

[29:38](https://www.youtube.com/watch?v=vi-2nasppAg&t=1778s) That's it. It's recording.

[29:40](https://www.youtube.com/watch?v=vi-2nasppAg&t=1780s) Hello. Oh, cool.

[29:42](https://www.youtube.com/watch?v=vi-2nasppAg&t=1782s) See that red bar is-

[29:44](https://www.youtube.com/watch?v=vi-2nasppAg&t=1784s) Um, hey, I would like to make a third example, uh, called agent processor, and for that, we need to install, uh, just the normal OpenAI SDK. Please, uh, do that and just make me a new file that looks like the hello world processor.

[30:00](https://www.youtube.com/watch?v=vi-2nasppAg&t=1800s) Okay. Um, okay, so, um, I just gotta gather everybody again after I left you for about, uh, 10 minutes.

[30:15](https://www.youtube.com/watch?v=vi-2nasppAg&t=1815s) Yeah.

[30:17](https://www.youtube.com/watch?v=vi-2nasppAg&t=1817s) Here, this is a normal, uh, pretty normal spaghetti code TypeScript program, right? Like, uh, basically what we've done here is we, we sort of like, uh, doing some boilerplate work.

[30:25](https://www.youtube.com/watch?v=vi-2nasppAg&t=1825s) Um, uh, here if we want to subscribe, we, we have to make a subscription. Um, oh my gosh. This example that you put in there has like an a- abort signal and, and handles all kinds of things.

[30:35](https://www.youtube.com/watch?v=vi-2nasppAg&t=1835s) And, and, um, anyway, the, the, um... I think, um, uh, the way I think about what we're really doing is we're, we're writing a stream processor. And if you've never done stream processing, uh, this, this might be like a bit weird, and people use slightly different n- names for, for these things.

[30:48](https://www.youtube.com/watch?v=vi-2nasppAg&t=1848s) But really, um, what we're saying is, um, there, uh, exists, uh, some kind of world state that we're interested in that can be derived from the events. Uh, in this, uh, in this example here that Misha made, uh, we are, uh, trying to count, uh, the number of times an "Hello, World!"

[31:04](https://www.youtube.com/watch?v=vi-2nasppAg&t=1864s) event has, uh, been encountered in the stream. And then you can write the entire logic of your program as, uh, effectively a reduce function. This is, this is synchronous, and it just, um, it just, uh, looks at all the new events as they come in, and then it updates the state.

[31:20](https://www.youtube.com/watch?v=vi-2nasppAg&t=1880s) That's all it does. So it takes, uh, a state and event, and it, uh, returns the new state. Or you can just also return nothing. It'll, it'll be fine.

[31:28](https://www.youtube.com/watch?v=vi-2nasppAg&t=1888s) It'll just ignore it. And, um, and then, uh, you ca- you should not do side effects in this reduce function. Um, and the reason I've split the reduce function from, from after append, where you should do your side effects, is because, uh, if you think about what happens if, if your program, uh, goes to sleep, right?

[31:44](https://www.youtube.com/watch?v=vi-2nasppAg&t=1904s) Like you're, uh, you're, you're closing your laptop. At the moment, everything's running on our laptops. Uh, you know, 100 new events go into the stream. Some of these events might, in the future, need to trigger LLM requests or something like this.

[31:53](https://www.youtube.com/watch?v=vi-2nasppAg&t=1913s) And then you bring, uh, you open your computer again, you start your, your program again, and you don't want your program to go and, um, make a ton of LLM requests for all of those 100 events in the past, uh, necessarily.

[32:04](https://www.youtube.com/watch?v=vi-2nasppAg&t=1924s) Uh, instead, you want it to sort of like ca- catch up all the way, and then decide what to do, um, with the state at the end. And so we've made this, like, super lightweight, um, abstraction here of a processor that basically, um, gets hooked up into a processor runtime.

[32:19](https://www.youtube.com/watch?v=vi-2nasppAg&t=1939s) Um, and, um, what it does, uh, is, uh, it, it, it splits your work into reducing events into state. And then if you want to do some side effects, like for example, appending, um, appending to, uh, uh, you know, to the same stream again, you can do this.

[32:32](https://www.youtube.com/watch?v=vi-2nasppAg&t=1952s) By the way, I think, uh, I think you can also do this, which, which is, like, potentially, uh, this is pretty interesting. Um, like, uh, uh, you know, you, you can literally just append to, uh, you know, like a child path, or you can append to, uh, a parent path or, or, uh, or whatever, um, else you

[32:52](https://www.youtube.com/watch?v=vi-2nasppAg&t=1972s) want. Uh, it's basically like a, uh, meant to be like a file system. And so if you wanted to build sub-agents on this thing, all you would do is probably you would just append to ./ you know, Boris, and pretend that Boris is a sub-agent.

[33:03](https://www.youtube.com/watch?v=vi-2nasppAg&t=1983s) And then you would just subscribe to some special events that Boris might output, like, "I have the result." And then you would automatically be woken up again on the parent when Boris has the result.

[33:13](https://www.youtube.com/watch?v=vi-2nasppAg&t=1993s) Um, is this confirmed, Misha, that this runs? Like, how do you run this? This just exports the,

[33:19](https://www.youtube.com/watch?v=vi-2nasppAg&t=1999s) um... Like, you, you need, you need the runtime, right?

[33:23](https://www.youtube.com/watch?v=vi-2nasppAg&t=2003s) Yes. There is a CLI command that I now can't remember because my agent has been [chuckles] running it. Uh, where you can...

[33:32](https://www.youtube.com/watch?v=vi-2nasppAg&t=2012s) You should be able to do pnpmw and then path to the file, I think.

[33:37](https://www.youtube.com/watch?v=vi-2nasppAg&t=2017s) Did, did you do all that just now?

[33:38](https://www.youtube.com/watch?v=vi-2nasppAg&t=2018s) I did that about a week ago, but you may have changed it.

[33:40](https://www.youtube.com/watch?v=vi-2nasppAg&t=2020s) No, no, no. Yeah. Okay. So, okay. Okay. [chuckles]

[33:44](https://www.youtube.com/watch?v=vi-2nasppAg&t=2024s) Um, let's go to our repo. Like I promised, this is, uh,

[33:51](https://www.youtube.com/watch?v=vi-2nasppAg&t=2031s) a little bit... The, these are the, um... So you can actually also do this. If you go to iterate/iterate, ai-engineer-workshop, um,

[34:01](https://www.youtube.com/watch?v=vi-2nasppAg&t=2041s) here there are a bunch of examples, uh, of files that are, um-

[34:05](https://www.youtube.com/watch?v=vi-2nasppAg&t=2045s) Uh, workshop two. I was going from workshop one.

[34:07](https://www.youtube.com/watch?v=vi-2nasppAg&t=2047s) Ah.

[34:08](https://www.youtube.com/watch?v=vi-2nasppAg&t=2048s) Yes.

[34:08](https://www.youtube.com/watch?v=vi-2nasppAg&t=2048s) Yeah, I also-

[34:09](https://www.youtube.com/watch?v=vi-2nasppAg&t=2049s) These out-of-date ones

[34:09](https://www.youtube.com/watch?v=vi-2nasppAg&t=2049s) That was meant to be, uh, meant to be renamed.

[34:13](https://www.youtube.com/watch?v=vi-2nasppAg&t=2053s) Um, ah, here. This is, this is, this is basically the snippet we want.

[34:20](https://www.youtube.com/watch?v=vi-2nasppAg&t=2060s) Okay.

[34:21](https://www.youtube.com/watch?v=vi-2nasppAg&t=2061s) There is this, um, there is this thing, uh, that you can have. Um, so here now we've just made a processor, right? Like, this is just like a sort of inert thing.

[34:29](https://www.youtube.com/watch?v=vi-2nasppAg&t=2069s) And then, um, there's a thing called a, uh, pull subscriptions processor runtime. Um, and all that does is it takes your, um, it takes your, uh, your processor that you just made, and it, uh, runs it.

[34:47](https://www.youtube.com/watch?v=vi-2nasppAg&t=2087s) Um-

[34:48](https://www.youtube.com/watch?v=vi-2nasppAg&t=2088s) I think you probably need to assign it to a variable 'cause you'll just export default above.

[34:53](https://www.youtube.com/watch?v=vi-2nasppAg&t=2093s) Um, yes. Doot doo doo. Mm-hmm. Okay. Um,

[35:14](https://www.youtube.com/watch?v=vi-2nasppAg&t=2114s) uh, and here, let's just say, uh... Just see if we can run this.

[35:23](https://www.youtube.com/watch?v=vi-2nasppAg&t=2123s) Doop doop.

[35:27](https://www.youtube.com/watch?v=vi-2nasppAg&t=2127s) Sorry, a question. Should we, should, should I have access to these examples that you're showing?

[35:32](https://www.youtube.com/watch?v=vi-2nasppAg&t=2132s) Uh, yes, but unfortunately, they need to be modified, uh, um, in order to, uh,

[35:40](https://www.youtube.com/watch?v=vi-2nasppAg&t=2140s) um, do anything interesting.

[35:42](https://www.youtube.com/watch?v=vi-2nasppAg&t=2142s) Okay, because I don't see them on GitHub.

[35:44](https://www.youtube.com/watch?v=vi-2nasppAg&t=2144s) Um-

[35:45](https://www.youtube.com/watch?v=vi-2nasppAg&t=2145s) Yes, those ones are, those ones are, were added in the last few minutes, but, uh, usually-

[35:51](https://www.youtube.com/watch?v=vi-2nasppAg&t=2151s) Yeah. I gave slightly, um-

[35:54](https://www.youtube.com/watch?v=vi-2nasppAg&t=2154s) Version of the-

[35:54](https://www.youtube.com/watch?v=vi-2nasppAg&t=2154s) ... bad copying instructions. Um, but I think, I think-

[35:59](https://www.youtube.com/watch?v=vi-2nasppAg&t=2159s) Those aren't committed yet.

[36:00](https://www.youtube.com/watch?v=vi-2nasppAg&t=2160s) Yeah. Hmm. Uh, I think the b- we're just gonna have to sort of like slowly, slowly build it up in, in this repo and then, uh, push it once it works here, unfortunately.

[36:12](https://www.youtube.com/watch?v=vi-2nasppAg&t=2172s) Um, so here, uh, basically what I've now done is I've taken this processor and I've hooked it up, uh, uh, to this runtime, and all the runtime does is it does this, like, boilerplate for, for consuming the stream and running the reducer and run it, running, um, uh, the, uh, after append hook.

[36:27](https://www.youtube.com/watch?v=vi-2nasppAg&t=2187s) And what we should see is once, uh, you submit "Hello, World!" into this, uh, into this path here that is just jonas/example Uh, you should get a response there.

[36:36](https://www.youtube.com/watch?v=vi-2nasppAg&t=2196s) So if I go here in the, in the UI, and I go to jonas/example, and I think I said this should be event of type Hello World. Um, oh no, this, uh, is up here.

[36:53](https://www.youtube.com/watch?v=vi-2nasppAg&t=2213s) If all works, this would be sort of like the proof point that lets us...

[36:58](https://www.youtube.com/watch?v=vi-2nasppAg&t=2218s) It doesn't. Hello world seen. Um.

[37:05](https://www.youtube.com/watch?v=vi-2nasppAg&t=2225s) I don't remember if this example relies on the, uh, machine username, but if it does, then that would be mmkal, not jonas.

[37:12](https://www.youtube.com/watch?v=vi-2nasppAg&t=2232s) Um, maybe. Let's just do this. Ah. Sorry, this is like the worst workshop because now I'm also on the wrong computer. [chuckles]

[37:34](https://www.youtube.com/watch?v=vi-2nasppAg&t=2254s) Um, it does after append. And, hmm. Okay.

[37:52](https://www.youtube.com/watch?v=vi-2nasppAg&t=2272s) Is my computer back up?

[37:54](https://www.youtube.com/watch?v=vi-2nasppAg&t=2274s) It's, uh, well, yes, but I don't know your password.

[37:56](https://www.youtube.com/watch?v=vi-2nasppAg&t=2276s) Okay. Yeah. I'll, I'll do that in a second. Okay. Um,

[38:01](https://www.youtube.com/watch?v=vi-2nasppAg&t=2281s) this example here is not working. Okay. So I think we have to do plan B, but we might not actually be able to run this.

[38:10](https://www.youtube.com/watch?v=vi-2nasppAg&t=2290s) Are you getting, getting close?

[38:11](https://www.youtube.com/watch?v=vi-2nasppAg&t=2291s) I'm just gonna walk through the code as we would have written it from scratch. Sorry about that. Um,

[38:17](https://www.youtube.com/watch?v=vi-2nasppAg&t=2297s) because I think it, it sort of like illustrates the, the progression of things, and maybe if you-

[38:22](https://www.youtube.com/watch?v=vi-2nasppAg&t=2302s) Uh, it's installing dependencies, which is, is slow. Uh, so-

[38:25](https://www.youtube.com/watch?v=vi-2nasppAg&t=2305s) Yeah, but, but it's like-

[38:26](https://www.youtube.com/watch?v=vi-2nasppAg&t=2306s) ... the walkthrough-

[38:27](https://www.youtube.com/watch?v=vi-2nasppAg&t=2307s) Exactly. Eventually, eventually this will work

[38:28](https://www.youtube.com/watch?v=vi-2nasppAg&t=2308s) ... it might all be runnable by the end of the walkthrough.

[38:30](https://www.youtube.com/watch?v=vi-2nasppAg&t=2310s) Exactly. So, um, in this, in this paradigm, uh, as, as, as we, uh, we've been using it in our agent, when you want to implement some sort of feature, what you do is you say, "Okay, what is the state I actually need in, in order to do my, my, my thing?"

[38:45](https://www.youtube.com/watch?v=vi-2nasppAg&t=2325s) In this case, we want to do an LLM request whenever somebody sends a message and says hi. So, um, we have here in our, um, in our user interface, and you can access this as well, there is basically like a cheat code that makes it a bit easier to, um, to create, uh, new events of a type

[39:01](https://www.youtube.com/watch?v=vi-2nasppAg&t=2341s) called agent input added. And this is like deliberately the simplest possible thing you can imagine. This is basically just a string. And so what we're trying to achieve is that whenever somebody puts an agent input added event into an event stream, we want to, uh, react to that by making an LLM request.

[39:18](https://www.youtube.com/watch?v=vi-2nasppAg&t=2358s) And for simplicity, we're just gonna go in and do it using the OpenAI SDK. So, uh, the OpenAI SDK, um, the way it works is, um, you have to,

[39:27](https://www.youtube.com/watch?v=vi-2nasppAg&t=2367s) uh, at some point, uh, before you want to use it, you have to make yourself, um,

[39:33](https://www.youtube.com/watch?v=vi-2nasppAg&t=2373s) here a new OpenAI client, and then you can use, uh, their Responses API. So you have openai.responses, uh, responses.create. And then, uh, in order to create it, um, you need some information.

[39:49](https://www.youtube.com/watch?v=vi-2nasppAg&t=2389s) Uh, specifically you need a model sta- uh, a string. And so immediately there it's saying, okay, so let's just say our state for our LLM agent, it has a model string because that is one of the things that we will need when we, when we come to actually make an LLM request and there is nothing but e-event

[40:03](https://www.youtube.com/watch?v=vi-2nasppAg&t=2403s) sourcing. So let's just say, okay, we have, um, we have a model string and, uh, that comes from, from, um, from our state. Uh, and then, you know, you could easily imagine, uh, in the future, this was one of the things that, uh, you could have done as an exercise, uh, in, in, in the hackathon is you,

[40:17](https://www.youtube.com/watch?v=vi-2nasppAg&t=2417s) you could say, let's add an event that is like LLM changed, LLM model changed, and you have the teeny tiny one-line reducer, and it just sets the model to be a different model, and then, um, off you go, you make the next LLM request, um, with a different model.

[40:30](https://www.youtube.com/watch?v=vi-2nasppAg&t=2430s) And the other thing we need is instructions. Uh, this is, I think, a bit of a misnomer. So, uh, I would call it system prompt in our state, and we say, okay, the ins- like, the system prompt for our LLM, what it's meant to be doing, we'll take that in our state, and then you need a history,

[40:43](https://www.youtube.com/watch?v=vi-2nasppAg&t=2443s) um, a state history. And, um, and, and so we've defined this, uh, and normally what you'll do is, uh, you'll just put this into, into, uh, like a little, um, into like a little, uh, TypeScript type if you're using TypeScript.

[40:56](https://www.youtube.com/watch?v=vi-2nasppAg&t=2456s) So here we're saying this is the state of our agent, right? And, and in the beginning it's really simple, but in the future, uh, you can very easily imagine how, how you quickly add things to it like state, am I currently compacting, or is a tool call currently in progress or, or whatever else, um, you might have.

[41:12](https://www.youtube.com/watch?v=vi-2nasppAg&t=2472s) Um, and, uh, the idea is to create a system in which it is trivially easy with three, four lines of code to add one of those capabilities, uh, to it.

[41:20](https://www.youtube.com/watch?v=vi-2nasppAg&t=2480s) And then you say, okay, what's my initial state? Um, because we're processing the stream initially, there's no events, so we need to know what we're, what we're initially starting with.

[41:27](https://www.youtube.com/watch?v=vi-2nasppAg&t=2487s) And so we're just saying, uh, this is-- we're starting with an empty history and this system prompt and GPT-5.4.

[41:34](https://www.youtube.com/watch?v=vi-2nasppAg&t=2494s) Um, and then the next thing you do once you've, um, uh, once you've done that, is you need to decide what events do I need to derive this, um, to derive this state?

[41:45](https://www.youtube.com/watch?v=vi-2nasppAg&t=2505s) Uh, and in this case, we will just,

[41:49](https://www.youtube.com/watch?v=vi-2nasppAg&t=2509s) um, uh, create a new event here, uh, a new... We're using Zod here for schemas. We're saying it's an agent input added event, and it just has a string.

[41:57](https://www.youtube.com/watch?v=vi-2nasppAg&t=2517s) Um, and then whenever anything comes back from OpenAI, because that is like a fact that has occurred, even if it's just a teeny tiny fragment of a string or, or something else, we store that in, um, in an event, um, and that's it.

[42:11](https://www.youtube.com/watch?v=vi-2nasppAg&t=2531s) Uh, th- these are, these are the two, the two main event, um, event types. Um, I don't think we need any of this stuff here actually.

[42:21](https://www.youtube.com/watch?v=vi-2nasppAg&t=2541s) Basically, what happened, as is often the case, I, uh, I attempted to instruct an agent to rewrite all of these examples to, uh, be simpler to execute just before, and it just, um, rewrote them quite significantly.

[42:35](https://www.youtube.com/watch?v=vi-2nasppAg&t=2555s) But this is really all you need. So, um- And then, uh, you have to write your reducer first, and the reducer is basically where you just say, "Okay, when an event is encountered, uh, how do I update my, um, how do I update my, uh, state?"

[42:47](https://www.youtube.com/watch?v=vi-2nasppAg&t=2567s) And you say, "Okay, when an agent input added event, um, is, uh, encountered..." This here is using, uh, a little, like, Zod helper library, actually one that Misha made, called Scheme Match.

[42:56](https://www.youtube.com/watch?v=vi-2nasppAg&t=2576s) Uh, it's just, uh, it, it just gives you basically type safety on this payload here. When I have an agent input added event, then I want my state to be updated as the current state plus the history, except the history also gets, uh, this little, uh, this little thing here, uh, here appended.

[43:13](https://www.youtube.com/watch?v=vi-2nasppAg&t=2593s) So we're... And, and, and, um, the, the reason we're doing that is because, uh, OpenAI's Responses API, um, since we're making OpenAI processor, we're basically translating between our view of the world.

[43:25](https://www.youtube.com/watch?v=vi-2nasppAg&t=2605s) We just have this, like, agent input and, um, uh, it's just a string. Uh, but OpenAI wants you to put role user and, and then put the string in a content field, so we're putting that there.

[43:34](https://www.youtube.com/watch?v=vi-2nasppAg&t=2614s) Um, and, um, then the other thing we need to do, um, when you use the OpenAI str- uh, streaming API, uh, it'll, it'll, like, basically chuck out tons and tons of these, uh, output, uh, response, um, events.

[43:50](https://www.youtube.com/watch?v=vi-2nasppAg&t=2630s) And, uh, one of them finally at the very end will be, um, of type, um,

[43:58](https://www.youtube.com/watch?v=vi-2nasppAg&t=2638s) uh, ba, ba, ba, ba, ba. Um, um.

[44:06](https://www.youtube.com/watch?v=vi-2nasppAg&t=2646s) Yeah. I, I think this is a bit hogwash. Um-

[44:07](https://www.youtube.com/watch?v=vi-2nasppAg&t=2647s) It's like an end event at the end, no?

[44:09](https://www.youtube.com/watch?v=vi-2nasppAg&t=2649s) Huh?

[44:09](https://www.youtube.com/watch?v=vi-2nasppAg&t=2649s) When it's done with the-

[44:10](https://www.youtube.com/watch?v=vi-2nasppAg&t=2650s) Yeah, yeah. Exactly.

[44:11](https://www.youtube.com/watch?v=vi-2nasppAg&t=2651s) Yeah.

[44:11](https://www.youtube.com/watch?v=vi-2nasppAg&t=2651s) It, it basically, uh... What we really want here is,

[44:16](https://www.youtube.com/watch?v=vi-2nasppAg&t=2656s) um, uh... Um, yeah.

[44:27](https://www.youtube.com/watch?v=vi-2nasppAg&t=2667s) You're low on battery, so.

[44:29](https://www.youtube.com/watch?v=vi-2nasppAg&t=2669s) Oh, thank you. Um, is that actually right?

[44:36](https://www.youtube.com/watch?v=vi-2nasppAg&t=2676s) Um, no. Um, let's just... I don't suppose you have managed to get the-

[44:51](https://www.youtube.com/watch?v=vi-2nasppAg&t=2691s) I have pushed workshop two to the-

[44:54](https://www.youtube.com/watch?v=vi-2nasppAg&t=2694s) Yeah, but it just doesn't-

[44:54](https://www.youtube.com/watch?v=vi-2nasppAg&t=2694s) ... the demo repo, but it's more or less as is.

[44:57](https://www.youtube.com/watch?v=vi-2nasppAg&t=2697s) I've got a question. Is this gonna be streamed in? Like, so if-

[45:01](https://www.youtube.com/watch?v=vi-2nasppAg&t=2701s) Yes

[45:01](https://www.youtube.com/watch?v=vi-2nasppAg&t=2701s) ... pushing the stream doesn't-

[45:02](https://www.youtube.com/watch?v=vi-2nasppAg&t=2702s) Yeah. Let, okay. So let's, let's just like, uh, sort of like admit defeat on the thing that I was gonna do, and just like try, try and show you how, how, how it work.

[45:09](https://www.youtube.com/watch?v=vi-2nasppAg&t=2709s) Because we, we can get something like very simple working, right? Because we have the extremely simple ping pong processor that, that does work. Uh, and so here we can, uh, we can even, uh, just...

[45:21](https://www.youtube.com/watch?v=vi-2nasppAg&t=2721s) Hmm. Um, let's maybe actually start here.

[45:32](https://www.youtube.com/watch?v=vi-2nasppAg&t=2732s) Oh, man, I hit, I hit insufficient quota [laughs] running my, uh...

[45:41](https://www.youtube.com/watch?v=vi-2nasppAg&t=2741s) Hmm.

[45:43](https://www.youtube.com/watch?v=vi-2nasppAg&t=2743s) Joop, joop, joop.

[45:47](https://www.youtube.com/watch?v=vi-2nasppAg&t=2747s) Yeah. We, we do now have the same examples on the other repo, but it'll, it'll-

[45:51](https://www.youtube.com/watch?v=vi-2nasppAg&t=2751s) Yeah. Ugh. To be honest, I think-

[45:55](https://www.youtube.com/watch?v=vi-2nasppAg&t=2755s) ... take the same

[45:55](https://www.youtube.com/watch?v=vi-2nasppAg&t=2755s) ... uh, I think we might have to just admit defeat, and we can just talk about something else or give you, give you the time back. Just because the problem is we can't actually run these things. [laughs]

[46:03](https://www.youtube.com/watch?v=vi-2nasppAg&t=2763s) Uh, and I think it will take me like probably like 10 minutes of actually concentrating to, to get them runnable. Um, so maybe we should, uh, admit defeat on that.

[46:14](https://www.youtube.com/watch?v=vi-2nasppAg&t=2774s) Um, I do wonder if there's like... Does A- Does...

[46:20](https://www.youtube.com/watch?v=vi-2nasppAg&t=2780s) Yeah. Do- Does it, does it sort of make sense what the, what the idea is, especially with, with it being distributed? So the... Right? That you can say, "Okay, like I have my processor over here," and your agent can use it, and it can be on a different, uh, server, or it can actually be in a, in

[46:36](https://www.youtube.com/watch?v=vi-2nasppAg&t=2796s) a dynamic worker. Um, and, um, yeah. I, I think without showing it, it doesn't really make sense.

[46:50](https://www.youtube.com/watch?v=vi-2nasppAg&t=2810s) So is, is the idea you'd, um... So with the stream processing, so you take this event stream from-

[46:55](https://www.youtube.com/watch?v=vi-2nasppAg&t=2815s) Yeah

[46:55](https://www.youtube.com/watch?v=vi-2nasppAg&t=2815s) ... OpenAI, and-

[46:56](https://www.youtube.com/watch?v=vi-2nasppAg&t=2816s) Mm-hmm

[46:56](https://www.youtube.com/watch?v=vi-2nasppAg&t=2816s) ... it contains events like output item added, or I, I know the Anthropic model better than anyone, but you've got-

[47:02](https://www.youtube.com/watch?v=vi-2nasppAg&t=2822s) It's very similar

[47:03](https://www.youtube.com/watch?v=vi-2nasppAg&t=2823s) ... item, and then you've got some series of like text deltas, say.

[47:06](https://www.youtube.com/watch?v=vi-2nasppAg&t=2826s) Yeah.

[47:06](https://www.youtube.com/watch?v=vi-2nasppAg&t=2826s) And so the reducer here is kind of squashing all of those events-

[47:09](https://www.youtube.com/watch?v=vi-2nasppAg&t=2829s) Yeah

[47:09](https://www.youtube.com/watch?v=vi-2nasppAg&t=2829s) ... and then materializing that sort of partial response-

[47:12](https://www.youtube.com/watch?v=vi-2nasppAg&t=2832s) Yeah

[47:13](https://www.youtube.com/watch?v=vi-2nasppAg&t=2833s) ... into an event, right. So then the bit I was trying to understand was sort of with this stream processor-

[47:18](https://www.youtube.com/watch?v=vi-2nasppAg&t=2838s) Yeah

[47:18](https://www.youtube.com/watch?v=vi-2nasppAg&t=2838s) ... sort of framework that you've built is like these materialized events, is, are those events persisted as new messages on the stream?

[47:26](https://www.youtube.com/watch?v=vi-2nasppAg&t=2846s) Um-

[47:26](https://www.youtube.com/watch?v=vi-2nasppAg&t=2846s) Are they being declined to consume the raw events, and sort of you're doing the materialization client side? Or is it sort of a part of something that's happening in the stream?

[47:34](https://www.youtube.com/watch?v=vi-2nasppAg&t=2854s) So every... Yeah. So, so everything that happens in the system, every streaming chunk, everything becomes a, becomes an event in the stream.

[47:42](https://www.youtube.com/watch?v=vi-2nasppAg&t=2862s) Right.

[47:42](https://www.youtube.com/watch?v=vi-2nasppAg&t=2862s) And then you have reducers running in many different places. Like, uh, for, for instance, uh, you know, even this thing with like is the stream paused or is the stream not paused, the actual implementation of that is, um...

[47:53](https://www.youtube.com/watch?v=vi-2nasppAg&t=2873s) Maybe that, maybe that's actually useful, because this is running in production now. Uh, like, right? Like there is a, a circuit breaker processor, and, and this is like how the whole thing is built, even inside the event service, and the circuit breaker processor has an initial state of paused false, and it has pause reason null.

[48:07](https://www.youtube.com/watch?v=vi-2nasppAg&t=2887s) And basically, uh, then it has a really, really simple reducer, um, uh, that just checks what are the last 100 timestamps of events I've seen. If the last 100 timestamps I've seen, uh, seen don't go, uh, you know, don't go more than a second back, then I'm just gonna append a, uh, a- append an event.

[48:22](https://www.youtube.com/watch?v=vi-2nasppAg&t=2902s) So the reducer basically just accumulates these timestamps, and then the after append function, uh, here says, "Okay, if I, if I have seen too many timestamps in the last second, uh, I'm gonna, uh, I'm gonna throw the circuit breaker."

[48:33](https://www.youtube.com/watch?v=vi-2nasppAg&t=2913s) So this is like a real processor that runs inside my, uh, my, um, my, uh, service. But let me show you another one. Uh, this one here, this UI, this is also a stream processor.

[48:43](https://www.youtube.com/watch?v=vi-2nasppAg&t=2923s) What does this UI do? The UI takes all of these events, and for some of the events that it deems like interesting, it chucks- Uh, it, it basically, it, it basically projects them onto what we call feed items.

[48:53](https://www.youtube.com/watch?v=vi-2nasppAg&t=2933s) So these things here that have like an, a slightly ni- nicer rendering, they are feed items, and they are not the same as events, but they're derived from events.

[49:01](https://www.youtube.com/watch?v=vi-2nasppAg&t=2941s) So, uh, when you're making UI for this thing, you're also just reducing. Um, and because the reducer is just a synchronous function, right? If, if, if you knew, for example, I have, I have this like, uh, a Pi agent harness pr- uh, uh, processor, and it comes with a whole bunch of event, uh, event types, um, and

[49:18](https://www.youtube.com/watch?v=vi-2nasppAg&t=2958s) it has a reducer. Um, you can just in your processor use their reducer. It's practically free, right? Like, uh, you can just import it and, and run it. Uh, and then you can just sort of like start building abstractions that rely on their event types.

[49:30](https://www.youtube.com/watch?v=vi-2nasppAg&t=2970s) Um, and so, um, I think what I'll, what I'll, what I, what I will commit to doing, because this was such a shitty experience, is I will just do, do the whole rundown in video form, uh, on the, on the internet, and that was one of the things I was gonna show.

[49:44](https://www.youtube.com/watch?v=vi-2nasppAg&t=2984s) Like, you can just hook up Pi or Claude or, or OpenCode as well, and, um, just s- say, okay, like, all... They come with a bunch of events, and you can store them in this event stream, and you can react to them or, or build on them.

[49:58](https://www.youtube.com/watch?v=vi-2nasppAg&t=2998s) Um, d- does that answer the question, like, where the reducer runs? Um, um, and, and then, like, one of the things you can do with this is you can also actually just append an event that has some source code in it, and then it runs that particular processor literally automatically for you, horizontally scalable.

[50:16](https://www.youtube.com/watch?v=vi-2nasppAg&t=3016s) Um, it's just, uh, yeah.

[50:19](https://www.youtube.com/watch?v=vi-2nasppAg&t=3019s) Do you have the example of showing how you do that, where you're appending like a, a function-

[50:24](https://www.youtube.com/watch?v=vi-2nasppAg&t=3024s) Yeah, I do have that. I do have that

[50:25](https://www.youtube.com/watch?v=vi-2nasppAg&t=3025s) ... even if it's not runnable, I think the, the-

[50:27](https://www.youtube.com/watch?v=vi-2nasppAg&t=3027s) I do have that

[50:27](https://www.youtube.com/watch?v=vi-2nasppAg&t=3027s) ... idea is somewhat-

[50:28](https://www.youtube.com/watch?v=vi-2nasppAg&t=3028s) Yeah. Well, actually, we can do it here. Uh, yeah, I, I think, I think maybe, maybe that is good. Just like focus... Instead of trying to write code, we can, uh, focus on the things that might work.

[50:35](https://www.youtube.com/watch?v=vi-2nasppAg&t=3035s) Um, so let's... We can create a new stream. By the way, all streams are created, uh, you know, uh, completely implicitly, so you can just, uh, uh, post to anything under the stream's API, and it'll, it'll make you a new stream.

[50:47](https://www.youtube.com/watch?v=vi-2nasppAg&t=3047s) And then, uh, here there's in the UI, and you can also play with this if you want to just see, um, there is a, there's a bunch of sort of preset, um, preset events, uh, and one of them is here.

[50:57](https://www.youtube.com/watch?v=vi-2nasppAg&t=3057s) You can append an event of type dynamic worker configured to this thing, and, uh, what does it have? It just has a script in it, and the script is a string, and inside the string is a reducer, uh, and an after append hook.

[51:10](https://www.youtube.com/watch?v=vi-2nasppAg&t=3070s) And so this is, um, literally a, uh, like, um, a stream, a stream processor. It would be funny if this, uh, if this is the thing that works, because th- [laughs] this is what...

[51:19](https://www.youtube.com/watch?v=vi-2nasppAg&t=3079s) I was basically, I was basically, uh, up most of the night working on this because this is the most exciting bit, but it wasn't really like workshop grade because it was...

[51:28](https://www.youtube.com/watch?v=vi-2nasppAg&t=3088s) You know, you get to, get like the first five concepts, and then you're like, "By the way, you can deploy this by just adding an event." Um, uh, but if I, if I just say ping here,

[51:37](https://www.youtube.com/watch?v=vi-2nasppAg&t=3097s) it says pong, right? That's pretty crazy. Like, I have here a stream, uh, that knows nothing about the world, and then I have appended this event here that just has a little bit of JavaScript in it, and this little bit of JavaScript, uh, just makes it respond with pong whenever it encounters something with ping.

[51:55](https://www.youtube.com/watch?v=vi-2nasppAg&t=3115s) And then there is actually a, a version of this. This is the thing that actually took, took the night [laughs] away, so to speak, is if you have these processor files that export a processor that you define with define processor, you can bundle that into an event effectively.

[52:08](https://www.youtube.com/watch?v=vi-2nasppAg&t=3128s) And this AI agent I also got running like that. But of course, you don't want to have your OpenAI API key in there, so that is why we have this like slightly awkward env vars here, where you can put your OpenAI API key outside of the stream, and then, um, it will basically, when it makes a fetch

[52:27](https://www.youtube.com/watch?v=vi-2nasppAg&t=3147s) request, it'll substitute the secret in, in the header. But, um,

[52:32](https://www.youtube.com/watch?v=vi-2nasppAg&t=3152s) yeah, I'll definitely, I'll definitely post a video of that because that's, that's pretty wild. Like, you, you can write like the 40 lines of code required for a basic AI agent, and then you can append that to any stream, and then that stream becomes an AI agent.

[52:46](https://www.youtube.com/watch?v=vi-2nasppAg&t=3166s) I don't know. [laughs] I'm sort of n- looking at like two or three nods, but mostly blank, blank stares. It is very strange. Um, but, uh, but, but I th- does this, does this make sense what happened here at least?

[52:56](https://www.youtube.com/watch?v=vi-2nasppAg&t=3176s) Because you can... Y- this one you can just play with. Like, you can just go in the UI. And so, uh, to some extent, uh, actually, you can, uh, you can make increasingly more complicated processors [laughs] for your streams.

[53:08](https://www.youtube.com/watch?v=vi-2nasppAg&t=3188s) Uh, you can just, you can just code them in this input field if you want. Or, uh, you know, um, the only problem is it cannot have any dependencies.

[53:16](https://www.youtube.com/watch?v=vi-2nasppAg&t=3196s) Like, if you want some npm packages, you have to bundle it into the string, which gets a bit more complicated. But, um, yeah.

[53:24](https://www.youtube.com/watch?v=vi-2nasppAg&t=3204s) And can you override?

[53:26](https://www.youtube.com/watch?v=vi-2nasppAg&t=3206s) Yeah, so this is the other thing. Like, everything, uh, you, you might have noticed is everything has a slug, and it's just like a URL safe identifier. And so the, the event here is actually called dynamic worker configured because you can override it.

[53:37](https://www.youtube.com/watch?v=vi-2nasppAg&t=3217s) And, and what also already works with this event type is you can give instructions to an AI agent to make itself

[53:46](https://www.youtube.com/watch?v=vi-2nasppAg&t=3226s) different functionality just by calling append, um, with like a little bit of a different JavaScript.

[53:53](https://www.youtube.com/watch?v=vi-2nasppAg&t=3233s) Um, and, uh, you know, you, you could, you can quite easily imagine overcoming the bundling problem, for example, by just saying, "Oh, there's another event type," which is called like a sort of like, uh, unbundled, uh, dynamic worker, which just has a package.json file, uh, uh, field and a script field.

[54:07](https://www.youtube.com/watch?v=vi-2nasppAg&t=3247s) And then a different processor takes it, bundles it, makes the fat event that has all of the bundled source code, and suddenly, uh, is, is basically like a, like a IDE.

[54:17](https://www.youtube.com/watch?v=vi-2nasppAg&t=3257s) A- a- and that's then where you can, you can hack on the agent harness

[54:22](https://www.youtube.com/watch?v=vi-2nasppAg&t=3262s) without having to really like install anything or like bring servers into the mix or, or whatever. Um, but sadly was not able to show it, so bummer.

[54:31](https://www.youtube.com/watch?v=vi-2nasppAg&t=3271s) Um, what is, what if there is a error in the JavaScript code you put in the stream?

[54:37](https://www.youtube.com/watch?v=vi-2nasppAg&t=3277s) Hmm?

[54:38](https://www.youtube.com/watch?v=vi-2nasppAg&t=3278s) So if you pushed a Java-

[54:39](https://www.youtube.com/watch?v=vi-2nasppAg&t=3279s) Yeah

[54:40](https://www.youtube.com/watch?v=vi-2nasppAg&t=3280s) ... JavaScript code in a stream, and if there is a error in that code or if you made a-

[54:46](https://www.youtube.com/watch?v=vi-2nasppAg&t=3286s) Uh-

[54:47](https://www.youtube.com/watch?v=vi-2nasppAg&t=3287s) ... made a typing error, what happens then?

[54:49](https://www.youtube.com/watch?v=vi-2nasppAg&t=3289s) Uh, well, th- this is, uh, this is, uh, JavaScript. There wouldn't be a typing, a typing error. Um, uh, but it, uh, if there's any kind of error, the only thing that can possibly happen is that you get an event.

[55:00](https://www.youtube.com/watch?v=vi-2nasppAg&t=3300s) Yeah.

[55:00](https://www.youtube.com/watch?v=vi-2nasppAg&t=3300s) So there would have to be an error event. Um- And there's no, there are no typing errors as implemented right now, but you-- that's because-

[55:06](https://www.youtube.com/watch?v=vi-2nasppAg&t=3306s) Yeah

[55:06](https://www.youtube.com/watch?v=vi-2nasppAg&t=3306s) ... this is a JavaScript evaluator. But you could also find a way to run a TypeScript compilation step on it first, and then you could emit error saying there was a TypeScript compiler error.

[55:17](https://www.youtube.com/watch?v=vi-2nasppAg&t=3317s) Then you could run it through an LLM to try and fix it and emit a new event with the fixed code or do something else with it.

[55:22](https://www.youtube.com/watch?v=vi-2nasppAg&t=3322s) Yeah. Um-

[55:24](https://www.youtube.com/watch?v=vi-2nasppAg&t=3324s) The idea is that just everything that happens results in an event, and then you can react to those events however you, you see fit.

[55:33](https://www.youtube.com/watch?v=vi-2nasppAg&t=3333s) And-

[55:34](https://www.youtube.com/watch?v=vi-2nasppAg&t=3334s) These, the event, they are then, um, evaluated and run in your backend, right?

[55:39](https://www.youtube.com/watch?v=vi-2nasppAg&t=3339s) Yes. So in this particular case, it's, it's dynamic workers in Cloudflare. So it, it just spins up a, a small, small dynamic worker. Um, so basically, like the deployment story for a processor like this is or, or like one way to think about it is, uh, at wh- wh- when this was still working before I, uh, ask

[55:55](https://www.youtube.com/watch?v=vi-2nasppAg&t=3355s) it to be refactored and broken, I had, um... The way I would do it is I would locally on my computer, I would do the SSE subscription and, and run my processor that way.

[56:04](https://www.youtube.com/watch?v=vi-2nasppAg&t=3364s) And then once I thought it was cool, uh, I could either deploy it just as a web service on, on Cloudflare Workers or Vercel or, or wherever, uh, and, and just tell, uh, tell the, um, agents, uh, uh, the, uh, tell the streams to notify me whenever a new event needs to be processed, or, uh, alternatively, just

[56:21](https://www.youtube.com/watch?v=vi-2nasppAg&t=3381s) use this dynamic worker thing. Um, and like there's, uh, I don't know if this is gonna work. This is why, like, at the moment, it's looking more like it's a really dumb idea, I think, because it's really not coming across.

[56:30](https://www.youtube.com/watch?v=vi-2nasppAg&t=3390s) But the-- For example, you could have a plugin for your agent, uh, that runs on another computer, especially if it was like something like really important like a prompt injection protection or something like that.

[56:40](https://www.youtube.com/watch?v=vi-2nasppAg&t=3400s) Like you could say, "Oh, okay, the way that my agent uses your prompt injection protection service," it can't really be through MCP because there's no way to, to kind of like proactively hook into the agent loop or, or, uh, um, at least not at the minute.

[56:53](https://www.youtube.com/watch?v=vi-2nasppAg&t=3413s) But what it could be is it could say, "Okay, my, my agent loop actually waits for up to like two hundred milliseconds before making any new LLM request, uh, for any safety checkers to say this."

[57:02](https://www.youtube.com/watch?v=vi-2nasppAg&t=3422s) And then it can just literally ask your safety checker over there. I don't care how you implement it. You could even charge me for it, right? Um, and, uh, I just don't, yeah, I just don't think that's, uh, currently possible in, in any other way.

[57:15](https://www.youtube.com/watch?v=vi-2nasppAg&t=3435s) That's why I, I think it's quite important that the stream can reach out to the processors and say, "You gotta do something," you know? "You need to process some events now."

[57:24](https://www.youtube.com/watch?v=vi-2nasppAg&t=3444s) Um, um, there's a, there's like a couple other, uh, potentially... Hmm, I don't, uh, I mean, this might, yeah.

[57:31](https://www.youtube.com/watch?v=vi-2nasppAg&t=3451s) Just-

[57:32](https://www.youtube.com/watch?v=vi-2nasppAg&t=3452s) Yeah.

[57:32](https://www.youtube.com/watch?v=vi-2nasppAg&t=3452s) With the idea, one of the ideas you shared is, uh, my agent might use, like, just-in-time, uh, services of other agent, uh, offering.

[57:40](https://www.youtube.com/watch?v=vi-2nasppAg&t=3460s) Yeah.

[57:41](https://www.youtube.com/watch?v=vi-2nasppAg&t=3461s) And he might be charged for it.

[57:43](https://www.youtube.com/watch?v=vi-2nasppAg&t=3463s) Yeah.

[57:44](https://www.youtube.com/watch?v=vi-2nasppAg&t=3464s) Okay.

[57:44](https://www.youtube.com/watch?v=vi-2nasppAg&t=3464s) Well, I mean, like, probably in- initially, the human would be charged of it. But, but this is just like the, there is no way... Like let's say, okay, so Claude Code.

[57:51](https://www.youtube.com/watch?v=vi-2nasppAg&t=3471s) If I want to make a Claude Code plugin, um, if, if I wanted to make that into a business, think, think about how you would have to do that at the moment.

[58:00](https://www.youtube.com/watch?v=vi-2nasppAg&t=3480s) It-- And you need to give some sort of instructions, uh, or, or, or something to, to, uh, to Claude Code, either to proactively call your MCP tools or, or something of that nature, or call maybe some CLI tool that was previously authenticated, where you did like CLI login to, you know, like promptinjectionprotector.com, and then, uh, somehow it

[58:18](https://www.youtube.com/watch?v=vi-2nasppAg&t=3498s) works. Where, whereas, um, uh, really, I think you can just plug into the, into the agent stream, like into the event stream directly. Like the, the interface is just somebody, somebody notices that Claude is about to do something and chuck some more events in.

[58:32](https://www.youtube.com/watch?v=vi-2nasppAg&t=3512s) And, and like they kind of all work that way, but not quite. Like it's, uh, it's sort of like you, you have to squint a lot to, to see that that's what it all compiles down to.

[58:43](https://www.youtube.com/watch?v=vi-2nasppAg&t=3523s) Um, um, another thing maybe worth pointing out if, for, for some of you that have tried to, uh, like tried to make OpenCode or, or, or Pi plugins or whatever is, there's no before hook.

[58:53](https://www.youtube.com/watch?v=vi-2nasppAg&t=3533s) This is very, very important. There's no like, um... There is actually in the back end, like our built-in processors, the only difference to our processors and your processors is that we can actually stop events from ever being appended.

[59:03](https://www.youtube.com/watch?v=vi-2nasppAg&t=3543s) For exam-- That is why the pause feature could not be implemented by a third party. So there's sort of like certain things that are just, um, that, that need to happen before an event goes in the stream.

[59:13](https://www.youtube.com/watch?v=vi-2nasppAg&t=3553s) But, um, broadly speaking, I'm very against before hooks. Like I, I think there were some instances in, in OpenClaw, for example, some massive performance regressions and, and cost increases where, you know, you can, you can break, uh, um, you can break context caching quite easily with before hooks.

[59:27](https://www.youtube.com/watch?v=vi-2nasppAg&t=3567s) You can massively destroy performance. Like it's just way better to think of the whole system as, as being eventually consistent. And, uh, you know, um, doing all these distributed systems things like saying, "Okay, we're gonna wait for up to two hundred milliseconds for somebody to say, 'I've got a little bit of information for you.'

[59:42](https://www.youtube.com/watch?v=vi-2nasppAg&t=3582s) But then we're actually gonna make the LLM request, whether you come in with information or not," because this is needs to be a resilient system. So if you think, for example, about RAG pipelines and, and things like that, you can easily have a little processor that says, "I have like a indexed version of the Notion knowledge base

[59:57](https://www.youtube.com/watch?v=vi-2nasppAg&t=3597s) or something, and I'm just gonna sit here and try to squeeze in a little bit of extra context if I think it's relevant. But if I don't get there in time, it's like totally chill.

[1:00:06](https://www.youtube.com/watch?v=vi-2nasppAg&t=3606s) The, the whole thing still works. It's not like I've, I've kind of delayed the, um, the agent or something."

[1:00:12](https://www.youtube.com/watch?v=vi-2nasppAg&t=3612s) Um, yeah.

[1:00:16](https://www.youtube.com/watch?v=vi-2nasppAg&t=3616s) What about, um, so you're hosting this, this instance of iterate. Like how would you imagine in the future, would everyone host their own one or is it centralized?

[1:00:24](https://www.youtube.com/watch?v=vi-2nasppAg&t=3624s) You mean-- I mean, the, the, the, the streaming database, like, I don't know. I, I, I think, um, I think this could work on almost anything that is like durable stream shape.

[1:00:33](https://www.youtube.com/watch?v=vi-2nasppAg&t=3633s) So this was just for the purposes of this, um, exercise. Uh, I do think like there is potentially an interesting scenario where, uh, like, where a, like it's, it's not even really like...

[1:00:45](https://www.youtube.com/watch?v=vi-2nasppAg&t=3645s) It, it's a combination of a queue and a pub/sub system and a, and like a streaming database and, uh, uh, that can also run code for you. But, but that, that sort of thing is an interesting infrastructure primitive that, uh, maybe somebody could make.

[1:00:57](https://www.youtube.com/watch?v=vi-2nasppAg&t=3657s) Um, I do think that, uh, yeah. But in, in principle, like I, I don't know if you don't know about it yet, you can read up on this, uh, Durable Streams, uh, API specification that somebody came out with.

[1:01:07](https://www.youtube.com/watch?v=vi-2nasppAg&t=3667s) We don't follow it exactly, but ... uh, close enough, and it's, it's basically

[1:01:13](https://www.youtube.com/watch?v=vi-2nasppAg&t=3673s) like a, like a very common old idea. Like, um, the, the thing that is more new is that it would be, like, you would also have push subscriptions out of it.

[1:01:23](https://www.youtube.com/watch?v=vi-2nasppAg&t=3683s) But there are some things that do is there's a thing called NA- uh, like JetStream NATS or something, uh, that, that does it. Um, yeah.

[1:01:32](https://www.youtube.com/watch?v=vi-2nasppAg&t=3692s) Are you talking about, uh, like the ElectricSQL?

[1:01:35](https://www.youtube.com/watch?v=vi-2nasppAg&t=3695s) Yeah, exactly. They, they have Durable Streams, yeah. And, uh, like a d- a durable stream is just like an um, append-only event log with, with offset tracking. And, and the, the, the, you know, they want the client to track the last consumed offset.

[1:01:46](https://www.youtube.com/watch?v=vi-2nasppAg&t=3706s) That's also how, say, Kafka works or something like that. Uh, uh, but you can also do it the other way around and have the server track the offsets, and those are more nor- more normally like this.

[1:01:55](https://www.youtube.com/watch?v=vi-2nasppAg&t=3715s) Google Cloud and AWS, they have these pub/sub systems where they say, "Oh, we'll just like give you the next event and we'll keep track of, of the offset for you."

[1:02:04](https://www.youtube.com/watch?v=vi-2nasppAg&t=3724s) Um.

[1:02:06](https://www.youtube.com/watch?v=vi-2nasppAg&t=3726s) I've got another question.

[1:02:07](https://www.youtube.com/watch?v=vi-2nasppAg&t=3727s) Yeah.

[1:02:07](https://www.youtube.com/watch?v=vi-2nasppAg&t=3727s) Uh, say I, say I've got a, I- I've, I've got Michael Bell here or Michael-

[1:02:11](https://www.youtube.com/watch?v=vi-2nasppAg&t=3731s) Yeah

[1:02:11](https://www.youtube.com/watch?v=vi-2nasppAg&t=3731s) ... and I have a sub path called images, and I-

[1:02:13](https://www.youtube.com/watch?v=vi-2nasppAg&t=3733s) Yeah

[1:02:13](https://www.youtube.com/watch?v=vi-2nasppAg&t=3733s) ... hook it up to like a local LLM which is generating images, and then anyone could essentially pass a stream to that which would then go to my LLM, generate-

[1:02:21](https://www.youtube.com/watch?v=vi-2nasppAg&t=3741s) Yeah

[1:02:21](https://www.youtube.com/watch?v=vi-2nasppAg&t=3741s) ... an image, and return it back.

[1:02:22](https://www.youtube.com/watch?v=vi-2nasppAg&t=3742s) Yeah.

[1:02:23](https://www.youtube.com/watch?v=vi-2nasppAg&t=3743s) How, how would I, like, prevent a certain amount of like basically flooding the system?

[1:02:27](https://www.youtube.com/watch?v=vi-2nasppAg&t=3747s) Oh, I mean, you would need to have authentication on it. Right, right [laughs] like this, this entire thing would never, uh, like, uh, right, like this, uh ... I was thinking like it might be fun to just say there's a, there's like-

[1:02:37](https://www.youtube.com/watch?v=vi-2nasppAg&t=3757s) Don't do that yet, basically. [laughs]

[1:02:38](https://www.youtube.com/watch?v=vi-2nasppAg&t=3758s) Yeah, exactly. Th- it might be fun to just say there's a public namespace, and it just gets cleared every hour or something-

[1:02:43](https://www.youtube.com/watch?v=vi-2nasppAg&t=3763s) Yeah

[1:02:43](https://www.youtube.com/watch?v=vi-2nasppAg&t=3763s) ... right? Uh, because it is kind of nice that anybody anywhere on the internet can just cURL a thing, uh, or like copy and paste a cURL from somewhere and, and suddenly you have like a flavor of agent.

[1:02:52](https://www.youtube.com/watch?v=vi-2nasppAg&t=3772s) I do think that's quite interesting, but it just needs to be deleted every, like quite aggressively. Um, yeah. But, but I think, I think that's more or less a solved problem.

[1:02:59](https://www.youtube.com/watch?v=vi-2nasppAg&t=3779s) It's like a bit gnarly, but basically the way I envision it, you would do it, um, if you did this properly is on each event, you basically have like client provenance information.

[1:03:08](https://www.youtube.com/watch?v=vi-2nasppAg&t=3788s) We say like, "Who was this? Like, uh, what, what were they able to do? Like, how, how sure are we that these people are, you know, the, the HTTP client or the, the stream client was actually entitled to do this operation?"

[1:03:19](https://www.youtube.com/watch?v=vi-2nasppAg&t=3799s) Um, and, and again, you can model all of that as events, right? Like, you can, you, you would just have an event that is like, "Make this stream public."

[1:03:29](https://www.youtube.com/watch?v=vi-2nasppAg&t=3809s) And until you make that event, it can only be, uh, written to by whoever created it or something.

[1:03:37](https://www.youtube.com/watch?v=vi-2nasppAg&t=3817s) Um, all right. I might ask, uh, um, uh, S- Sean if we can, instead of this video, do a video we'll record a little bit later today, um, that shows it more nicely because I do think it's worth showing.

[1:03:51](https://www.youtube.com/watch?v=vi-2nasppAg&t=3831s) Yeah.

[1:03:51](https://www.youtube.com/watch?v=vi-2nasppAg&t=3831s) Just a little bit too short, short notice.

[1:03:59](https://www.youtube.com/watch?v=vi-2nasppAg&t=3839s) And shall we just wrap it then if, uh... I don't, I didn't mean to keep you all of your, uh, like 10 minute la- longer break, or if anybody wants to chat.

[1:04:08](https://www.youtube.com/watch?v=vi-2nasppAg&t=3848s) Thank you. [laughs] [clapping] [outro jingle]
