Skip to content

What is Alchemy AI?

Alchemy AI models agentic processes in code. A process is prose that describes a piece of work, and everything it mentions is a real reference: a tool, an LLM, another process, a part of your business.

Those references connect the whole system. Processes use tools, tools use your infrastructure, and your Domain model holds the rules of the business. It is one declarative program that the compiler checks and Alchemy deploys.

The examples come from an issue board that looks after a GitHub repository, the same one the tutorial builds.

ProcessesDomain modelToolsResourcesstartssendssendscallsusesonstored inRespondReviewOpenPullRequestApprovePullRequestPullRequestSearchIssuesGitHub.SearchIssuesRepoGitHub.RepositoryBoardCloudflare.DurableObject
CommandAggregateProcessToolBindingResource
Respond opens a pull request for an issue and starts Review to check it. The pull request lives in the Domain model, and both processes act on it through commands. A tool reaches GitHub through a binding, and Alchemy deploys all of it.

A process has two parts. The class is its name, which the rest of your program refers to:

src/Triage.process.ts
export class Triage extends AI.Process<Triage>()("Triage", {}) {}

A Layer gives that name its prose, which the LLM reads as its instructions:

src/Triage.process.ts
export const TriageLive = Triage.toLayer({
description: "Say what kind of issue this is.",
})`
Read the issue you are given and reply with one word:
bug, feature or question.
`;

Everything in Alchemy AI is split this way. A tool, an LLM, the harness and the sandbox are each a name, and a Layer provides its implementation. Code depends on the name, so one implementation can be swapped for another without changing the code that uses it.

A process is not an agent with an identity. It describes work, and it can run any number of times.

See Processes.

Prose refers to a tool, a model or another process with ${}. That is a mention. The LLM sees it by name, and the process may use it.

src/Triage.process.ts
export const TriageLive = Triage.toLayer({
description: "Say what kind of issue this is.",
})`
Find the code the issue is about with ${AI.Grep} and ${AI.Read}.
Reply with one word: bug, feature or question.
`;

A process can use only what it mentions. This Triage can search and read files, and it cannot edit one or run a command.

A mention is also a dependency. TriageLive needs a Layer for each tool, and a program that provides it without them does not compile.

A session is a running process: one conversation, with a key you choose.

const triage = yield* Triage;
const reply = yield* triage.get("issue-42").prompt("The app crashes on the settings page.");

A session keeps its conversation indefinitely. Send it another message next week and it remembers everything so far. send leaves a message and returns, steer puts one into the turn that is running, and interrupt stops it.

A session reports what it does as a stream. The first event says whether it is working, and the rest are its messages and tool calls as they happen:

const events = triage.get("issue-42").events();

A process has no inputs and no output. A session is told what to do in its messages, and it acts through what its process mentions.

A tool is a function the LLM can call. Its class says what it takes, what it returns and how it can fail.

src/PostAnswer.tool.ts
export class IssueClosed extends Schema.TaggedError<IssueClosed>()("IssueClosed", {
issue: Schema.Number,
}) {}
export class PostAnswer extends AI.Tool<PostAnswer>()("post_answer", {
description: "Post your answer on the issue as a comment.",
parameters: Schema.Struct({ issue: Schema.Number, markdown: Schema.String }),
success: Schema.Struct({ url: Schema.String }),
failure: IssueClosed,
}) {}

The LLM reads a failure as the tool’s result and can try something else.

The class is only the tool’s name and shape. A Layer provides its handler, an Effect that runs in your program:

src/PostAnswer.tool.ts
export const PostAnswerLive = PostAnswer.make(
Effect.gen(function* () {
const comment = yield* GitHub.CreateIssueComment(yield* Repo);
return Effect.fn(function* ({ issue, markdown }) {
const posted = yield* comment({ issue_number: issue, body: markdown }).pipe(Effect.orDie);
return { url: posted.html_url };
});
}),
).pipe(Layer.provide(GitHub.CreateIssueCommentHttp));

