Skip to content

[Feature Request] Support Webhook/Callback for long-running code execution results #1069

Description

@feifei325

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:

  1. When calling sandbox.run_code or exec_cell, I want to be able to provide a callback_url.
  2. E2B should accept the task and immediately return a task ID.
  3. Once the code execution is finished (whether it succeeds or fails), the E2B backend should send a POST request to the provided callback_url containing 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

  1. Polling: Periodically checking the sandbox status or files, but this increases API overhead and is inefficient.
  2. Long-lived WebSockets: Keeping a connection open for 15+ minutes is unreliable in many production environments (like serverless functions or behind certain load balancers).
  3. 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"}
)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or requestsdkImprovements or additions to SDKs

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions