Documentation menu

Concepts

runScript

A sandboxed JavaScript runtime that fans out many API reads in one call and correlates them in-script.

runScript is the default tool for any analytical question. It runs a sandboxed JavaScript runtime where your agent can fan out many API reads in a single call and correlate them in-script — instead of a dozen sequential round-trips.

Why it exists

Real questions span surfaces. “Find wasted spend” needs campaigns, search terms, and quality scores together. runScript lets the agent pull all of them at once and compute the answer locally, which is faster and cheaper than tool-by-tool reads.

Shape

Each platform exposes a host API on ads. For Google Ads:

const r = await ads.gaqlParallel([
  { name: "campaigns",  query: "SELECT campaign.name, metrics.cost_micros ..." },
  { name: "searchTerms", query: "SELECT search_term_view.search_term ..." },
]);
return r.campaigns.rows.filter(/* ... */);

Meta exposes ads.graph/ads.graphParallel; X exposes ads.get/ads.getParallel/ads.stats. The pattern is identical across platforms.

runScript is read-only. Mutations always go through the dedicated write tools so they’re logged and approval-gated — never write through runScript.