Skip to content

Commit 81cca58

Browse files
authored
Merge pull request #68 from Alibaba-Agent-Sandbox/fix/provider-preflight-20261018
fix(providers): enforce native PTY before context or wire access
2 parents 5a99f0f + 841dae8 commit 81cca58

8 files changed

Lines changed: 82 additions & 0 deletions

File tree

‎.agents/README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,5 @@ Builtin transport: [direct HTTP](notes/implemented/architecture/2026-10-18-nativ
7777
- [Final provider convergence acceptance](evidence/verify/2026-10-18-provider-convergence-acceptance.md)
7878

7979
- [Provider-owned metadata follow-up](evidence/verify/2026-10-18-provider-owned-metadata-followup.md)
80+
81+
- [Provider preflight](notes/proposed/feature/2026-10-18-provider-preflight.md) · [verification](evidence/verify/2026-10-18-provider-preflight.md)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Native provider preflight verification — 2026-10-18
2+
3+
Result: scoped local PASS; exact-head full hosted matrix pending.
4+
5+
Base5a99f0fa; Python3.13 with the locked development environment and actual current
6+
client/server sources selected before imports.
7+
8+
- Regression before fix:1 FAIL (session.url accessed on absent context); after:
9+
1 PASS with ProviderFeatureNotSupportedError before context or wire access.
10+
- Full maintained client2180 PASS/24 SKIP. Lint/format/typecheck PASS for both packages.
11+
- Actual local Express suite112 PASS/2 Volume opt-in SKIP/2 slow DESELECT/1 existing
12+
KI-009 XFAIL (Jupyter404 and documented shell fallback). No assertion weakened.
13+
- Task tracker cleanup executed; independent complete read-only list confirmed zero
14+
current-date E2E-tagged sandboxes. No unrelated resource was deleted.
15+
- Server code/distribution metadata are unchanged; full hosted Python3.10/3.11/3.12
16+
client/server/package matrix is required before merge. No cloud/model Actions run.
17+
- Final owner record/link/hygiene checks follow preparation.
18+
19+
The standard migration and successful account-dependent pause/snapshot acceptance
20+
remain separate in PR47. This patch enables no new capability or package release.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Decision: Check native PTY before terminal context or wire access
2+
3+
Status: proposed
4+
5+
## Problem
6+
The native Express terminal implementation did not enforce its declared PTY
7+
feature before touching the supplied session and wire adapter. The fix was trapped
8+
in the larger conditional migration branch.
9+
10+
## Decision
11+
Apply the provider declaration check at the start of open_terminal. Preserve the
12+
existing native public API and available Express behavior independently of migration.
13+
14+
## API Design
15+
Undeclared PTY raises ProviderFeatureNotSupportedError before context or network
16+
access. Valid declared terminal calls continue through the existing adapter.
17+
18+
## Alternatives considered
19+
Waiting for unrelated snapshot/standard frontend prerequisites leaves the defect
20+
on main. Failing later with attribute or transport errors loses the typed contract.
21+
22+
## Dependencies
23+
Current accepted main5a99f0fa. Related owner migration issue:
24+
https://github.com/Alibaba-Agent-Sandbox/python-sdk/issues/36
25+
Companion CLI issue https://github.com/Alibaba-Agent-Sandbox/agent-sandbox/issues/33.
26+
27+
## Test Strategy
28+
Observe failing unguarded access, verify the feature error, run all maintained client
29+
checks and real available Express lifecycle/terminal/server coverage and cleanup.
30+
31+
## Acceptance criteria
32+
Regression, maintained client checks and real available backend acceptance pass;
33+
latest full hosted matrix passes before normal merge. No conditional feature is enabled.
34+
35+
## Evidence
36+
[Verification](../../../evidence/verify/2026-10-18-provider-preflight.md).

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
1010

1111
### Fixed
1212

13+
- Reject undeclared native Express PTY before session/context or wire access.
14+
1315
- Reconcile provider isolation with accepted native transport, explicit-key authentication and retired-module cleanup; preserve canonical compatibility aliases and pure configuration metadata.
1416

1517
### Documentation

‎client-sdk/src/agent_sandbox/providers/alicloud_express/provider.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ async def prepare_session(
156156
return binding
157157

158158
async def open_terminal(self, sandbox: Any, **options: Any) -> Any:
159+
self.require("pty")
159160
from agent_sandbox.providers.shared.e2b.terminal import TerminalSession
160161

161162
return await TerminalSession.create(
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"""Declared absence must refuse PTY before touching session or wire state."""
2+
3+
import pytest
4+
5+
from agent_sandbox.models.errors import ProviderFeatureNotSupportedError
6+
from agent_sandbox.providers.alicloud_express.provider import AlicloudExpressProvider
7+
8+
9+
async def test_native_terminal_checks_feature_before_session_access() -> None:
10+
provider = AlicloudExpressProvider()
11+
provider.features = provider.features - {"pty"}
12+
with pytest.raises(ProviderFeatureNotSupportedError):
13+
await provider.open_terminal(None)

‎docs/en/guide/providers.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,3 +400,8 @@ A package can also publish an entry point in the group `agent_sandbox.providers`
400400
- [Configuration reference](../reference/configuration.md) — names, aliases, precedence
401401
- [Authentication](authentication.md)
402402
- [Design: providers and credentials](../design/providers-and-credentials.md)
403+
404+
Native terminal access enforces the provider's `pty` declaration before reading
405+
session context or starting its wire adapter. An unsupported terminal returns the
406+
typed provider feature error; declaring a client method does not enable an account
407+
or function capability.

‎docs/zh/guide/providers.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,3 +395,6 @@ register_provider(MyProvider())
395395
- [配置参考](../reference/configuration.md) —— 名称、别名、优先级
396396
- [认证详解](authentication.md)
397397
- [设计:提供方与凭证](../design/providers-and-credentials.md)
398+
399+
原生终端在读取会话上下文或启动协议适配器前检查 Provider 的 `pty` 声明。
400+
不支持时返回明确的能力错误;客户端存在方法并不代表账号或函数已开通该能力。

0 commit comments

Comments
 (0)