Skip to content

Add Sandbox tools to sandbox.commands.run() - #1791

Open
jpwilliams wants to merge 4 commits into
jack/sandbox-tools2-enginefrom
jack/sandbox-tools2-commands
Open

jpwilliams wants to merge 4 commits into
jack/sandbox-tools2-enginefrom
jack/sandbox-tools2-commands

Conversation

@jpwilliams

Copy link
Copy Markdown
Member

Summary

Adds the ability for code running in a Sandbox to call functions from the local scope of the orchestrating run.

Pass tools to sandbox.commands.run() and each call the code makes to a tool runs as its own durable step.

await sandbox.commands.run("agent", "node agent.js", {
  tools: {
    getCustomer: (id: string) => db.customers.find(id),
  },
});

The Sandbox code simply calls tools.getCustomer("123").

Checklist

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

jpwilliams and others added 2 commits October 15, 2026 20:03
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Pass tools to commands.run and the code in the command can call them. A
command with tools defaults to the longest command timeout, since it
waits on your functions.

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

changeset-bot Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e9d9aa5

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 tool invocation capability to sandbox command execution.

Fix repeated command IDs before merging; later calls can silently skip their commands.

Findings

  1. P1 Repeated IDs skip commands ▶
  2. P2 Failures lose sandbox trace details ▶
Fix with agent prompt
### Issue 1
packages/inngest/src/components/sandbox/middleware.ts:175-177
Sequential `commands.run()` calls that reuse an ID with `tools` only run the first command. `step.run()` gives later calls distinct indexed IDs, but `runCommandWithTools()` still uses the original ID for its sandbox directory. The second wrapper sees that directory as already started, skips the new command, and returns the first command's output.

Give each command occurrence a replay-stable identity before deriving its directory and child-step IDs.

### Issue 2
packages/inngest/src/components/sandbox/middleware.ts:194-195
Failed command steps with `tools` never write their sandbox trace details. This wrapper writes `meta` only after `fn()` succeeds, then just rethrows on failure. Unlike ordinary commands, a failed process start or wait loses the sandbox name, command, and service error code, making failures harder to debug.

Write the sandbox trace details on failure too, while keeping trace errors non-fatal.

---

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

Summary

Adds tools and toolOptions to durable sandbox.commands.run() calls.

  • Sandbox commands can call app functions as durable tools.

Reviews (1) · Last reviewed commit: "feat(sandbox): tools on commands.run" · Reviewed by Greptile

Comment thread packages/inngest/src/components/sandbox/middleware.ts
Comment thread packages/inngest/src/components/sandbox/middleware.ts
jpwilliams and others added 2 commits October 15, 2026 21:32
Name the tools directory for the executing step's own ID so repeated
command IDs don't share it, and write the sandbox trace metadata when a
command step with tools fails.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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