-
Notifications
You must be signed in to change notification settings - Fork 765
Description
Is your feature request related to a problem? Please describe.
I am experiencing challenges when running long-duration tasks (e.g., heavy data processing, complex simulations, or long-running Python scripts) that take more than 5-10 minutes to complete.
Currently, the SDK requires a persistent connection to receive execution results through streaming or standard return values. I'm often frustrated when network fluctuations or client-side timeouts cause the connection to drop before the task finishes, making it difficult to retrieve the final output without complex manual polling or state management.
Describe the solution you'd like
I would like E2B to support an asynchronous execution mode with a Webhook/Callback mechanism.
Specifically:
- When calling
sandbox.run_codeorexec_cell, I want to be able to provide acallback_url. - E2B should accept the task and immediately return a task ID.
- Once the code execution is finished (whether it succeeds or fails), the E2B backend should send a
POSTrequest to the providedcallback_urlcontaining the full execution results (stdout, stderr, results, and exit code).
This "fire-and-forget" pattern would significantly improve the reliability of long-running agentic workflows.
Describe alternatives you've considered
- Polling: Periodically checking the sandbox status or files, but this increases API overhead and is inefficient.
- Long-lived WebSockets: Keeping a connection open for 15+ minutes is unreliable in many production environments (like serverless functions or behind certain load balancers).
- Custom Proxy: Building a middle-layer worker to wait for E2B, but this adds unnecessary architectural complexity.
Additional context
This feature is particularly important for Multi-Agent systems where one supervisor agent might trigger multiple long-running sub-tasks across different sandboxes. A native callback support would allow the system to be truly event-driven.
Proposed conceptual API:
sandbox.commands.run(
"python long_task.py",
callback_url="https://my-service.com/api/v1/e2b-callback",
metadata={"job_id": "abc-123"}
)