(just an evening spike, ignore)
openai's swarm, rewritten by vercel's ai sdk team, running on workers/durable objects.
const agentA = new Agent({
name: "Agent A",
system: "You are a helpful agent.",
tools: {
transferToAgentB: {
type: "handover",
parameters: z.object({}),
execute: () => ({ agent: agentB }),
},
},
});
const agentB = new Agent({
name: "Agent B",
system: "Only speak in Haikus.",
});
try {
const { text } = await runSwarm({
agent: agentA,
context: {},
model: openai("gpt-4o", { structuredOutputs: true }),
prompt: "I want to talk to agent B.",
debug: true,
onStepFinish: (result) => {
console.log({ result });
},
});
console.log("got here");
this.state.text = text;
} catch (e) {
console.error(e);
}