agentscope-ai / agentscope-ai/agentscope-java

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

Aperta
#2,421 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
area/build area/core/memory area/extensions bug
Lingua principale
Java
Stelle
5.6k
Fork
1.3k
Merge medio
4g 12h
PR unite (30g)
77

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.