@peakflo/agent-harness 0.2.25-rc.1 → 0.2.25
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.
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
*
|
|
5
5
|
* The harness is published on its own and does not depend on
|
|
6
6
|
* `@pf-workflo/core`, so it cannot import the server's helper. Keep the two in
|
|
7
|
-
* step; `
|
|
7
|
+
* step; the parity test in `__tests__/ingest-invalid-text.test.ts` runs both
|
|
8
|
+
* on one fixture table and fails if they disagree.
|
|
8
9
|
*
|
|
9
10
|
* The harness cleans every batch before `/ingest` so a NUL in a tool result
|
|
10
11
|
* cannot fail the batch even against a control plane that does not clean it.
|
|
@@ -608,6 +608,19 @@ export declare class SessionRunner {
|
|
|
608
608
|
* both sides agree on it; a limit only one side knows is not a limit.
|
|
609
609
|
*/
|
|
610
610
|
private flush;
|
|
611
|
+
/**
|
|
612
|
+
* THE FINAL INGEST WAS REFUSED (400/413/422). Send it again with less, so
|
|
613
|
+
* the turn is recorded and the lease released instead of waiting for the
|
|
614
|
+
* watchdog:
|
|
615
|
+
*
|
|
616
|
+
* 1. no parts, same turn metadata and model messages;
|
|
617
|
+
* 2. no parts, no model messages, only the turn's id, times, stop
|
|
618
|
+
* reason and cost (what the lease release and billing need).
|
|
619
|
+
*
|
|
620
|
+
* Each step that is refused the same way is logged and the next is tried.
|
|
621
|
+
* Anything else, or a refusal of the last step, is thrown as before.
|
|
622
|
+
*/
|
|
623
|
+
private sendRefusedFinal;
|
|
611
624
|
/**
|
|
612
625
|
* Remove NUL and replace lone UTF-16 surrogates before a batch leaves this
|
|
613
626
|
* runner: Postgres refuses both, and one such character in a tool result
|
|
@@ -2563,10 +2563,10 @@ class SessionRunner {
|
|
|
2563
2563
|
`final=${chunkFinal} partIds=${partIds.slice(0, 20).join(',')}` +
|
|
2564
2564
|
(partIds.length > 20 ? ',…' : '') +
|
|
2565
2565
|
' (the parts remain in the local transcript store)');
|
|
2566
|
-
// The FINAL ingest also releases the lease and records the turn
|
|
2567
|
-
//
|
|
2568
|
-
if (chunkFinal
|
|
2569
|
-
await this.
|
|
2566
|
+
// The FINAL ingest also releases the lease and records the turn, so
|
|
2567
|
+
// it must still get through. See `sendRefusedFinal`.
|
|
2568
|
+
if (chunkFinal) {
|
|
2569
|
+
await this.sendRefusedFinal(sessionId, chunkTurn, chunkMessages);
|
|
2570
2570
|
}
|
|
2571
2571
|
continue;
|
|
2572
2572
|
}
|
|
@@ -2579,6 +2579,49 @@ class SessionRunner {
|
|
|
2579
2579
|
}
|
|
2580
2580
|
}
|
|
2581
2581
|
}
|
|
2582
|
+
/**
|
|
2583
|
+
* THE FINAL INGEST WAS REFUSED (400/413/422). Send it again with less, so
|
|
2584
|
+
* the turn is recorded and the lease released instead of waiting for the
|
|
2585
|
+
* watchdog:
|
|
2586
|
+
*
|
|
2587
|
+
* 1. no parts, same turn metadata and model messages;
|
|
2588
|
+
* 2. no parts, no model messages, only the turn's id, times, stop
|
|
2589
|
+
* reason and cost (what the lease release and billing need).
|
|
2590
|
+
*
|
|
2591
|
+
* Each step that is refused the same way is logged and the next is tried.
|
|
2592
|
+
* Anything else, or a refusal of the last step, is thrown as before.
|
|
2593
|
+
*/
|
|
2594
|
+
async sendRefusedFinal(sessionId, turn, modelMessages) {
|
|
2595
|
+
const minimal = turn
|
|
2596
|
+
? {
|
|
2597
|
+
turnId: turn.turnId,
|
|
2598
|
+
startedAt: turn.startedAt,
|
|
2599
|
+
finishedAt: turn.finishedAt,
|
|
2600
|
+
stopReason: turn.stopReason,
|
|
2601
|
+
// Kept: the control plane bills the turn from it.
|
|
2602
|
+
costUsd: turn.costUsd
|
|
2603
|
+
}
|
|
2604
|
+
: undefined;
|
|
2605
|
+
const attempts = [
|
|
2606
|
+
{ label: 'without-parts', turn, modelMessages },
|
|
2607
|
+
{ label: 'minimal-turn', turn: minimal, modelMessages: undefined }
|
|
2608
|
+
];
|
|
2609
|
+
for (let i = 0; i < attempts.length; i += 1) {
|
|
2610
|
+
const attempt = attempts[i];
|
|
2611
|
+
try {
|
|
2612
|
+
await this.deps.ingest(sessionId, [], attempt.turn, true, attempt.modelMessages);
|
|
2613
|
+
return;
|
|
2614
|
+
}
|
|
2615
|
+
catch (error) {
|
|
2616
|
+
const status = errorStatus(error);
|
|
2617
|
+
const refused = status === 400 || status === 413 || status === 422;
|
|
2618
|
+
if (!refused || i === attempts.length - 1)
|
|
2619
|
+
throw error;
|
|
2620
|
+
this.logger.error(`[SessionRunner] ingest-final-refused session=${sessionId} status=${status} ` +
|
|
2621
|
+
`code=${errorCode(error) ?? '(none)'} attempt=${attempt.label}`);
|
|
2622
|
+
}
|
|
2623
|
+
}
|
|
2624
|
+
}
|
|
2582
2625
|
/**
|
|
2583
2626
|
* Remove NUL and replace lone UTF-16 surrogates before a batch leaves this
|
|
2584
2627
|
* runner: Postgres refuses both, and one such character in a tool result
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peakflo/agent-harness",
|
|
3
|
-
"version": "0.2.25
|
|
3
|
+
"version": "0.2.25",
|
|
4
4
|
"description": "Headless Peakflo coding-agent harness. One codebase, three hosting modes: a Daytona cloud sandbox, a customer VM, and the 20x desktop.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|