Tools within your code are registered using one of the SDKs, this makes the tool available for the agent to use within a Workflow.

The execution of functions takes place within your environment. Inferable manages a distributed job queue of function calls which is polled by the SDK. This means in order to use a function,

  1. Your service does not need to expose an endpoint to receive function calls.
  2. There are no network configuration changes required to run the function.
  3. The function will be executed in your own VPC, as long as it can connect to the Inferable cluster.

Here’s how the long polling mechanism works between your tools and the Inferable control plane:

Examples

Tool registration works the same way across all SDKs.

inferable.tools.register({
  name: "greet",
  description: "Greet the user",
  func: (input) => {
    console.log("Greeting user", input);
    return `Hello ${input.userName}`;
  },
  schema: {
    input: z.object({
      userName: z.string(),
    }),
  },
});

inferable.tools.register({
  // ... another tool
});

inferable.tools.listen();

// and on shutdown
inferable.tools.unlisten();

The snippet above registered a tool called greet. Agents within the same cluster can now invoke this tool as needed. The result of a tool’s handler is always returned to the agent for evaluation, this includes any Errors or Exceptions thrown.