Skip to content

[Feature]: Support specifying environment variables in execute command API #412

@bianjp

Description

@bianjp

Why do you need it?

Currently, environment variables must be predefined during sandbox creation or written to the file specified by the EXECD_ENVS environment variable. However, in many scenarios, we need to inject or override environment variables dynamically at execution time.

Specific Use Case:
When using tools like the gh-issue skill, a GH_TOKEN is required. If a user updates their token after the sandbox has been created, recreating the entire sandbox environment is not performance-efficient.

While EXECD_ENVS works for some use cases, it is not suitable when multiple commands are executed concurrently, as they share the same environment file. Supporting execution-level environment variables would allow for greater flexibility and better isolation without the overhead of environment recreation.

How could it be?

We should add an env property to the command execution request model and update the SDKs accordingly.

  1. Backend Change:
    Add the Env field to the RunCommandRequest struct:
    type RunCommandRequest struct {
  2. SDK Update:
    Update all Official SDKs (Python, JS, etc.) to support passing environment variables in the command options.

Example usage in Python SDK:

# Expected API usage
execution = await sandbox.commands.run(
    "echo $GH_TOKEN", 
    opts=RunCommandOpts(env={'GH_TOKEN': 'your_token_here'})
)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions