Agent Runtime

Give Agents Tools

Agent Runtime provides several agent tools out-of-the-box.

Agent Runtime Tools

The webSearch tool allows agents to search the web for information.

const agent = createAgent({
  goal,
  model: anthropic("claude-sonnet-3-5-latest"),
  tools: [webSearch],
});

Custom Tools

You can also create your own tools.

// Define tool
const lookupUser = createTool(
  async (input) => {
    const user = await getUser(input.userId);
    return textBlock(user);
  },
  {
    name: "getUserInfo",
    description: "Retrieve information about the user from their userId",
    schema: z.object({
      userId: z.string(),
    }),
  }
);
 
const agent = createAgent({
  goal,
  model: anthropic("claude-sonnet-3-5-latest"),
  // Provide tool to agent
  tools: [lookupUser],
});

On this page