Skip to content

Commit 9ac0f30

Browse files
kapaleshreyasclaude
andcommitted
test(sandboxes): aggressive integration suite + fix TTL clamping direction
scripts/test-sandboxes.py — 33-test integration suite hitting a live server: - wire shape (validation, 404, 400, list, snapshot, ttl clamping) - multi-turn warmth (turn 2/3 measurably faster than cold turn 1) - context retention across turns (proves engine memory works) - 409 BUSY on concurrent chat, then recovery after first turn ends - DELETE mid-chat returns in <2s without deadlock - 3 concurrent sandboxes each retain their own private context - idle TTL reaps when no chat for the configured window - hard TTL fires even when idle would have kept it alive - boot_deadline + max_concurrent_429 documented as manual checks Result against api.clawagent.sh: 33/33 passed. Fix in resolveSandboxTtl: previously when idle > hard, the code clamped hard UP to idle (so idle=300s + hard=15s became hard=300s, which made the hard-TTL test fail and was generally confusing). The correct semantics, matching the user's intent of "dispose after X idle OR Y total, whichever fires first": hard cap is the authority, idle clamps DOWN to it. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent d4bc022 commit 9ac0f30

2 files changed

Lines changed: 406 additions & 3 deletions

File tree

examples/computeragent-server.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,9 +459,12 @@ function resolveSandboxTtl(
459459
if (idleRaw <= 0 || hardRaw <= 0) {
460460
throw new Error("idleTtlMs and ttlMs must be positive milliseconds");
461461
}
462-
const idleTtlMs = Math.min(idleRaw, idleMax);
463-
// Hard cap can never be SHORTER than idle (would make idle moot).
464-
const ttlMs = Math.min(Math.max(hardRaw, idleTtlMs), hardMax);
462+
// Hard cap is the authority. Idle gets clamped DOWN to it — a sandbox
463+
// can't be idle-alive longer than its absolute lifetime. This matches
464+
// the intuitive reading: "dispose after X idle OR after Y total,
465+
// whichever fires first."
466+
const ttlMs = Math.min(hardRaw, hardMax);
467+
const idleTtlMs = Math.min(idleRaw, idleMax, ttlMs);
465468
return { idleTtlMs, ttlMs };
466469
}
467470

0 commit comments

Comments
 (0)