Repository navigation
feat(e2b): add E2B_SANDBOX_URL - #3520
Conversation
There was a problem hiding this comment.
🟡 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
envdSandboxUrlconfiguration 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.
| if (call.getEnvdSandboxUrl() != null) { | ||
| o.setEnvdSandboxUrl(call.getEnvdSandboxUrl()); | ||
| } |
| public E2bFilesystemSpec envdSandboxUrl(String envdSandboxUrl) { | ||
| options.setEnvdSandboxUrl(envdSandboxUrl); | ||
| return this; | ||
| } |
| * <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 Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
fcfc383 to
0a73d17
Compare
|
@wahllllll @qbc2016 @chickenlj PTAL |
0a73d17 to
64f4230
Compare
0314ee8 to
1960198
Compare
|
cc @jujn |
wahllllll
left a comment
There was a problem hiding this comment.
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). envdSandboxUrlis not validated as an absolute URL; a malformed value would only surface as anIllegalArgumentExceptionfrom 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.
|
Assign to @wahllllll (Review) |
|
你好 @jujn 👋 我们最近在 AgentScope-Java 上比较活跃,提交了一些 issue 和 PR,也参与了几次 PR 评审(例如 #3519、#3520,都在合并前给出了 在学习
我们很想把评审这条路走扎实,也非常欢迎任何关于评审方式与标准的建议。谢谢! |
github 有时有 bug,Assignees 不了(点了没反应),所以评论 Assign to xx 也计入。另外,有些过于简单的PR是否完全没必要多 review 一次呢? |
|
感谢 @jujn 的说明!我们之前只看了 Assignees 字段,没意识到 关于第二点我们完全认同:评审的价值在于真正发现问题,而不是把每个 PR 都过一遍凑次数。像 #3519 这种一行改动,确实没必要单独 review。后续我们会更聚焦在改动较大、涉及并发 / 协议 / 兼容性等真正需要独立验证的 PR 上,尽量给出可复现的验证和具体意见,而不是走形式。 如果方便的话想请教一下:您更希望我们把评审精力放在哪些方向(某些模块 / 某类改动)?我们也好把力气用在刀刃上。谢谢! |
比较重要的功能/修复吧,比如 agent 核心执行链路 |


AgentScope-Java Version
2.0.5-SNAPSHOT
Description
Background
The E2B sandbox backend (
agentscope-extensions-sandbox-e2b) builds its data-plane (envd) address ashttps://<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-Portrequest headers — the same header-based routing the official E2B SDKs use (the official cloud itself serves envd traffic from the shared
sandbox.<domain>host, and offersE2B_SANDBOX_URLfor exactly this override).Purpose
Add an
envdSandboxUrloption — the equivalent of the official SDK'sE2B_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 gateway 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