Skip to content
Documentation
On this page

App tools · Operation approvals

App tools · Operation approvals from the built-in skills in Executor 2.0.0-beta.79.

This page covers Operation approvals from the built-in skills shipped with Executor 2.0.0-beta.79. It contains app-authoring/tools.md.

Previous: App tools

Operation approvals

Declare approval in a query or mutation options object:

import { always, never } from "apps/operations/approval"

// On a tool that needs confirmation:
approval: always(),
// On a tool that can run without confirmation:
approval: never(),

A custom synchronous or async callback receives toolName, decoded toolInput, and signal. Return approved, denied, or user-approval. The constructors infer the callback input from its schema. Annotate a shared function with Approval<Input> from apps/operations/approval. Assign the same function to several tools to share a policy. Attach approval to one shared operation with withApproval(operation, policy), and to the tools of an MCP, OpenAPI or GraphQL router with withApprovals(router, (tool, name) => policy) (integrations.md).

Only the selected tool’s callback runs, after input validation. Omitted approval permits execution. Invalid decisions and callback failures prevent the tool body from running. There is no app-level policy or createExecutor policy option.

In model mode, when execute returns approval-required, show its elicitation.message and reviewed invocation to the user. This is an MCP form request with an empty requestedSchema. After the user answers, call resume({ requestId, response: { action: "accept", content: {} } }), resume({ requestId, response: { action: "decline" } }), or resume({ requestId, response: { action: "cancel" } }). Do not put tool arguments in response.content; this form only confirms the saved invocation. Resume continues the existing program and can return another interaction. For input-required, show the form and return the user-provided fields in response.content; accept, decline and cancel all return to the running tool. Invalid form content leaves the request pending. Never execute the original source again to continue it. No native or browser prompt is opened by this mode; the agent must ask the user. An unavailable response means that continuation cannot resume; report that earlier calls may have completed. Do not remove the approval policy to bypass it. Discovery does not evaluate approval callbacks without arguments. Account access and app evaluation remain separate trust decisions.

With /mcp?elicitation_mode=native, the client displays the policy confirmation through MCP elicitation/create. Execute waits for its answer and continues the same program; resume is not exposed. This requires a client with form elicitation support on a compatible stateful MCP protocol. Keep the tool’s approval policy in either mode. Running tools can ask for structured input with await ctx.elicit({ mode: "form", message: "Name this result", requestedSchema: { type: "object", properties: { name: { type: "string" } }, required: ["name"] } }). This returns an MCP response with action and optional content; the framework validates accepted content against the form. Handle decline/cancel in tool code. The same tool continues with its local state intact. This works in native or model mode, or with an SDK host that supplies a delivery handler. The capability is unavailable during factory evaluation/discovery and after the invocation closes. An earlier tool policy approval never auto-answers these requests. Upstream MCP form elicitation uses this same path automatically for MCP tools. URL-mode input is not yet supported.

With /mcp?elicitation_mode=browser, pending requests include approvalUrl. Show that link to the user, then call resume({ requestId }) with no response. The user signs in and answers in the browser. Do not submit an answer on their behalf. Resume waits briefly; if it returns the same pending request, wait and collect again. If it returns a new link, show that link too. The original program and running tool continue without replay. An unavailable request may have expired, been consumed, or been lost on restart; do not rerun the source automatically.

Cache and lazy operation sources

Use ctx.cache.get({ key, schema, freshFor, staleFor, load }) for shared JSON. Put every result dependency in the key. Use ctx.cache.forAccount(account) for private results; the host also scopes entries to current credentials. Use the loader’s fetch, signal, and cache so stale refreshes can finish after the request. Pass stale: "revalidate" to await the load past freshFor instead of serving the old value; the loader can read(key, schema) the old value to confirm it cheaply. Errors are not cached. invalidate(key) also fences pending loaders.

The cache keeps an entry at most 7 days. A longer freshFor plus staleFor, or a longer write retention, is shortened to 7 days, taking staleFor first. A call that exceeds another limit fails with CacheError and code capacity, and the message names the limit:

Limit Value
Key, as canonical JSON 8,192 bytes
Value, as JSON 2,000,000 bytes
One readMany or write 128 entries and 8,000,000 bytes
The app’s whole cache 100,000 entries and 128,000,000 bytes

A load has 90 seconds. A caller waits at most 10 seconds for another caller’s load of the same key, then loads for itself without storing the result.

Use dynamicRouter({ list, resolve }) for large or remote catalogs. List tool metadata separately from resolving one query or mutation. accountRouter preserves lazy resolution: a call resolves its one tool without running list. Agents can still call only tools list returns; MCP call and execute fail with UnknownTool for any other name before it reaches resolve. Input validation and approvals still run on each call.

A dynamic router can be the app’s whole tools value, or be mounted under a key. Names are relative to the router and may contain dots. Mark queries with readOnly: true; other tools are mutations. An optional meta() supplies the router’s title, description and instructions.

export default defineApp(
  {},
  {
    tools: dynamicRouter({
      list: async () => [
        {
          name: "ping",
          description: "Return pong",
          inputSchema: { type: "object", properties: {} },
          readOnly: true,
        },
      ],
      resolve: async (name) =>
        name === "ping" ? query({ input: object({}) }, async () => "pong") : undefined,
    }),
  },
);

list describes available tools; resolve returns the matching query or mutation declaration.

Was this page helpful?