Skip to content

feat(e2b): add E2B_SANDBOX_URL - #3520

Merged
jujn merged 1 commit into
agentscope-ai:mainfrom
wg1026688210:feature/add_sandbox_url
Oct 14, 2026
Merged

jujn merged 1 commit into
agentscope-ai:mainfrom
wg1026688210:feature/add_sandbox_url

Conversation

@wg1026688210

Copy link
Copy Markdown
Contributor

AgentScope-Java Version

2.0.5-SNAPSHOT

Description

Background

The E2B sandbox backend (agentscope-extensions-sandbox-e2b) builds its data-plane (envd) address as https://<port>-<sandboxId>.<domain>, which requires wildcard DNS (*.<domain>) to resolve. Self-hosted E2B-
compatible backends (e.g. CubeSandbox) typically expose a single fixed gateway address instead, and route data-plane requests by the E2b-Sandbox-Id / E2b-Sandbox-Port request headers — the same header-based r
outing the official E2B SDKs use (the official cloud itself serves envd traffic from the shared sandbox.<domain> host, and offers E2B_SANDBOX_URL for exactly this override).

Purpose

Add an envdSandboxUrl option — the equivalent of the official SDK's E2B_SANDBOX_URL — so the E2B backend can target a fixed data-plane URL (e.g. http://10.0.0.1:8080) with no wildcard DNS, as long as the ga
teway routes by the E2B headers (which this client already sends on every envd request, together with X-Access-Token).

How to test

mvn -T1 -pl agentscope-extensions/agentscope-extensions-sandbox/agentscope-extensions-sandbox-e2b -am test

Copilot AI balanced review requested due to automatic review settings October 12, 2026 09:51
@wg1026688210 wg1026688210 changed the title add E2B_SANDBOX_URL feat(e2b): add E2B_SANDBOX_URL Oct 12, 2026
@CLAassistant

CLAassistant commented Oct 12, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Call-level gateway overrides are lost when persisted sandboxes are resumed, and public API documentation needs correction.

3 open findings
What changed in this PR

Adds fixed-gateway envd routing for self-hosted E2B-compatible backends.

Changes:

  • Adds envdSandboxUrl configuration and request routing.
  • Preserves the option during client option merging.
  • Adds tests and bilingual documentation.

Review note: Rename the PR using conventional commits, e.g. feat(sandbox-e2b): add fixed envd sandbox URL.