The handler reaches the outside world through resources and bindings. Repo is a GitHub repository this program declares, and GitHub.CreateIssueComment is a binding that lets the handler comment on it. Any resource works the same way. A tool that saves a report binds to an S3 bucket:

src/SaveReport.tool.ts
export const Reports = AWS.S3.Bucket("Reports", {});
export const SaveReportLive = SaveReport.make(
Effect.gen(function* () {
const putObject = yield* AWS.S3.PutObject(yield* Reports);
return Effect.fn(function* ({ name, markdown }) {
yield* putObject({ Key: name, Body: markdown }).pipe(Effect.orDie);
});
}),
).pipe(Layer.provide(AWS.S3.PutObjectHttp));

Alchemy deploys the bucket and grants what the binding needs: s3:PutObject on that one bucket. A tool can do what its bindings allow.

A few tools are the same everywhere: run a command, read a file, edit one, search. Those are names (AI.Bash, AI.Read, AI.Edit, AI.Grep) that each harness implements its own way. An MCP server is mentioned like a tool and stands for every tool it offers.

See Tools, Coding tools and MCP servers.

A model is a name for an LLM. A process mentions the name, never the LLM behind it.

src/Models.ts
export class Smart extends AI.Model<Smart>()("smart") {}
export class Fast extends AI.Model<Fast>()("fast") {}

Every session runs on the default model unless told otherwise. A process that mentions a model may hand work to it:

`For anything you need to look up, start a ${Research} on ${Fast}.`

See Models.

A process can mention another. That gives its session two ways to use it: follow it, reading that process’s prose into its own conversation, or start it, as a session of its own.

src/Answering.process.ts
export class Answering extends AI.Process<Answering>()("Answering", {}) {}
export const AnsweringLive = Answering.toLayer({
description: "How to write an answer on an issue. Follow it before you post one.",
})`
Keep the answer under two hundred words. Name each file you read.
`;
src/Triage.process.ts
export const TriageLive = Triage.toLayer({
description: "Answer one issue and say what kind of issue it is.",
})`
Follow ${Answering}, then post your answer with ${PostAnswer}.
`;

Triage mentions the name Answering, not its prose, so AnsweringLive can change without Triage knowing.

A mention does not fix how Answering is used. It makes the process available, and the session decides: it can follow it, start it, or do both at different times. The prose can suggest one, as “Follow” does above, and it is still the session’s choice.

Other systems have two concepts here: a skill, instructions read into the current conversation, and a subagent, a separate conversation with its own instructions. Here both are the same process, used in two ways.

Processes that mention each other are how you model a team or an organization.

See Processes that use processes.

Domain model: the business a process works on

Section titled “Domain model: the business a process works on”

A Domain model is your business in code: what can happen, what did happen, and the rules that decide. An issue board has issues that are reported, labeled and replied to.

src/Board/Board.model.ts
export class Board extends Domain.Model("Board", {
aggregates: [Issue],
views: [IssueDetail],
}) {}

A process describes a business process over that model. Its prose mentions the model’s commands and views, and a session reads and acts through them:

src/Triage.process.ts
export const TriageLive = Triage.toLayer({
description: "Say what kind of issue this is.",
})`
Get the issue with ${Board.IssueDetail}. Then send ${Board.LabelIssue}:
bug when something is broken, feature when something new is asked for,
question otherwise.
`;

The model’s rules hold whoever sends a command. A session cannot label an issue nobody reported, because the board rejects it. A session is started as someone, and every command it sends is sent as them:

yield* assistant.start(customer.id, { as: CurrentActor.context(customer) });

The two work in both directions. A policy of the model decides when there is work for a process, and Domain can prove the model’s rules hold whatever a session sends.

See Processes and Domain models.

A Layer provides an implementation. It connects a tool, a model or a process to something concrete in the outside world, through resources and bindings. A process’s Layer is its prose, and a tool’s Layer is its handler.

A model’s Layer is the LLM behind its name:

src/Models.ts
export const SmartLlama = AICloudflare.Model(Smart, {
model: "@cf/meta/llama-3.3-70b-instruct-fp8-fast",
});

A process that will only ever have one prose can skip the Layer and carry it on the class:

