Processes that use processes
A process can mention another process. The session’s model then has two ways to use it. It can follow it: read that process’s prose into its own conversation and carry it out itself. Or it can start it: open a separate session, with its own conversation.
Follow a process
Section titled “Follow a process”Mention a process and tell the model to follow it:
import * as AI from "@alchemy.run/ai";import { RunTests } from "./RunTests.tool.ts";
export class Releasing extends AI.Process<Releasing>()("Releasing", { description: "How to cut a release of this project. Follow it when asked to ship.",})` Call ${RunTests} and stop if anything fails. Bump the version, build, and tag the commit with ${AI.Bash}.` {}import * as AI from "@alchemy.run/ai";import { Releasing } from "./Releasing.process.ts";
export class Engineer extends AI.Process<Engineer>()("Engineer", { description: "Make one change to the project.",})` Make the change you are asked for with ${AI.Edit}. When asked to ship, follow ${Releasing}.` {}An Engineer session always sees Releasing’s name and description. Its prose is read only when the model decides to follow it, so twenty processes to follow cost twenty short descriptions. The tools Releasing mentions are the session’s from the start: Engineer requires RunTests and AI.Bash too.
Write the description for the model
Section titled “Write the description for the model”A process’s description is what another session’s model reads to choose it. Say what the process is for and when to use it.
Start a process
Section titled “Start a process”Mention a process and tell the model to start one:
import * as AI from "@alchemy.run/ai";import { Research } from "./Research.process.ts";
export class Engineer extends AI.Process<Engineer>()("Engineer", { description: "Make one change to the project.",})` Before changing anything, start a ${Research} for each thing you need to know. Then make the change with ${AI.Edit}.` {}Starting is a tool call. It takes the new session’s first message, which says what it is to do, and an optional name for the session, and it returns that name at once. The new session has its own conversation, and nothing it reads fills up the Engineer’s.
Hear back from a started session
Section titled “Hear back from a started session”A process has no output, so a started session does not return to the one that started it. Give both the same place to write: a command and a view of a Domain model, or any tool both mention. The starter can also send the session another message later, with the tool the mention gives it.
Start more of itself
Section titled “Start more of itself”AI.Self is the process being described. Mention it to let a session split its own work:
import * as AI from "@alchemy.run/ai";
export class Research extends AI.Process<Research>()("Research", { description: "Answer one question about the code, with file paths.",})` Answer one question about the repository in your working directory. Search with ${AI.Grep} and open what looks relevant with ${AI.Read}. If the question is too broad, start a ${AI.Self} for each part.` {}Mention a model
Section titled “Mention a model”A model is mentioned like anything else. A session may then be run on it, and may start other sessions on it:
import * as AI from "@alchemy.run/ai";import { Fast } from "./Models.ts";import { Research } from "./Research.process.ts";
export class Engineer extends AI.Process<Engineer>()("Engineer", { description: "Make one change to the project.",})` Before changing anything, start a ${Research} on ${Fast} for each thing you need to know. Then make the change with ${AI.Edit}.` {}Engineer now requires Fast’s Layer. The model that runs an Engineer session itself is the default model, until a message names another. The session keeps that model from then on:
yield* engineer.get("task-7").send("Rename the config flag.", { model: Fast });A session can also be started on a model, before its first message:
yield* research.start("parser", { model: Fast });Mention a tagged process
Section titled “Mention a tagged process”A process declared by name alone is mentioned the same way. The process that mentions it then requires that tag, and none of what its prose mentions:
import * as AI from "@alchemy.run/ai";import { Engineer } from "./Engineer.process.ts";
export class Lead extends AI.Process<Lead>()("Lead", { description: "Split a feature into tasks and hand each to an engineer.",})` Split the feature you are given into tasks, and start an ${Engineer} for each.` {}Whatever Layer provides Engineer is its implementation, so Lead can be given another way of doing the work without changing a word of its own prose.