agentscope-ai / agentscope-ai/agentscope-java

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

Aberta
#2,421 2 comentários 0 reações 0 responsáveis Ver no GitHub
area/build area/core/memory area/extensions bug
Linguagem predominante
Java
Estrelas
5.6k
Forks
1.3k
Merge médio
4d 12h
PRs com merge (30d)
77

Descrição

## 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`

Guia de contribuição

Abrir o guia de contribuição

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.