@vellumai/assistant 0.10.10-dev.202607210140.cb3a413 → 0.10.10-dev.202607210310.d95be07
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/workflows/sandbox.test.ts +22 -13
package/package.json
CHANGED
|
@@ -202,38 +202,47 @@ describe("createWorkflowSandbox — CPU guard", () => {
|
|
|
202
202
|
).rejects.toThrow(WorkflowResourceError);
|
|
203
203
|
});
|
|
204
204
|
|
|
205
|
+
// Margins for the two long-await tests below. The host await must exceed the
|
|
206
|
+
// deadline so the reset is load-bearing — without it, the script resumes
|
|
207
|
+
// against an already-expired guard and trips. The deadline itself leaves a
|
|
208
|
+
// full second of post-resume headroom: on shared CI runners, CPU contention
|
|
209
|
+
// can stall the resume path for hundreds of milliseconds, and that stall
|
|
210
|
+
// counts against the contiguous-CPU deadline.
|
|
211
|
+
const LONG_HOST_AWAIT_MS = 1500;
|
|
212
|
+
const LONG_AWAIT_DEADLINE_MS = 1000;
|
|
213
|
+
|
|
205
214
|
test("a genuinely long host call does not trip the deadline (latency excused)", async () => {
|
|
206
|
-
// A single host call whose await
|
|
207
|
-
//
|
|
208
|
-
//
|
|
215
|
+
// A single host call whose await exceeds the deadline must NOT trip: the
|
|
216
|
+
// reset excuses real leaf/agent latency. With the reset gated on a 50ms
|
|
217
|
+
// threshold, this call still resets.
|
|
209
218
|
const sandbox = createWorkflowSandbox({
|
|
210
219
|
hostFunctions: {
|
|
211
220
|
slow: async () => {
|
|
212
|
-
await new Promise((r) => setTimeout(r,
|
|
221
|
+
await new Promise((r) => setTimeout(r, LONG_HOST_AWAIT_MS));
|
|
213
222
|
return "ok";
|
|
214
223
|
},
|
|
215
224
|
},
|
|
216
|
-
interruptDeadlineMs:
|
|
225
|
+
interruptDeadlineMs: LONG_AWAIT_DEADLINE_MS,
|
|
217
226
|
});
|
|
218
227
|
const result = await sandbox.run(`return slow();`, null);
|
|
219
228
|
expect(result).toBe("ok");
|
|
220
229
|
});
|
|
221
230
|
|
|
222
231
|
test("a host call that REJECTS after a long await still resets the deadline (catch survives)", async () => {
|
|
223
|
-
// A leaf that fails after a
|
|
224
|
-
//
|
|
225
|
-
//
|
|
226
|
-
//
|
|
227
|
-
//
|
|
228
|
-
//
|
|
232
|
+
// A leaf that fails after a long round-trip must not leave the script's
|
|
233
|
+
// catch block resuming against an already-expired CPU deadline. The
|
|
234
|
+
// reject-path reset (finally) excuses the awaited latency on failure too,
|
|
235
|
+
// so the catch — which does enough work to hit an interrupt check — runs
|
|
236
|
+
// instead of being killed as a WorkflowResourceError. Without the reset,
|
|
237
|
+
// this run rejects.
|
|
229
238
|
const sandbox = createWorkflowSandbox({
|
|
230
239
|
hostFunctions: {
|
|
231
240
|
slowFail: async () => {
|
|
232
|
-
await new Promise((r) => setTimeout(r,
|
|
241
|
+
await new Promise((r) => setTimeout(r, LONG_HOST_AWAIT_MS));
|
|
233
242
|
throw new Error("leaf failed");
|
|
234
243
|
},
|
|
235
244
|
},
|
|
236
|
-
interruptDeadlineMs:
|
|
245
|
+
interruptDeadlineMs: LONG_AWAIT_DEADLINE_MS,
|
|
237
246
|
});
|
|
238
247
|
const result = await sandbox.run(
|
|
239
248
|
`try {
|