Skip to content

Add ai.contrib.sandbox workers for ai.remote - #351

Open
msullivan wants to merge 9 commits into
remote-agentfrom
remote-agent-2
Open

msullivan wants to merge 9 commits into
remote-agentfrom
remote-agent-2

Conversation

@msullivan

Copy link
Copy Markdown
Collaborator

I am not sure what library this code actually belongs in, but it is glue for allowing tools/loops to be automatically run on Vercel Sandbox. None of this code is really ai specific.

There are two main components:

  • ai.contrib.sandbox.worker: generic worker and client code for running python functions in another process (possibly a remote one on a sandbox). This is sandbox agnostic and just depends on being handed anyio streams for talking to a worker process.
  • ai.contrib.sandbox.vercel: which provides glue for syncing the calling project over to a provided vercel sandbox and hooks up streams to pass to the worker client. (The stream part is actually quite annoying because the sandbox API mangles binary, so we need to base64 everything.)

The runner supports running both sync and async functions as well as generators. Results may return out of order. By default generators need to be advanced one element at a time but a "free running" mode can be requested where generators will generate elements without waiting for a request. To avoid either blowing up memory or blocking everything on one slow generator consumer, we have per-generator backpressure.

@msullivan
msullivan requested a review from anbuzin November 13, 2026 01:58
@msullivan
msullivan added this pull request to stack #352 November 13, 2026 01:58
@msullivan msullivan added the feature New functionality label Nov 13, 2026
@vercel

vercel Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
ai-python Ready Ready Preview, v0 Nov 17, 2026 1:52am UTC

@socket-security

socket-security Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedpypi/​vercel-oidc@​0.8.0 ⏵ 0.12.0100 +1100100100100
Addedpypi/​vercel@​0.13.0100100100100100

View full report

@vercel-internal-security-reviewer

Copy link
Copy Markdown

Security review details

@msullivan msullivan changed the title [WIP] Add ai.contrib.sandbox workers for ai.remote Add ai.contrib.sandbox workers for ai.remote Nov 16, 2026
@msullivan
msullivan marked this pull request as ready for review November 16, 2026 23:09
Comment thread src/ai/contrib/sandbox/runner.py Resolved
Comment thread src/ai/contrib/sandbox/runner.py Resolved
I am not sure what library this code actually belongs in, but it is
glue for allowing tools/loops to be automatically run on Vercel
Sandbox. None of this code is really ai specific.

There are two main components:
 * `ai.contrib.sandbox.runner`: generic runner and client code for
   running python functions in another process (possibly a remote one on
   a sandbox). This is sandbox agnostic and just depends on being handed
   anyio streams for talking to a runner process.
 * `ai.contrib.sandbox.vercel`: which provides glue for syncing the
   calling project over to a provided vercel sandbox and hooks up
   streams to pass to the runner client. (The stream part is actually
   quite annoying because the sandbox API mangles binary, so we need
   to base64 everything.)

The runner supports running both sync and async functions as well as
generators. Results may return out of order. By default generators
need to be advanced one element at a time but a "free running" mode
can be requested where generators will generate elements without
waiting for a request. To avoid either blowing up memory or blocking
everything on one slow generator consumer, we have per-generator
backpressure.

This branch was successfully deployed

1 active deployment
Preview — 5e596b96 Deployed Nov 17, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant