Skip to content

Create Custom Tools

Custom tools are declared as extensions on AgentConfig.

Runtime Tool

Runtime tools execute inside the managed agent environment.

ts
const agent = await app.agents.create({
  title: "Tool agent",
  config: {
    instructions: "Use tools when helpful.",
    capabilities: ["execute"],
    extensions: [
      {
        environment: "agent",
        name: "calculate_total",
        description: "Calculate an order total from item prices.",
        parameters: {
          type: "object",
          properties: {
            prices: {
              type: "array",
              items: { type: "number" },
            },
          },
          required: ["prices"],
        },
        code: `
export default async function ({ prices }) {
  return prices.reduce((sum, price) => sum + price, 0);
}
`,
      },
    ],
  },
});

Permissions

Use capabilities to describe what the runtime may do:

ts
await agent.updateConfig({
  capabilities: [
    "read",
    "write",
    {
      environment: "agent",
      capabilities: ["execute", "network"],
    },
  ],
});