File Description
E2bSandboxClientOptions.java Defines the fixed envd URL option.
E2bSandboxClient.java Merges and copies the option.
E2bFilesystemSpec.java Exposes fluent configuration.
E2bEnvdProcessClient.java Routes envd requests to the configured URL.
E2bEnvdSandboxUrlTest.java Tests routing, headers, and option merging.
docs/​v2/​en/​docs/​harness/​filesystem.md Documents the option in English.
docs/​v2/​zh/​docs/​harness/​filesystem.md Documents the option in Chinese.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +129 to +131
if (call.getEnvdSandboxUrl() != null) {
o.setEnvdSandboxUrl(call.getEnvdSandboxUrl());
}
Comment on lines +53 to +56
public E2bFilesystemSpec envdSandboxUrl(String envdSandboxUrl) {
options.setEnvdSandboxUrl(envdSandboxUrl);
return this;
}
Comment on lines +42 to +43
* <p>When set, {@link #setDomain(String) domain} only affects the control-plane default
* ({@code api.<domain>}) and the recorded sandbox state; the data plane ignores it.
@codecov

codecov Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.66667% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...cope/extensions/sandbox/e2b/E2bFilesystemSpec.java 0.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@wg1026688210
wg1026688210 force-pushed the feature/add_sandbox_url branch from fcfc383 to 0a73d17 Compare October 13, 2026 00:28
@wg1026688210

wg1026688210 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor Author

@wahllllll @qbc2016 @chickenlj PTAL

@wg1026688210
wg1026688210 force-pushed the feature/add_sandbox_url branch from 0a73d17 to 64f4230 Compare October 13, 2026 08:25
@wg1026688210
wg1026688210 force-pushed the feature/add_sandbox_url branch from 0314ee8 to 1960198 Compare October 14, 2026 02:28
@wg1026688210

Copy link
Copy Markdown
Contributor Author

cc @jujn

@wahllllll wahllllll left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed this since @wg1026688210 asked for a look. I verified the routing change end to end and ran the module locally; everything holds.

The override reaches every envd call site. envdHost is the single place that builds the data-plane base, and all three callers — runShellCapture, uploadFile, downloadFile — go through it. The E2b-Sandbox-Id / E2b-Sandbox-Port headers are added unconditionally in baseRequest, so with envdSandboxUrl set a request is <gateway>/process.Process/Start (or /files?...) and routing falls entirely to those headers — exactly the official E2B_SANDBOX_URL contract. The trailing slash is trimmed via E2bPlatformHttp.trimSlash, so path joins stay clean.

Resume keeps the override. create(...) copies the merged value onto the persisted E2bSandboxState, and resume(...) reads it back onto the rebuilt options, so a gateway override survives a stop/resume cycle. That also closes the medium-severity point Copilot raised on the earlier revision.

Verified locally (JDK 17, this branch):

E2bEnvdSandboxUrlTest         Tests run: 5,  Failures: 0, Errors: 0
whole e2b module              Tests run: 87, Failures: 0, Errors: 0, Skipped: 1

On the red build (windows-latest): it is ChatSessionsTest.queuedTasksAreDistinctAndSteeringStaysInCurrentExecution (23.15 s vs the 15 s await budget), not this change. That is the known windows-latest flake we filed as #3517 — unrelated to the sandbox module, and it reproduces on other PRs too.

Two non-blocking nits:

  • The PR title has a double space (add E2B_SANDBOX_URL) and would read better as a conventional commit, e.g. feat(sandbox-e2b): support a fixed envd gateway URL (E2B_SANDBOX_URL).
  • envdSandboxUrl is not validated as an absolute URL; a malformed value would only surface as an IllegalArgumentException from OkHttp at request time. A cheap check in the setter (or a note in the javadoc) would fail earlier — optional.

LGTM — the design matches the official SDK and the coverage is solid.

@jujn

jujn commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

Assign to @wahllllll (Review)

@jujn
jujn merged commit febc795 into agentscope-ai:main Oct 14, 2026
6 of 7 checks passed
@wahllllll

Copy link
Copy Markdown
Contributor

你好 @jujn 👋

我们最近在 AgentScope-Java 上比较活跃,提交了一些 issue 和 PR,也参与了几次 PR 评审(例如 #3519、#3520,都在合并前给出了 LGTM)。我们对这个项目很感兴趣,希望能长期、持续地参与共建,后续也会继续积极地提 issue、PR 和做评审。

在学习 COMMUNITY_zh.md 时我们注意到,有效 Review 需要由核心维护者在合并前把 Reviewer 加入 PR 的 Assignees,作为贡献记录的依据。而我们评审过的 #3519、#3520 在合并时 Assignees 都是空的,所以想向您请教一下:

  • 是我们评审的方式或质量还不到位、或者哪里不符合规范,所以没有被计入吗?
  • 还是只是流程上漏记了?如果是后者,方便的话能否帮我们补记一下 Assignees?

我们很想把评审这条路走扎实,也非常欢迎任何关于评审方式与标准的建议。谢谢!

@jujn

jujn commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

你好 @jujn 👋
在学习 COMMUNITY_zh.md 时我们注意到,有效 Review 需要由核心维护者在合并前把 Reviewer 加入 PR 的 Assignees,作为贡献记录的依据。而我们评审过的 #3519、#3520 在合并时 Assignees 都是空的,所以想向您请教一下:

  • 是我们评审的方式或质量还不到位、或者哪里不符合规范,所以没有被计入吗?
  • 还是只是流程上漏记了?如果是后者,方便的话能否帮我们补记一下 Assignees?

我们很想把评审这条路走扎实,也非常欢迎任何关于评审方式与标准的建议。谢谢!

github 有时有 bug,Assignees 不了(点了没反应),所以评论 Assign to xx 也计入。另外,有些过于简单的PR是否完全没必要多 review 一次呢?

@wahllllll

Copy link
Copy Markdown
Contributor

感谢 @jujn 的说明!我们之前只看了 Assignees 字段,没意识到 Assign to @xxx (Review) 的评论同样计入,是我们理解偏了,抱歉。也看到您在 #2697、#3519、#3520 都留了记录,非常感谢。

关于第二点我们完全认同:评审的价值在于真正发现问题,而不是把每个 PR 都过一遍凑次数。像 #3519 这种一行改动,确实没必要单独 review。后续我们会更聚焦在改动较大、涉及并发 / 协议 / 兼容性等真正需要独立验证的 PR 上,尽量给出可复现的验证和具体意见,而不是走形式。

如果方便的话想请教一下:您更希望我们把评审精力放在哪些方向(某些模块 / 某类改动)?我们也好把力气用在刀刃上。谢谢!

@jujn

jujn commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

如果方便的话想请教一下:您更希望我们把评审精力放在哪些方向(某些模块 / 某类改动)?我们也好把力气用在刀刃上。谢谢!

比较重要的功能/修复吧,比如 agent 核心执行链路

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants