agentscope-ai / agentscope-ai/agentscope

[Bug]: Lack of a lifecycle recovery mechanism after sandbox expiration.

未關閉 適合新手
#2,483 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Python
星號
31.6k
分支
3.5k
平均合併
1 天 16 小時
30 天內合併 PR
103

描述

### Prerequisites

- [x] I have searched the existing [issues](https://github.com/agentscope-ai/agentscope/issues) and [discussions](https://github.com/agentscope-ai/agentscope/discussions), and this is not a duplicate.
- [x] This is a bug, not a usage question. (For questions, please use [Discussions](https://github.com/agentscope-ai/agentscope/discussions/new?category=general) instead.)

### Background / Description

- `OpenSandboxWorkspaceManager.get_workspace()` first checks the in-memory cache;
- If there is a cache hit, it returns the existing `OpenSandboxWorkspace` directly without checking if the Sandbox is still active;
- `OpenSandboxWorkspace.initialize()` is executed only upon a cache miss;
- During initialization, it queries for the same `workspace.id`:
- If found in `Running` state: reconnect;
- If found in `Paused` state: call `resume()`;
- If not found: create a new Sandbox.

- `/D:/a_bot/agentscope/src/agentscope/app/workspace_manager/_opensandbox_workspace_manager.py:247` Returns immediately on cache hit;
- `/D:/a_bot/agentscope/src/agentscope/workspace/_opensandbox/_opensandbox_workspace.py:159` Searches for an existing Sandbox during initialization;
- `/D:/a_bot/agentscope/src/agentscope/workspace/_opensandbox/_opensandbox_workspace.py:276` Connects to or resumes the Sandbox if it is `Running` or `Paused`.

Consequently, the current behavior is:
Sandbox TTL expires and it is destroyed

The workspace remains in the cache

The next message continues using the old connection

`httpx.ConnectError`

Automatic recreation or resumption occurs only if one of the following happens:

- The AgentScope process restarts;
- The workspace is cleared from the manager's idle cache;
- The workspace is manually closed and re-initialized;
- Code is explicitly added to handle reconnection/recreation after a connection failure.

Image

### Error Messages

```shell
The conversation will fail in 5 minutes.
```

### Steps to Reproduce

OPEN_SANDBOX_REQUEST_TIMEOUT=600
OPEN_SANDBOX_TIMEOUT_SECONDS=300

### Environment

- AgentScope Version:
- Python Version:
- OS:windows

貢獻指南

開啟貢獻指南

研究方向

Read `src/agentscope/app/workspace_manager/_opensandbox_workspace_manager.py` around line 247 where `get_workspace()` returns a cached `OpenSandboxWorkspace` directly. Then inspect `src/agentscope/workspace/_opensandbox/_opensandbox_workspace.py` lines 159 and 276 to see how `initialize()` handles Running/Paused state recovery. No tests are referenced; reproduce with the provided timeout settings and confirm expired sandboxes are recreated or resumed before continuing instead of reusing a stale cache entry that triggers `httpx.ConnectError`.

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
backend
Issue 類型
缺陷
難度
2/5
預估耗時
1-3 小時
活躍度
活躍
描述清晰度
描述清楚
新手友好度
70/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。