Agents can use tools to achieve their goal. By default, agents have access to all the tools connected to the cluster at the time of the agent’s execution. However, you can also specify a list of tools the agent should use alongside the agent’s goals.

Explicitly Specifying Tools

You can restrict the tools that an agent can use by specifying a list of tools in the agent’s configuration. Note that by specifying a list of tools:

Semantics:

  • The agent will only be able to use the tools specified.
  • The agent may choose not to use the specified tool, at its own discretion.
workflow.version(1).define(async (ctx) => {
  const identifyUserAgent = ctx.agent({
    name: `identifyUser`,
    systemPrompt: [
      `You are given an email body`,
      `Analyze the email and identify the user and the purpose of the email`,
    ],
    resultSchema: z.object({
      userId: z.string().optional(),
      purpose: z.enum(["refund", "inquiry", "other"]),
    }),
    tools: ["users_getUserByEmail"],
  });

  const result = await identifyUserAgent.trigger();

  console.log(result);
});

Biasing the Agent Towards a Specific Tool

You can bias the agent towards a specific tool by specifying the tool in the agent’s system prompt. We recommend using the structured prompt for this purpose.

Semantics:

  • The agent will be biased towards using the specified tool.
  • The agent may choose to use other tools, at its own discretion.
  • The agent may choose not to use the specified tool, at its own discretion.
workflow.version(1).define(async (ctx) => {
  const identifyUserAgent = ctx.agent({
    name: `identifyUser`,
    systemPrompt: inferable.workflows.helpers.structuredPrompt({
      facts: [
        `You are given an email body`,
        `Analyze the email and identify the user and the purpose of the email`,
      ],
      goals: [
        {
          goal: "Identify the user that sent the email",
          tools: ["users_getUserByEmail"],
        },
        "Identify the purpose of the email",
      ],
    }),
  });

  const result = await identifyUserAgent.trigger();

  console.log(result);
});