agentscope-ai / agentscope-ai/agentscope-java

DaytonaSandboxClient: Using snapshot to create sandbox fails because cpu/memory/disk default values are always sent

未关闭
#2,421 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
area/build area/core/memory area/extensions bug
主要语言
Java
星标
5.6k
派生
1.3k
平均合并
4 天 12 小时
30 天内合并 PR
77

描述

## Bug Description

When using `DaytonaHttp#createSandbox` with a `snapshot` parameter, the Daytona API returns a 400 error:

```
Cannot specify Sandbox resources when using a snapshot
```

The root cause is that `DaytonaSandboxClientOptions` defines non-null default values for `cpu`, `memory`, and `disk`, which are always included in the request body — even when a `snapshot` is specified. The Daytona API does not allow specifying resource parameters together with a snapshot.

## Steps to Reproduce

1. Create a `DaytonaSandboxClientOptions` with a `snapshot` value
2. Call `DaytonaHttp#createSandbox(options)`
3. The request fails with 400 Bad Request

## Expected Behavior

When `snapshot` is specified, the request body should NOT include `cpu`, `memory`, and `disk` fields.

## Actual Behavior

The request body always includes `cpu: 1`, `memory: 1`, `disk: 3` (the default values), causing the API to reject the request.

## Root Cause Analysis

In `DaytonaSandboxClientOptions`:
```java
private Integer cpu = 1;
private Integer memory = 1;
private Integer disk = 3;
```

In `DaytonaHttp#createSandbox`, these fields are always included when non-null. Since defaults are non-null, they are always serialized.

## Suggested Fix

**Option A**: Skip resource fields when `snapshot` is specified.
**Option B**: Change default values to `null`.

## Environment

- Library: `agentscope-extensions-sandbox-daytona`
- Daytona API: `https://app.daytona.io/api/sandbox`

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。