// Router agent that delegates to sub-agent
const routerAgent = new Agent({
name: "router-agent",
model: openai("gpt-4"),
agents: { subAgent }, // Sub-agent registered here
memory: new Memory({
options: {
workingMemory: {
enabled: true,
scope: "resource", // resource scoped memory
template: `User Info: {{name}}, {{email}}`,
},
},
}),
});
// Sub-agent with working memory enabled
const subAgent = new Agent({
name: "sub-agent",
model: openai("gpt-4"),
instructions: "You help with specific tasks",
memory: new Memory({
options: {
workingMemory: {
enabled: true,
scope: "resource",
template: `User Info: {{name}}, {{email}}`,
},
},
}),
});
// Router agent that delegates to sub-agent
const routerAgent = new Agent({
name: "router-agent",
model: openai("gpt-4"),
agents: { subAgent }, // Sub-agent registered here
memory: new Memory({
options: {
workingMemory: {
enabled: true,
scope: "resource", // resource scoped memory
template: `User Info: {{name}}, {{email}}`,
},
},
}),
});
// Sub-agent with working memory enabled
const subAgent = new Agent({
name: "sub-agent",
model: openai("gpt-4"),
instructions: "You help with specific tasks",
memory: new Memory({
options: {
workingMemory: {
enabled: true,
scope: "resource",
template: `User Info: {{name}}, {{email}}`,
},
},
}),
});