src/Answering.process.ts
export class Answering extends AI.Process<Answering>()("Answering", {
description: "How to write an answer on an issue. Follow it before you post one.",
})`
Keep the answer under two hundred words. Name each file you read.
` {}

Something has to run the loop: send the LLM the conversation and its tools, run the tools it asks for, and ask again until it answers. That program is an agent harness. Pi and OpenCode are harnesses, and so are Claude Code and Codex.

A process never names one. The harness is one more Layer, provided with the rest:

src/Layers.ts
export const Live = TriageLive.pipe(
Layer.provide(
Layer.mergeAll(
AnsweringLive,
PostAnswerLive,
SmartLlama,
AI.DefaultModel(Smart),
Pi.HarnessLive,
),
),
);

Change Pi.HarnessLive for OpenCode.HarnessLive and the same processes run on OpenCode.

See Choose a harness.

Sandboxes: a machine for files and commands

Section titled “Sandboxes: a machine for files and commands”

The harness and a sandbox are two separate things. The harness runs the loop, inside your program. A sandbox is a Linux machine somewhere else, on E2B, Daytona, Modal, Boat or Archil. It only holds files and runs shell commands.

A session that never touches a file needs no sandbox. When a tool reads a file or runs a command, the harness sends that one call to the session’s sandbox, and each session has its own.

const sandbox = yield* AI.Sandbox;
const result = yield* sandbox.exec(["npm", "test"]);

See Sandboxes.

A session needs two things from where it runs: storage that only it owns, for its conversation, and a way to carry on after a restart. Both are Layers, like everything else, so the host is a choice and not part of a process.

On a long-lived machine, such as a container or a Fly Machine, the storage is a SQLite file:

const StorageLive = Pi.SqliteFile("/data/pi.sqlite");

On Cloudflare it is a Durable Object you write. It yields the process, and its methods are what the rest of your app may ask of a session:

src/Agents.ts
export default class Agents extends Cloudflare.DurableObject<Agents>()(
"Agents",
Effect.gen(function* () {
const triage = yield* Triage;
return Effect.succeed({
start: (issue: number) =>
triage
.get(String(issue))
.send(`The issue is ${issue}.`, { requestId: "start" })
.pipe(Effect.orDie),
});
}).pipe(Effect.provide(Live)),
) {}

See Where sessions run and Pi on other hosts.

A session reports everything it does as a stream: its status, then each message, tool call and result. The object that runs it records that into the Domain model, as a command:

src/Agents.ts
yield* triage.get(issue).events({ after: recorded.seq }).pipe(
Stream.groupedWithin(50, "100 millis"),
Stream.runForEach((batch) => sessions.send(new RecordActivity(batchOf(issue, batch)))),
);

From there it is ordinary model: a view holds the agent’s status, and a stream holds its transcript.

src/Board/SessionStatus.view.ts
export class SessionStatus extends Domain.View("SessionStatus", {
from: [IssueSession],
key: IssueSession,
state: Schema.Struct({ status: Status, queued: Schema.Array(QueuedMessage) }),
initial: { status: "idle", queued: [] },
evolve: {
ActivityRecorded: (_, event) => ({ status: event.status, queued: event.queued }),
},
}) {}

So a front end uses one Api. It sends commands, which a policy passes to the session, and it watches the status and the transcript like any other read. See Connect a front end.

Every reference above is typed, so the graph is checked from end to end. Triage mentions PostAnswer. PostAnswerLive uses GitHub.CreateIssueComment on Repo. The Durable Object provides them, and the Worker binds the Durable Object.

Alchemy deploys that graph. The binding in PostAnswerLive is also what gives the Worker its GitHub token and the repository to comment on. A process can do what its tools can do, and a tool can do what its bindings allow.

So a process describes the work, and Layers connect it to real implementations: an LLM, a harness, a sandbox, your resources. The same process runs on another harness, another LLM or another sandbox platform by changing a Layer.

Next, build one: the tutorial puts these ideas to work on an issue board, one step at a time. Or read each concept in depth, starting with Processes.