@theoremjs/agents 0.3.4-next.795.g054c5db → 0.3.4-next.801.g4c28a4b
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.
|
@@ -435,6 +435,9 @@ held) {
|
|
|
435
435
|
return 'pass';
|
|
436
436
|
if (!answersByTool(flow.currentGen))
|
|
437
437
|
return 'pass';
|
|
438
|
+
// why: A rewrite that gives no answer leaves the reply it was fixing; the validation gate removes the refused items.
|
|
439
|
+
if (flow.pendingItemFix)
|
|
440
|
+
return 'pass';
|
|
438
441
|
const validation = profileTurnOutputs(profile)?.validation;
|
|
439
442
|
if (validation && flow.currentAttempt < (validation.maxRetries ?? 0)) {
|
|
440
443
|
const rejection = labelText('structured.answer_missing', { tool: ANSWER_TOOL }, profile.labels);
|
|
@@ -369,8 +369,10 @@ function buildLiveSession(args) {
|
|
|
369
369
|
},
|
|
370
370
|
};
|
|
371
371
|
let cycle = 'idle';
|
|
372
|
-
/**
|
|
373
|
-
let
|
|
372
|
+
/** An interrupt ended the reply; its `turnComplete` is still to come. */
|
|
373
|
+
let cutOff = false;
|
|
374
|
+
/** Input landed while this cycle was already open: if an interrupt ends it, that input opens the next. */
|
|
375
|
+
let ingressInCycle = false;
|
|
374
376
|
let cycleStep = 0;
|
|
375
377
|
/** What this cycle's tool results read from outside the host; a cycle starts clean, as a turn does. */
|
|
376
378
|
let cycleTaint;
|
|
@@ -634,9 +636,12 @@ function buildLiveSession(args) {
|
|
|
634
636
|
await runCycleStage('post_turn', { stop });
|
|
635
637
|
};
|
|
636
638
|
const openCycleIfNeeded = async () => {
|
|
637
|
-
if (cycle === 'open')
|
|
639
|
+
if (cycle === 'open') {
|
|
640
|
+
ingressInCycle = true;
|
|
638
641
|
return { aborted: false };
|
|
642
|
+
}
|
|
639
643
|
cycle = 'open';
|
|
644
|
+
ingressInCycle = false;
|
|
640
645
|
cycleStep += 1;
|
|
641
646
|
cycleTaint = undefined;
|
|
642
647
|
destinations.remote.clear();
|
|
@@ -895,15 +900,12 @@ function buildLiveSession(args) {
|
|
|
895
900
|
// why: An abort only drops what the gate held; there is no check to time.
|
|
896
901
|
if (item.turnPhase !== 'abort')
|
|
897
902
|
trace.outboundTime(performance.now() - gateStart);
|
|
898
|
-
if (hostEvents.some(isGenerationDone))
|
|
899
|
-
reply = 'generated';
|
|
900
903
|
// why: A close after a cut-off reply is not a finish, and the next cycle may already be open.
|
|
901
|
-
const closesCutOff = item.turnPhase === 'complete' &&
|
|
904
|
+
const closesCutOff = item.turnPhase === 'complete' && cutOff;
|
|
902
905
|
if (item.turnPhase === 'complete')
|
|
903
|
-
|
|
906
|
+
cutOff = false;
|
|
904
907
|
if (item.turnPhase === 'abort') {
|
|
905
|
-
|
|
906
|
-
reply = cut ? 'cut_off' : 'open';
|
|
908
|
+
cutOff = hostEvents.some((ev) => ev.type === 'done' && ev.interrupted);
|
|
907
909
|
}
|
|
908
910
|
for (const ev of gated) {
|
|
909
911
|
if (ev.type === 'guardrail')
|
|
@@ -933,6 +935,10 @@ function buildLiveSession(args) {
|
|
|
933
935
|
for await (const ev of endCycleAroundDone(boundaryDone)) {
|
|
934
936
|
yield projectGuardrailTurnEvent(stampDone(ev), includeMatch);
|
|
935
937
|
}
|
|
938
|
+
// why: A barge-in reaches the model before its `interrupted` reaches us, so the reply
|
|
939
|
+
// to it comes with no ingress left to open the cycle it belongs to.
|
|
940
|
+
if (interrupted && ingressInCycle)
|
|
941
|
+
await withIngress(() => openCycleIfNeeded().then(() => { }));
|
|
936
942
|
yield* drainPendingHostEvents(pendingHostEvents);
|
|
937
943
|
}
|
|
938
944
|
else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theoremjs/agents",
|
|
3
|
-
"version": "0.3.4-next.
|
|
3
|
+
"version": "0.3.4-next.801.g4c28a4b",
|
|
4
4
|
"description": "A flat TypeScript agent kernel for typed profiles, deterministic turn execution, registered tools, provider adapters, guardrails, and host-injected traces.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|