Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix(dify-agent): use E2B traffic access header (#40891)

盐粒 Yanlic267e73ca660
diff --git a/dify-agent/src/dify_agent/runtime_backend/e2b.py b/dify-agent/src/dify_agent/runtime_backend/e2b.py
index 376a43a54b7..3140391eb13 100644
--- a/dify-agent/src/dify_agent/runtime_backend/e2b.py
+++ b/dify-agent/src/dify_agent/runtime_backend/e2b.py
@@ -312,13 +312,13 @@ class E2BExecutionBindingBackend:
raise BindingAcquireError("E2B sandbox did not provide a traffic access token")
http_client = httpx.AsyncClient(
base_url=entrypoint,
- headers={"X-Access-Token": traffic_token},
+ headers={"e2b-traffic-access-token": traffic_token},
follow_redirects=True,
timeout=httpx.Timeout(60.0),
)
# Explicit token="" prevents process-level SHELLCTL_AUTH_TOKEN fallback;
- # E2B port access is authenticated only by X-Access-Token above.
+ # E2B port access is authenticated only by e2b-traffic-access-token above.
def client_factory() -> ShellctlClientProtocol:
from shellctl.client import ShellctlClient
diff --git a/dify-agent/tests/local/dify_agent/runtime_backend/test_e2b.py b/dify-agent/tests/local/dify_agent/runtime_backend/test_e2b.py
index 60b09224344..9dcddff2b8c 100644
--- a/dify-agent/tests/local/dify_agent/runtime_backend/test_e2b.py
+++ b/dify-agent/tests/local/dify_agent/runtime_backend/test_e2b.py
@@ -336,7 +336,8 @@ async def test_e2b_acquire_retries_transient_shellctl_failures_until_ready(
def handler(request: httpx.Request) -> httpx.Response:
nonlocal attempts
attempts += 1
- assert request.headers["X-Access-Token"] == "traffic-token"
+ assert request.headers["e2b-traffic-access-token"] == "traffic-token"
+ assert "X-Access-Token" not in request.headers
assert "Authorization" not in request.headers
if attempts == 1:
raise httpx.ReadTimeout("shellctl starting", request=request)