Agent Sandbox Registry

python-sdk

Decision: Dual Authentication Mode (API Key + AK/SK)

无中文版

.agents/notes/implemented/architecture/2026-09-02-dual-auth-mode.md

Decision: Dual Authentication Mode (API Key + AK/SK)

Status: implemented

Problem

Users need to authenticate with the sandbox service. E2B uses a single API Key, but Alibaba Cloud ecosystem users typically use AccessKey ID/Secret (AK/SK).

Decision

Support both authentication modes: 1. API Key (primary): SANDBOX_API_KEY env var → X-API-KEY header for Platform API 2. AK/SK (extension): ALICLOUD_ACCESS_KEY_ID + ALICLOUD_ACCESS_KEY_SECRET → exchange for temporary API Key (TTL=3600s, auto-refresh 5min before expiry)

After sandbox creation, envd API uses envdAccessToken returned in create response, sent as X-Access-Token header.

API Design

# Credential resolution (transport/auth.py)
# 1. SANDBOX_API_KEY -> X-API-KEY header (primary)
# 2. ALICLOUD_ACCESS_KEY_ID + ALICLOUD_ACCESS_KEY_SECRET
#      -> exchange for temporary API key (TTL=3600s, auto-refresh 5min before expiry)
# Post-create: envdAccessToken from the create response -> X-Access-Token header for envd API

Alternatives considered

Dependencies

Test Strategy

Acceptance criteria

Consequences