Build Dataset using Function called in AIP Agent

I have built a function in typescript v2 repository. Here I have used the dataset build orchestator api. This api triggers the dataset build. It works when I execute the function inside the repository. However, when I call this function in AIP agent then it fails to execute.

Is there any setting that I might be missing? or is this a platform level restriction?

Typescript v2 function:

import { PlatformClient } from "@osdk/client";

import { Orchestration } from "@osdk/foundry";

 

/**

 * Triggers a build for the specified dataset.

 * @param client - The Foundry platform client (injected automatically).

 * @param datasetRid - The RID of the dataset to build (input by the user).

 * @returns A message indicating the result.

 */

export default async function triggerCustomersCleanBuild(

  client: PlatformClient,

  datasetRid: string

): Promise<string> {

  // Trigger the build using the Orchestration API

  await Orchestration.Builds.create(client, {

    target: {

      type: "manual",

      targetRids: [datasetRid], // datasetRid is now provided by the user

    },

    branchName: "master",

    fallbackBranches: [],

    abortOnFailure: false,

    notificationsEnabled: false

  });

 

  return `Build triggered successfully for dataset: ${datasetRid}`;

}

Hey Ankit, quick question first, is there a reason you need to trigger the build programmatically via the Orchestration API? (e.g., conditional logic, dynamic dataset selection, chaining multiple builds, etc.)

If not, and you just need the agent to kick off a dataset build, the simplest approach is to skip the custom function entirely and use an Action Type with a Schedule rule:

  1. Create a Schedule for the dataset(s) you want to build

  2. Create an Action Type → under Rules, click “+ Add new rule” → scroll to Advanced → select Schedule and point it to your schedule
    (screenshot of the action rules editor)

  3. Add that Action as a tool in your AIP Agent
    (screenshot of the tools panel)

That’s it, the agent can then trigger the build via the action and it works out of the box:
(screenshot of the successful execution)

No custom code needed, and it avoids whatever execution context issues you’re hitting with the PlatformClient approach.

Thanks, it worked. I did not know this solution yet.

However, I would like to make it dynamic, we have a dataset that contains list of dataset rids along with some other details for batch and streaming datasets. We have created an ontology object on top of this dataset.

We are using this ontology object inside the AIP chatbot studio and also calling execute function within tools.

Based on the user query if they see some streaming issue on any dataset or some other issue, they can immediately query AIP and AIP will execute the build depending on dataset name/rid. AIP will fetch the RID from ontology object and execute the function.