Skip to content

Allow Inngest Functions to be passed as Sandbox tools - #1796

Open
jpwilliams wants to merge 3 commits into
jack/sandbox-tools2-groupfrom
jack/sandbox-tools2-invoke
Open

jpwilliams wants to merge 3 commits into
jack/sandbox-tools2-groupfrom
jack/sandbox-tools2-invoke

Conversation

@jpwilliams

Copy link
Copy Markdown
Member

Summary

An Inngest function, or a referenceFunction() to one, can now be a Sandbox tool. The code calls it with named arguments, which become the event data, and gets the function's result back. The invoke is a durable step.

import { eventType } from "inngest";

const refund = inngest.createFunction(
  {
    id: "refund",
    triggers: [
      eventType("order/refund", { schema: z.object({ orderId: z.string() }) }),
    ],
  },
  async ({ event }) => issueRefund(event.data.orderId),
);

await sandbox.commands.run("agent", "node agent.js", {
  tools: { refund },
});

Checklist

  • Added a docs PR that references this PR N/A
  • Added unit/integration tests
  • Added changesets if applicable

A function, or a reference to one, in tools is invoked with the call's
named arguments as its event data. It is a group tool whose only step is
the invoke, with its input checked against the function's trigger schema
when there is one.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@jpwilliams
jpwilliams added this pull request to stack #1792 October 15, 2026 21:24
@changeset-bot

changeset-bot Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 758ec20

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
inngest Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@inngest-release-bot inngest-release-bot added the 📦 inngest Affects the `inngest` package label Oct 15, 2026
@greptile-apps

greptile-apps Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] Adds Inngest functions as sandbox tools.

Fix schema selection for wrapped event triggers before merging.

Findings

  1. P1 Wrapped triggers skip argument checks ▶
Fix with agent prompt
### Issue 1
packages/inngest/src/components/sandbox/tools.ts:234-238
`triggerSchema()` misses schemas in supported triggers such as `{ event: eventType("order/refund", { schema }) }`. The schema lives on `trigger.event.schema`, not `trigger.schema`. These functions fall back to `z.record(z.unknown())`, so `{ orderId: 5 }` reaches `step.invoke()` despite a declared string schema. The handler receives invalid data instead of the sandbox getting an argument error.

Read wrapped event types before selecting the schema, and add a test for this trigger form.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Adds Inngest functions and referenceFunction() references as sandbox tools.

  • Sandbox tools can invoke Inngest functions and return their results.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Sandbox tool call] --> B[Resolve registered tool]
  B --> C[Select trigger schema or record fallback]
  C --> D{Arguments accepted?}
  D -->|No| E[Reply with argument error]
  D -->|Yes| F[Set tool call step prefix]
  F --> G[step.invoke]
  G --> H[Reply with function result]
Loading

Reviews (1) · Last reviewed commit: "feat(sandbox): an Inngest function as a ..." · Reviewed by Greptile

Comment thread packages/inngest/src/components/sandbox/tools.ts Outdated
…emas

A function triggered by `{ event: eventType(..., { schema }) }` keeps its
schema on the event type, so tool arguments skipped validation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jpwilliams jpwilliams changed the title feat(sandbox): an Inngest function as a tool Allow Inngest Functions to be passed as Sandbox tools Oct 15, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📦 inngest Affects the `inngest` package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants