@parcha/agentrun-pi 0.1.0-beta.8 → 0.1.0-beta.9
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.
|
@@ -54,8 +54,10 @@ async function withAdapterDiagnostic(stage, run) {
|
|
|
54
54
|
if (error.code === 'http') {
|
|
55
55
|
if (Number.isInteger(error.status) && error.status >= 100 && error.status <= 599)
|
|
56
56
|
diagnostic.status = error.status;
|
|
57
|
-
if (reason === 'max_tokens_exceeded')
|
|
57
|
+
if (reason === 'max_tokens_exceeded') {
|
|
58
58
|
diagnostic.reason = reason;
|
|
59
|
+
diagnostic.message = 'Jev refused the request: it exceeds the model\'s token budget. Send fewer or shorter items per request. No judgment was accepted; provider details are omitted.';
|
|
60
|
+
}
|
|
59
61
|
}
|
|
60
62
|
}
|
|
61
63
|
}
|
|
@@ -124,7 +126,7 @@ function localDiagnostic(error) {
|
|
|
124
126
|
&& stateBytes > maxStateBytes && maxStateBytes > 0)
|
|
125
127
|
return {
|
|
126
128
|
code: 'jev_state_too_large', stage, stateBytes, maxStateBytes,
|
|
127
|
-
message: `Jev state at ${stage} is ${stateBytes} UTF-8 bytes; configured host limit is ${maxStateBytes}. No request was sent. A sift
|
|
129
|
+
message: `Jev state at ${stage} is ${stateBytes} UTF-8 bytes; configured host limit is ${maxStateBytes}. No request was sent. A sift splits its items across requests only when the host sets maxStateBytesPerRequest; otherwise send less of each item or use per-item judgments without losing headers or qualifiers.`
|
|
128
130
|
};
|
|
129
131
|
if (reason === 'invalid_state' || reason === 'invalid_questions')
|
|
130
132
|
return { code: `jev_${reason}`, stage,
|
|
@@ -361,11 +363,36 @@ export class WorkflowExtensionService {
|
|
|
361
363
|
queue.shift()?.();
|
|
362
364
|
}
|
|
363
365
|
};
|
|
366
|
+
const rejectTrace = (error) => {
|
|
367
|
+
rejectedEvents++;
|
|
368
|
+
traceTruncated = true;
|
|
369
|
+
if (!signal.aborted) {
|
|
370
|
+
// Snapshot rejects unsafe/non-JSON values separately from resource bounds.
|
|
371
|
+
// Keep fail-closed cancellation; never echo values or arbitrary error text.
|
|
372
|
+
const diagnostic = error instanceof ExtensionServiceError && error.code === 'data'
|
|
373
|
+
? new ExtensionServiceError('trace_invalid_data', 'Workflow trace contains non-JSON data. Numbers must be finite; objects and arrays must be plain, acyclic and free of accessors or symbols.')
|
|
374
|
+
: error instanceof ExtensionServiceError && error.code === 'bounds'
|
|
375
|
+
? new ExtensionServiceError('limit', 'Workflow trace exceeded its JSON byte, depth or value-count limit.')
|
|
376
|
+
: new ExtensionServiceError('trace_capture_failed', 'Workflow trace capture failed. Unsafe event details are omitted.');
|
|
377
|
+
controller.abort(diagnostic);
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
const prepareEvent = (event) => {
|
|
381
|
+
if (closed)
|
|
382
|
+
return { type: event.type, label: event.label };
|
|
383
|
+
try {
|
|
384
|
+
return snapshot(event, this.limits.maxEventBytes);
|
|
385
|
+
}
|
|
386
|
+
catch (error) {
|
|
387
|
+
rejectTrace(error);
|
|
388
|
+
return undefined;
|
|
389
|
+
}
|
|
390
|
+
};
|
|
364
391
|
const onEvent = (event) => {
|
|
365
392
|
if (closed)
|
|
366
393
|
return;
|
|
367
394
|
try {
|
|
368
|
-
const clean = sanitize(
|
|
395
|
+
const clean = sanitize(event);
|
|
369
396
|
const size = Buffer.byteLength(JSON.stringify(clean));
|
|
370
397
|
if (size > this.limits.maxEventBytes)
|
|
371
398
|
throw new ExtensionServiceError('bounds', 'Workflow event exceeds its serialized byte limit.');
|
|
@@ -405,26 +432,17 @@ export class WorkflowExtensionService {
|
|
|
405
432
|
}
|
|
406
433
|
}
|
|
407
434
|
catch (error) {
|
|
408
|
-
|
|
409
|
-
traceTruncated = true;
|
|
410
|
-
if (!signal.aborted) {
|
|
411
|
-
// Snapshot rejects unsafe/non-JSON values separately from resource bounds.
|
|
412
|
-
// Keep fail-closed cancellation; never echo values or arbitrary error text.
|
|
413
|
-
const diagnostic = error instanceof ExtensionServiceError && error.code === 'data'
|
|
414
|
-
? new ExtensionServiceError('trace_invalid_data', 'Workflow trace contains non-JSON data. Numbers must be finite; objects and arrays must be plain, acyclic and free of accessors or symbols.')
|
|
415
|
-
: error instanceof ExtensionServiceError && error.code === 'bounds'
|
|
416
|
-
? new ExtensionServiceError('limit', 'Workflow trace exceeded its JSON byte, depth or value-count limit.')
|
|
417
|
-
: new ExtensionServiceError('trace_capture_failed', 'Workflow trace capture failed. Unsafe event details are omitted.');
|
|
418
|
-
controller.abort(diagnostic);
|
|
419
|
-
}
|
|
435
|
+
rejectTrace(error);
|
|
420
436
|
}
|
|
421
437
|
};
|
|
422
438
|
const sections = Object.entries(this.rubricSections);
|
|
423
439
|
const deps = {
|
|
424
|
-
signal, onEvent,
|
|
440
|
+
signal, onEvent, prepareEvent,
|
|
425
441
|
...(options.deps.skill ? { skill: options.deps.skill } : {}),
|
|
426
442
|
...(sections.length ? { sop: sections.map(([name, text]) => `## ${name}\n${text}`).join('\n\n') } : options.deps.sop ? { sop: options.deps.sop } : {}),
|
|
427
|
-
|
|
443
|
+
// Forward any set limit, so the interpreter rejects an invalid one rather than running without it.
|
|
444
|
+
...(options.deps.maxQuestionsPerRequest !== undefined ? { maxQuestionsPerRequest: options.deps.maxQuestionsPerRequest } : {}),
|
|
445
|
+
...(options.deps.maxStateBytesPerRequest !== undefined ? { maxStateBytesPerRequest: options.deps.maxStateBytesPerRequest } : {}),
|
|
428
446
|
...(options.deps.runNode ? { runNode: params => dispatch('agent', params.signal, () => withAdapterDiagnostic(params.label, () => options.deps.runNode({ ...params, tools: params.tools ?? [...this.allowedTools] })), true) } : {}),
|
|
429
447
|
...(options.deps.runJudge ? { runJudge: params => dispatch('judge', params.signal, () => withAdapterDiagnostic(params.label, () => options.deps.runJudge(params)), true) } : {}),
|
|
430
448
|
...(options.deps.runEffect ? { runEffect: params => dispatch('tool', params.signal, () => {
|
|
@@ -69,7 +69,7 @@ Typed questions answered by the host's judge in one request each: no tools, no s
|
|
|
69
69
|
- A question schema is a flat object. Each property's `description` is its question. A boolean yields a yes-probability; a string enum (at most 240 options, optional per-option `criteria`) yields a choice; an integer with `criteria`: [level descriptions] (2 to 10 levels, minimum 0, maximum the last level index) yields a score. Nothing else is a question.
|
|
70
70
|
- `judge`: a non-empty `state` map, `out` (a question schema) and `as`. The decoded value lands at `as`, the raw answers at `<as>$answers`.
|
|
71
71
|
- `pick`: `itemsPath`, `describe` (the option text per item, such as "{item.name}"), `instructions` (the one question) and `as`; `allowNone` adds a none-of-these option. The result is {index, item, none, option}.
|
|
72
|
-
- `sift`: `itemsPath`, `out` (a question schema asked of every item
|
|
72
|
+
- `sift`: `itemsPath`, `out` (a question schema asked of every item; the host splits the items across requests when they exceed its limits) and `as`. `keep` {path: a question id or <id>.confidence, never a choice, gte?} keeps passing items, in order, at `<as>.items`.
|
|
73
73
|
- `route`: a non-empty `state` map, `instructions` (the one question) and 2 to 240 named `branches`, each {criteria?, body}. `unsure` {branch: one of the branches, gte: a number in (0, 1]} takes that branch when the choice's confidence is below `gte`. `as` records the choice.
|
|
74
74
|
- A decoded boolean is true at yes-probability 0.5. To hold a different threshold, read `<as>$answers.answers.<id>.noul` in a code node.
|
|
75
75
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcha/agentrun-pi",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.9",
|
|
4
4
|
"description": "Pi extension for building, running and evaluating AgentRun workflows",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"@earendil-works/pi-ai": "0.87.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@parcha/agentrun-dsl": "0.1.0-beta.
|
|
39
|
-
"@parcha/agentrun-jev": "0.1.0-beta.
|
|
38
|
+
"@parcha/agentrun-dsl": "0.1.0-beta.9",
|
|
39
|
+
"@parcha/agentrun-jev": "0.1.0-beta.9",
|
|
40
40
|
"@earendil-works/pi-agent-core": "0.87.0",
|
|
41
41
|
"@earendil-works/pi-coding-agent": "0.87.0",
|
|
42
42
|
"@earendil-works/pi-tui": "0.87.0",
|