omnius 1.0.550 → 1.0.551
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/dist/index.js +437 -459
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/prompts/agentic/system-large.md +17 -714
- package/prompts/agentic/system-medium.md +17 -276
- package/prompts/agentic/system-small.md +17 -138
package/dist/index.js
CHANGED
|
@@ -571719,48 +571719,44 @@ function ago(ms) {
|
|
|
571719
571719
|
const h = Math.floor(m2 / 60);
|
|
571720
571720
|
return `${h}h ago`;
|
|
571721
571721
|
}
|
|
571722
|
-
function computeNextActionHint(reconciled, recentFailures,
|
|
571723
|
-
if (focusDirective?.requiredNextAction) {
|
|
571724
|
-
const reason = focusDirective.reason ? ` Reason: ${focusDirective.reason.slice(0, 180)}.` : "";
|
|
571725
|
-
return `Active recovery directive requires ${focusDirective.requiredNextAction}.${reason} Follow that before completion or unrelated work.`;
|
|
571726
|
-
}
|
|
571722
|
+
function computeNextActionHint(reconciled, recentFailures, _focusDirective) {
|
|
571727
571723
|
if (recentFailures.length > 0) {
|
|
571728
571724
|
const first2 = recentFailures[0];
|
|
571729
|
-
return `
|
|
571725
|
+
return `Unresolved failure: "${first2.stem}" (${first2.attempts} attempt${first2.attempts === 1 ? "" : "s"}).`;
|
|
571730
571726
|
}
|
|
571731
571727
|
const inProgress = reconciled.find((t2) => t2.reconciled === "in_progress");
|
|
571732
571728
|
if (inProgress)
|
|
571733
|
-
return `
|
|
571729
|
+
return `In-progress plan item: "${inProgress.content.slice(0, 100)}".`;
|
|
571734
571730
|
const claimedMissing = reconciled.filter((t2) => t2.reconciled === "claimed_missing");
|
|
571735
571731
|
if (claimedMissing.length > 0) {
|
|
571736
571732
|
const first2 = claimedMissing[0];
|
|
571737
571733
|
const missing = first2.artifactCheck?.find((c9) => c9.reason === "missing")?.path;
|
|
571738
|
-
return `
|
|
571734
|
+
return `Plan/disk mismatch: completed todo "${first2.content.slice(0, 60)}" claims missing ${missing ?? "artifact"}.`;
|
|
571739
571735
|
}
|
|
571740
571736
|
const claimedEmpty = reconciled.filter((t2) => t2.reconciled === "claimed_empty");
|
|
571741
571737
|
if (claimedEmpty.length > 0) {
|
|
571742
571738
|
const first2 = claimedEmpty[0];
|
|
571743
|
-
return `
|
|
571739
|
+
return `Plan/disk mismatch: completed todo "${first2.content.slice(0, 60)}" declares an empty artifact.`;
|
|
571744
571740
|
}
|
|
571745
571741
|
const claimedNoProof = reconciled.filter((t2) => t2.reconciled === "claimed_no_proof");
|
|
571746
571742
|
if (claimedNoProof.length > 0) {
|
|
571747
571743
|
const first2 = claimedNoProof[0];
|
|
571748
|
-
return `
|
|
571744
|
+
return `Plan evidence gap: completed todo "${first2.content.slice(0, 80)}" has no declared on-disk evidence.`;
|
|
571749
571745
|
}
|
|
571750
571746
|
const pending2 = reconciled.filter((t2) => t2.reconciled === "pending");
|
|
571751
571747
|
if (pending2.length > 0) {
|
|
571752
571748
|
const first2 = pending2[0];
|
|
571753
|
-
return `
|
|
571749
|
+
return `Pending plan item: "${first2.content.slice(0, 100)}".`;
|
|
571754
571750
|
}
|
|
571755
571751
|
const completedUnverified = reconciled.filter((t2) => t2.reconciled === "completed_unverified");
|
|
571756
571752
|
if (completedUnverified.length > 0) {
|
|
571757
571753
|
const first2 = completedUnverified[0];
|
|
571758
|
-
return `
|
|
571754
|
+
return `Verification evidence is absent for completed todo: ${first2.rationale}`;
|
|
571759
571755
|
}
|
|
571760
571756
|
if (reconciled.length === 0) {
|
|
571761
|
-
return `No declared plan items are available
|
|
571757
|
+
return `No declared plan items are available.`;
|
|
571762
571758
|
}
|
|
571763
|
-
return `Declared plan items have no visible gaps
|
|
571759
|
+
return `Declared plan items have no visible disk gaps in this snapshot.`;
|
|
571764
571760
|
}
|
|
571765
571761
|
function regenerate(opts) {
|
|
571766
571762
|
const startMs = Date.now();
|
|
@@ -571855,22 +571851,11 @@ function regenerate(opts) {
|
|
|
571855
571851
|
}
|
|
571856
571852
|
}
|
|
571857
571853
|
lines.push(``);
|
|
571858
|
-
if (opts.focusDirective?.requiredNextAction) {
|
|
571859
|
-
lines.push(`ACTIVE RECOVERY DIRECTIVE:`);
|
|
571860
|
-
lines.push(` required_next_action=${opts.focusDirective.requiredNextAction}`);
|
|
571861
|
-
if (opts.focusDirective.state) {
|
|
571862
|
-
lines.push(` state=${opts.focusDirective.state}`);
|
|
571863
|
-
}
|
|
571864
|
-
if (opts.focusDirective.reason) {
|
|
571865
|
-
lines.push(` reason=${opts.focusDirective.reason.slice(0, 240)}`);
|
|
571866
|
-
}
|
|
571867
|
-
lines.push(``);
|
|
571868
|
-
}
|
|
571869
571854
|
const nextActionHint = computeNextActionHint(reconciled, opts.recentFailures, opts.focusDirective);
|
|
571870
|
-
lines.push(`
|
|
571855
|
+
lines.push(`PLAN / FAILURE DIAGNOSTIC:`);
|
|
571871
571856
|
lines.push(` ${nextActionHint}`);
|
|
571872
571857
|
lines.push(``);
|
|
571873
|
-
lines.push(`
|
|
571858
|
+
lines.push(`Snapshot scope: workspace scan, reconciled plan, and unresolved failures at generation time. Prior world-state snapshots are replaced on regeneration.`);
|
|
571874
571859
|
lines.push(`</world-state>`);
|
|
571875
571860
|
const block = lines.join("\n");
|
|
571876
571861
|
return {
|
|
@@ -572715,35 +572700,8 @@ ${item.outputPreview ?? ""}`));
|
|
|
572715
572700
|
return directive;
|
|
572716
572701
|
}
|
|
572717
572702
|
function renderDirectiveAsMessage(d2) {
|
|
572718
|
-
|
|
572719
|
-
|
|
572720
|
-
}
|
|
572721
|
-
const lines = [];
|
|
572722
|
-
lines.push(`[STUCK-STATE META-ANALYZER — REG-49]`);
|
|
572723
|
-
lines.push(``);
|
|
572724
|
-
lines.push(`A meta-analyzer sub-agent reviewed the recent tool-call pattern, the`);
|
|
572725
|
-
lines.push(`current world state, and the plan; it produced a single concrete`);
|
|
572726
|
-
lines.push(`unblocking action for you to take.`);
|
|
572727
|
-
lines.push(``);
|
|
572728
|
-
lines.push(`DIAGNOSIS: ${d2.diagnosis}`);
|
|
572729
|
-
lines.push(``);
|
|
572730
|
-
lines.push(`STOP DOING (anti-pattern): ${d2.anti_pattern}`);
|
|
572731
|
-
lines.push(``);
|
|
572732
|
-
lines.push(`DO NEXT:`);
|
|
572733
|
-
lines.push(` Tool: ${d2.next_action.tool}`);
|
|
572734
|
-
const argsJson = JSON.stringify(d2.next_action.args_seed, null, 2);
|
|
572735
|
-
lines.push(` Args:`);
|
|
572736
|
-
for (const ln of argsJson.split("\n"))
|
|
572737
|
-
lines.push(` ${ln}`);
|
|
572738
|
-
lines.push(` Rationale: ${d2.next_action.rationale}`);
|
|
572739
|
-
lines.push(``);
|
|
572740
|
-
lines.push(`AFTER THE ACTION, verify with: ${d2.verification}`);
|
|
572741
|
-
lines.push(``);
|
|
572742
|
-
lines.push(`This directive comes from a meta-analysis of YOUR recent activity. Treat`);
|
|
572743
|
-
lines.push(`the args as a bounded recommendation, not permission to invent a target.`);
|
|
572744
|
-
lines.push(`If its evidence is stale or insufficient, first refresh the cited target`);
|
|
572745
|
-
lines.push(`or run the listed verification; do not repeat the anti-pattern.`);
|
|
572746
|
-
return lines.join("\n");
|
|
572703
|
+
void d2;
|
|
572704
|
+
return "";
|
|
572747
572705
|
}
|
|
572748
572706
|
async function runStuckAnalyzer(opts) {
|
|
572749
572707
|
const startMs = Date.now();
|
|
@@ -573121,42 +573079,8 @@ function parseFrameVerdict(rawResponse) {
|
|
|
573121
573079
|
};
|
|
573122
573080
|
}
|
|
573123
573081
|
function renderVerdictAsMessage(v) {
|
|
573124
|
-
|
|
573125
|
-
|
|
573126
|
-
if (v.verdict === "continue")
|
|
573127
|
-
return "";
|
|
573128
|
-
const lines = [];
|
|
573129
|
-
lines.push(`[PROBLEM-FRAME VALIDATION — REG-51 — ${v.verdict.toUpperCase()}]`);
|
|
573130
|
-
lines.push(``);
|
|
573131
|
-
lines.push(`A meta-strategy validator reviewed your goal, current sub-task, and recent`);
|
|
573132
|
-
lines.push(`activity. Verdict:`);
|
|
573133
|
-
lines.push(``);
|
|
573134
|
-
lines.push(` ${v.rationale}`);
|
|
573135
|
-
lines.push(``);
|
|
573136
|
-
if (v.verdict === "simplify" || v.verdict === "pivot") {
|
|
573137
|
-
const rf = v.recommended_frame;
|
|
573138
|
-
const verb = v.verdict === "simplify" ? "SHRINK YOUR CURRENT FRAME" : "PIVOT TO A DIFFERENT FRAME";
|
|
573139
|
-
lines.push(`${verb}:`);
|
|
573140
|
-
lines.push(``);
|
|
573141
|
-
lines.push(` New sub-task: ${rf.new_subtask}`);
|
|
573142
|
-
lines.push(` Why this is better: ${rf.why_better}`);
|
|
573143
|
-
lines.push(` Done when: ${rf.success_criterion}`);
|
|
573144
|
-
lines.push(``);
|
|
573145
|
-
lines.push(`Update your todo list to reflect this new framing on your next response.`);
|
|
573146
|
-
lines.push(`Then take ONE concrete action toward the new sub-task. Do NOT continue`);
|
|
573147
|
-
lines.push(`the previous approach — it has been judged ${v.verdict === "pivot" ? "wrong" : "too ambitious"} for`);
|
|
573148
|
-
lines.push(`your current state.`);
|
|
573149
|
-
} else if (v.verdict === "declare-blocked") {
|
|
573150
|
-
lines.push(`DECLARE BLOCKED:`);
|
|
573151
|
-
lines.push(``);
|
|
573152
|
-
lines.push(` ${v.blocker_summary}`);
|
|
573153
|
-
lines.push(``);
|
|
573154
|
-
lines.push(`Call task_complete with a summary that names this blocker EXPLICITLY. Do`);
|
|
573155
|
-
lines.push(`not pretend the work is done; do not keep iterating. The validator has`);
|
|
573156
|
-
lines.push(`determined no productive frame exists from this state. Surface the`);
|
|
573157
|
-
lines.push(`blocker and let the user / next agent intervene.`);
|
|
573158
|
-
}
|
|
573159
|
-
return lines.join("\n");
|
|
573082
|
+
void v;
|
|
573083
|
+
return "";
|
|
573160
573084
|
}
|
|
573161
573085
|
async function runFrameValidator(opts) {
|
|
573162
573086
|
const startMs = Date.now();
|
|
@@ -574048,9 +573972,8 @@ function buildTrajectoryCheckpoint(input) {
|
|
|
574048
573972
|
doNotRepeat.push("Retrying the blocked action unchanged without new evidence.");
|
|
574049
573973
|
} else if (focus) {
|
|
574050
573974
|
assessment = "recovery_required";
|
|
574051
|
-
|
|
574052
|
-
successEvidence = "
|
|
574053
|
-
doNotRepeat.push("Ignoring the active focus recovery directive.");
|
|
573975
|
+
const focusDiagnostic = extractFocusNextAction(focus);
|
|
573976
|
+
successEvidence = focusDiagnostic ? `Active controller directive remains unresolved: ${focusDiagnostic}` : "An active controller directive is unresolved; its evidence is recorded separately.";
|
|
574054
573977
|
} else if (hasRecentFailure && !fullWriteRecoveredByMutation) {
|
|
574055
573978
|
assessment = "recovery_required";
|
|
574056
573979
|
nextAction = "Use the newest failure evidence to make one different, narrow diagnostic or repair action.";
|
|
@@ -574156,7 +574079,7 @@ function buildTrajectoryCheckpoint(input) {
|
|
|
574156
574079
|
}
|
|
574157
574080
|
function renderTrajectoryCheckpoint(checkpoint, maxChars = 1100) {
|
|
574158
574081
|
const lines = [
|
|
574159
|
-
"[TRAJECTORY
|
|
574082
|
+
"[TRAJECTORY DIAGNOSTIC]",
|
|
574160
574083
|
`revision=${checkpoint.revision} turn=${checkpoint.turn} trigger=${checkpoint.trigger}`,
|
|
574161
574084
|
`Goal: ${checkpoint.goal}`,
|
|
574162
574085
|
`Assessment: ${checkpoint.assessment}`,
|
|
@@ -574164,8 +574087,8 @@ function renderTrajectoryCheckpoint(checkpoint, maxChars = 1100) {
|
|
|
574164
574087
|
checkpoint.currentStep ? `Current step: ${checkpoint.currentStep}` : null,
|
|
574165
574088
|
// Keep the action contract ahead of explanatory evidence so truncation can
|
|
574166
574089
|
// never hide the guard that the main agent must follow.
|
|
574167
|
-
`
|
|
574168
|
-
`
|
|
574090
|
+
`Observed next action: ${checkpoint.nextAction}`,
|
|
574091
|
+
`Observed success evidence: ${checkpoint.successEvidence}`,
|
|
574169
574092
|
checkpoint.situationAssessment ? `${checkpoint.groundingSource === "model" ? "Reasoned situation" : "Safety orientation"}: ${checkpoint.situationAssessment}` : null,
|
|
574170
574093
|
checkpoint.groundingEvidenceRefs?.length ? `Grounding evidence: ${checkpoint.groundingEvidenceRefs.join(", ")}` : null,
|
|
574171
574094
|
checkpoint.completedWork.length > 0 ? `Completed evidence-backed work: ${checkpoint.completedWork.join("; ")}` : null,
|
|
@@ -574173,9 +574096,8 @@ function renderTrajectoryCheckpoint(checkpoint, maxChars = 1100) {
|
|
|
574173
574096
|
...checkpoint.groundedFacts.map((fact) => `- [${fact.evidence}; ${fact.freshness}] ${fact.statement}`),
|
|
574174
574097
|
checkpoint.openQuestions.length > 0 ? "Open questions:" : null,
|
|
574175
574098
|
...checkpoint.openQuestions.map((question) => `- ${question}`),
|
|
574176
|
-
checkpoint.doNotRepeat.length > 0 ? "
|
|
574177
|
-
...checkpoint.doNotRepeat.map((constraint) => `- ${constraint}`)
|
|
574178
|
-
"Attention rule: reconcile the next tool call with this checkpoint. Treat stale or unknown evidence as a reason to read or verify. Do not quote this checkpoint or produce a reasoning transcript."
|
|
574099
|
+
checkpoint.doNotRepeat.length > 0 ? "Recorded retry risks:" : null,
|
|
574100
|
+
...checkpoint.doNotRepeat.map((constraint) => `- ${constraint}`)
|
|
574179
574101
|
].filter((line) => Boolean(line));
|
|
574180
574102
|
return truncate2(lines.join("\n"), maxChars);
|
|
574181
574103
|
}
|
|
@@ -578054,65 +577976,6 @@ function normalizeFailurePatterns(patterns) {
|
|
|
578054
577976
|
return a2.signature.localeCompare(b.signature);
|
|
578055
577977
|
});
|
|
578056
577978
|
}
|
|
578057
|
-
function buildFailureModeHandoff(input) {
|
|
578058
|
-
const toolCalls = input.toolCallLog ?? [];
|
|
578059
|
-
const maxRecentCalls = input.maxRecentCalls ?? 8;
|
|
578060
|
-
const recentCalls = maxRecentCalls > 0 ? toolCalls.slice(-maxRecentCalls) : [];
|
|
578061
|
-
const failedCalls = toolCalls.filter((call) => call.success === false);
|
|
578062
|
-
const modified = normalizeModifiedFiles(input.taskState?.modifiedFiles);
|
|
578063
|
-
const failedApproaches = input.taskState?.failedApproaches ?? [];
|
|
578064
|
-
const completedSteps = input.taskState?.completedSteps ?? [];
|
|
578065
|
-
const pendingSteps = input.taskState?.pendingSteps ?? [];
|
|
578066
|
-
const currentStep = cleanInline(input.taskState?.currentStep, 180);
|
|
578067
|
-
const nextAction = cleanInline(input.taskState?.nextAction, 180);
|
|
578068
|
-
const goal = cleanInline(input.taskGoal || input.taskState?.goal || input.taskState?.originalGoal || "", 260);
|
|
578069
|
-
const patterns = normalizeFailurePatterns(input.errorPatterns).slice(0, input.maxPatterns ?? 10);
|
|
578070
|
-
if (patterns.length === 0 && recentCalls.length === 0 && modified.length === 0 && failedApproaches.length === 0 && !goal) {
|
|
578071
|
-
return null;
|
|
578072
|
-
}
|
|
578073
|
-
const lines = ["[FAILURE-MODE INTAKE]"];
|
|
578074
|
-
if (goal)
|
|
578075
|
-
lines.push(`Goal: ${goal}`);
|
|
578076
|
-
if (patterns.length > 0) {
|
|
578077
|
-
lines.push("Top persisted failure modes:");
|
|
578078
|
-
for (const p2 of patterns) {
|
|
578079
|
-
const guidance = p2.guidance ? ` - ${p2.guidance}` : "";
|
|
578080
|
-
lines.push(`- ${p2.signature} x${p2.count}${guidance}`);
|
|
578081
|
-
}
|
|
578082
|
-
}
|
|
578083
|
-
if (recentCalls.length > 0) {
|
|
578084
|
-
const total = toolCalls.length;
|
|
578085
|
-
const failed = failedCalls.length;
|
|
578086
|
-
const mutations = toolCalls.filter((call) => call.mutated || (call.mutatedFiles?.length ?? 0) > 0).length;
|
|
578087
|
-
lines.push(`Current run: ${total} tool calls, ${failed} failed, ${mutations} mutation calls.`);
|
|
578088
|
-
const lastFailure = failedCalls[failedCalls.length - 1];
|
|
578089
|
-
if (lastFailure) {
|
|
578090
|
-
const preview = cleanInline(lastFailure.outputPreview, 240);
|
|
578091
|
-
lines.push(`Last raw failure: ${lastFailure.name}${preview ? ` - ${preview}` : ""}`);
|
|
578092
|
-
}
|
|
578093
|
-
}
|
|
578094
|
-
if (modified.length > 0) {
|
|
578095
|
-
lines.push(`Files touched: ${modified.slice(-8).map(([path16, action]) => `${path16} (${action})`).join(", ")}`);
|
|
578096
|
-
} else {
|
|
578097
|
-
lines.push("Files touched: none recorded.");
|
|
578098
|
-
}
|
|
578099
|
-
if (completedSteps.length > 0) {
|
|
578100
|
-
lines.push(`Recent completed steps: ${completedSteps.slice(-4).join("; ")}`);
|
|
578101
|
-
}
|
|
578102
|
-
if (currentStep)
|
|
578103
|
-
lines.push(`Current step: ${currentStep}`);
|
|
578104
|
-
if (failedApproaches.length > 0) {
|
|
578105
|
-
lines.push(`Failed approaches: ${failedApproaches.slice(-4).join("; ")}`);
|
|
578106
|
-
}
|
|
578107
|
-
if (pendingSteps.length > 0) {
|
|
578108
|
-
lines.push(`Remaining work: ${pendingSteps.slice(0, 5).join("; ")}`);
|
|
578109
|
-
} else if (nextAction) {
|
|
578110
|
-
lines.push(`Next action: ${nextAction}`);
|
|
578111
|
-
}
|
|
578112
|
-
lines.push("Operating rule: base the next move on the raw failure/output state above; do not repeat the same failed approach unchanged.");
|
|
578113
|
-
lines.push("[/FAILURE-MODE INTAKE]");
|
|
578114
|
-
return lines.join("\n");
|
|
578115
|
-
}
|
|
578116
577979
|
function computeCommitProgressGate(input) {
|
|
578117
577980
|
const cooldown = input.cooldownTurns ?? 4;
|
|
578118
577981
|
if (typeof input.lastInjectedTurn === "number" && input.lastInjectedTurn >= 0 && input.turn - input.lastInjectedTurn < cooldown) {
|
|
@@ -578699,6 +578562,57 @@ context_fabric: included=${included.length} dropped=${dropped.length} truncated=
|
|
|
578699
578562
|
});
|
|
578700
578563
|
|
|
578701
578564
|
// packages/orchestrator/dist/context-compiler.js
|
|
578565
|
+
function isControllerStateMessage(message2) {
|
|
578566
|
+
return typeof message2.content === "string" && message2.content.includes(CONTROLLER_STATE_MARKER);
|
|
578567
|
+
}
|
|
578568
|
+
function isActionGroundTruthMessage(message2) {
|
|
578569
|
+
return typeof message2.content === "string" && message2.content.includes(ACTION_GROUND_TRUTH_MARKER);
|
|
578570
|
+
}
|
|
578571
|
+
function isProtectedControllerMessage(message2) {
|
|
578572
|
+
return isControllerStateMessage(message2) || isActionGroundTruthMessage(message2);
|
|
578573
|
+
}
|
|
578574
|
+
function modelFacingMessageCap(message2) {
|
|
578575
|
+
if (isControllerStateMessage(message2)) {
|
|
578576
|
+
return MODEL_FACING_CONTROLLER_STATE_CHAR_CAP;
|
|
578577
|
+
}
|
|
578578
|
+
if (isActionGroundTruthMessage(message2)) {
|
|
578579
|
+
return MODEL_FACING_ACTION_GROUND_TRUTH_CHAR_CAP;
|
|
578580
|
+
}
|
|
578581
|
+
if (message2.role === "tool")
|
|
578582
|
+
return MODEL_FACING_TOOL_CHAR_CAP;
|
|
578583
|
+
if (message2.role === "system")
|
|
578584
|
+
return MODEL_FACING_SYSTEM_CHAR_CAP;
|
|
578585
|
+
return messageText(message2.content).length;
|
|
578586
|
+
}
|
|
578587
|
+
function stripLegacyRuntimeControlFragments(content) {
|
|
578588
|
+
let out = content;
|
|
578589
|
+
out = out.replace(new RegExp(`(?:^|\\n)\\s*${LEGACY_RUNTIME_CONTROL_BLOCK_START_RE.source}[\\s\\S]*?(?=\\n\\s*\\n|\\n(?=\\s*#{1,6}\\s)|\\n(?=\\s*\\[(?:CONTROLLER STATE v1|RECENT ACTION GROUND TRUTH)\\])|$)`, "gim"), "\n");
|
|
578590
|
+
const pieces = out.split(/(\n\s*\n)/);
|
|
578591
|
+
out = pieces.map((piece) => LEGACY_RUNTIME_CONTROL_FRAGMENT_RE.test(piece) ? "" : piece).join("");
|
|
578592
|
+
return collapseWhitespace(out);
|
|
578593
|
+
}
|
|
578594
|
+
function splitOversizedSystemMessages(messages2) {
|
|
578595
|
+
const out = [];
|
|
578596
|
+
for (const message2 of messages2) {
|
|
578597
|
+
if (message2.role !== "system" || typeof message2.content !== "string" || isProtectedControllerMessage(message2) || message2.content.length <= MODEL_FACING_SYSTEM_CHAR_CAP) {
|
|
578598
|
+
out.push(message2);
|
|
578599
|
+
continue;
|
|
578600
|
+
}
|
|
578601
|
+
let remaining = message2.content.trim();
|
|
578602
|
+
while (remaining.length > MODEL_FACING_SYSTEM_CHAR_CAP) {
|
|
578603
|
+
const window2 = remaining.slice(0, MODEL_FACING_SYSTEM_CHAR_CAP);
|
|
578604
|
+
const boundary = Math.max(window2.lastIndexOf("\n\n"), window2.lastIndexOf("\n"));
|
|
578605
|
+
const cut = boundary >= Math.floor(MODEL_FACING_SYSTEM_CHAR_CAP * 0.5) ? boundary : MODEL_FACING_SYSTEM_CHAR_CAP;
|
|
578606
|
+
const chunk = remaining.slice(0, cut).trim();
|
|
578607
|
+
if (chunk)
|
|
578608
|
+
out.push({ ...message2, content: chunk });
|
|
578609
|
+
remaining = remaining.slice(cut).trimStart();
|
|
578610
|
+
}
|
|
578611
|
+
if (remaining)
|
|
578612
|
+
out.push({ ...message2, content: remaining });
|
|
578613
|
+
}
|
|
578614
|
+
return out;
|
|
578615
|
+
}
|
|
578702
578616
|
function isCurrentGoalMessage(message2) {
|
|
578703
578617
|
return typeof message2.content === "string" && message2.content.includes("[CURRENT USER GOAL]");
|
|
578704
578618
|
}
|
|
@@ -578712,14 +578626,15 @@ function applyModelFacingBudget(messages2, preserveFirstSystem) {
|
|
|
578712
578626
|
const content = messageText(message2.content);
|
|
578713
578627
|
const isReservedTransactionMessage = reservedTransaction.has(index);
|
|
578714
578628
|
const isPriorityIntent = message2.role === "user" || isCurrentGoalMessage(message2);
|
|
578715
|
-
const perMessageCap = message2
|
|
578716
|
-
const
|
|
578717
|
-
|
|
578629
|
+
const perMessageCap = modelFacingMessageCap(message2);
|
|
578630
|
+
const isProtectedController = isProtectedControllerMessage(message2);
|
|
578631
|
+
const allowed = isReservedTransactionMessage ? perMessageCap : isPriorityIntent ? content.length : isProtectedController ? perMessageCap : Math.min(remaining, perMessageCap);
|
|
578632
|
+
if (!isReservedTransactionMessage && !isPriorityIntent && !isProtectedController && allowed <= 0) {
|
|
578718
578633
|
continue;
|
|
578719
578634
|
}
|
|
578720
578635
|
const bounded = content.length > allowed && allowed > 0 ? `${content.slice(0, Math.max(0, allowed - 83))}
|
|
578721
578636
|
[truncated_by_context_budget: retained higher-priority current intent/evidence]` : content;
|
|
578722
|
-
if (!isReservedTransactionMessage && !isPriorityIntent && !bounded) {
|
|
578637
|
+
if (!isReservedTransactionMessage && !isPriorityIntent && !isProtectedController && !bounded) {
|
|
578723
578638
|
continue;
|
|
578724
578639
|
}
|
|
578725
578640
|
kept.push(typeof message2.content === "string" ? { ...message2, content: bounded } : message2);
|
|
@@ -578812,7 +578727,7 @@ function latestResolvedToolTransaction(messages2) {
|
|
|
578812
578727
|
}
|
|
578813
578728
|
function modelFacingReservedChars(message2) {
|
|
578814
578729
|
const content = messageText(message2.content);
|
|
578815
|
-
const cap = message2
|
|
578730
|
+
const cap = modelFacingMessageCap(message2);
|
|
578816
578731
|
return Math.min(content.length, cap);
|
|
578817
578732
|
}
|
|
578818
578733
|
function retireLinkedAssistantReadIntents(messages2) {
|
|
@@ -578838,6 +578753,12 @@ function runtimeControlSemanticKey(content) {
|
|
|
578838
578753
|
const normalized = content.replace(/\s+/g, " ").trim().toLowerCase();
|
|
578839
578754
|
if (!normalized)
|
|
578840
578755
|
return null;
|
|
578756
|
+
if (content.includes(CONTROLLER_STATE_MARKER)) {
|
|
578757
|
+
return "context.controller-state";
|
|
578758
|
+
}
|
|
578759
|
+
if (content.includes(ACTION_GROUND_TRUTH_MARKER)) {
|
|
578760
|
+
return "context.action-ground-truth";
|
|
578761
|
+
}
|
|
578841
578762
|
if (content.includes("[ACTIVE CONTEXT FRAME]"))
|
|
578842
578763
|
return "context.active-frame";
|
|
578843
578764
|
if (content.includes("[TRAJECTORY CHECKPOINT]"))
|
|
@@ -578923,8 +578844,16 @@ function retireDuplicateToolFailures(messages2) {
|
|
|
578923
578844
|
function prepareModelFacingApiMessages(input) {
|
|
578924
578845
|
const preserveFirstSystem = input.preserveFirstSystem !== false;
|
|
578925
578846
|
const sanitized = [];
|
|
578926
|
-
|
|
578927
|
-
|
|
578847
|
+
const withoutLegacyControl = input.messages.flatMap((message2) => {
|
|
578848
|
+
if (message2.role !== "system" || typeof message2.content !== "string" || isProtectedControllerMessage(message2)) {
|
|
578849
|
+
return [message2];
|
|
578850
|
+
}
|
|
578851
|
+
const stripped = stripLegacyRuntimeControlFragments(message2.content);
|
|
578852
|
+
return stripped ? [{ ...message2, content: stripped }] : [];
|
|
578853
|
+
});
|
|
578854
|
+
const independentlyBounded = splitOversizedSystemMessages(withoutLegacyControl);
|
|
578855
|
+
for (let index = 0; index < independentlyBounded.length; index++) {
|
|
578856
|
+
const message2 = independentlyBounded[index];
|
|
578928
578857
|
if (message2.role === "system" && typeof message2.content === "string") {
|
|
578929
578858
|
if (preserveFirstSystem && sanitized.length === 0) {
|
|
578930
578859
|
sanitized.push({ ...message2 });
|
|
@@ -579016,9 +578945,36 @@ function normalizeContextSignalsForModel(signals) {
|
|
|
579016
578945
|
}
|
|
579017
578946
|
return { signals: normalized, rejected };
|
|
579018
578947
|
}
|
|
578948
|
+
function typeControllerSignal(signal) {
|
|
578949
|
+
if (signal.modelVisible === false)
|
|
578950
|
+
return signal;
|
|
578951
|
+
if (signal.content.includes(CONTROLLER_STATE_MARKER)) {
|
|
578952
|
+
return {
|
|
578953
|
+
...signal,
|
|
578954
|
+
id: "controller-state-v1",
|
|
578955
|
+
dedupeKey: "context.controller_state_v1",
|
|
578956
|
+
semanticKey: "context.controller_state_v1",
|
|
578957
|
+
conflictGroup: "context.controller_state",
|
|
578958
|
+
priority: Math.max(signal.priority ?? 0, PRIORITY.GOAL + 15),
|
|
578959
|
+
ttlTurns: 1
|
|
578960
|
+
};
|
|
578961
|
+
}
|
|
578962
|
+
if (signal.content.includes(ACTION_GROUND_TRUTH_MARKER)) {
|
|
578963
|
+
return {
|
|
578964
|
+
...signal,
|
|
578965
|
+
id: "recent-action-ground-truth",
|
|
578966
|
+
dedupeKey: "context.recent_action_ground_truth",
|
|
578967
|
+
semanticKey: "context.recent_action_ground_truth",
|
|
578968
|
+
conflictGroup: "context.action_ground_truth",
|
|
578969
|
+
priority: Math.max(signal.priority ?? 0, PRIORITY.GOAL + 14),
|
|
578970
|
+
ttlTurns: 1
|
|
578971
|
+
};
|
|
578972
|
+
}
|
|
578973
|
+
return signal;
|
|
578974
|
+
}
|
|
579019
578975
|
function compileContextFrameV2(input) {
|
|
579020
578976
|
const builder = input.builder ?? new ContextFrameBuilder();
|
|
579021
|
-
const normalized = normalizeContextSignalsForModel(input.signals);
|
|
578977
|
+
const normalized = normalizeContextSignalsForModel(input.signals.map(typeControllerSignal));
|
|
579022
578978
|
const goal = deriveCurrentGoal({
|
|
579023
578979
|
explicitGoal: input.currentGoal,
|
|
579024
578980
|
signals: normalized.signals
|
|
@@ -579058,7 +579014,7 @@ function compileContextFrameV2(input) {
|
|
|
579058
579014
|
}
|
|
579059
579015
|
};
|
|
579060
579016
|
}
|
|
579061
|
-
var MODEL_FACING_CONTEXT_CHAR_BUDGET, MODEL_FACING_TOOL_CHAR_CAP, MODEL_FACING_SYSTEM_CHAR_CAP, ASSISTANT_READ_INTENT_RETIRED_MARKER, RESTORE_NOISE_LINE_RE, RUNTIME_GUIDANCE_RE, ACTIVE_CONTEXT_RE;
|
|
579017
|
+
var MODEL_FACING_CONTEXT_CHAR_BUDGET, MODEL_FACING_TOOL_CHAR_CAP, MODEL_FACING_SYSTEM_CHAR_CAP, MODEL_FACING_CONTROLLER_STATE_CHAR_CAP, MODEL_FACING_ACTION_GROUND_TRUTH_CHAR_CAP, CONTROLLER_STATE_MARKER, ACTION_GROUND_TRUTH_MARKER, LEGACY_RUNTIME_CONTROL_FRAGMENT_RE, LEGACY_RUNTIME_CONTROL_BLOCK_START_RE, ASSISTANT_READ_INTENT_RETIRED_MARKER, RESTORE_NOISE_LINE_RE, RUNTIME_GUIDANCE_RE, ACTIVE_CONTEXT_RE;
|
|
579062
579018
|
var init_context_compiler = __esm({
|
|
579063
579019
|
"packages/orchestrator/dist/context-compiler.js"() {
|
|
579064
579020
|
"use strict";
|
|
@@ -579066,6 +579022,12 @@ var init_context_compiler = __esm({
|
|
|
579066
579022
|
MODEL_FACING_CONTEXT_CHAR_BUDGET = 48e3;
|
|
579067
579023
|
MODEL_FACING_TOOL_CHAR_CAP = 6e3;
|
|
579068
579024
|
MODEL_FACING_SYSTEM_CHAR_CAP = 8e3;
|
|
579025
|
+
MODEL_FACING_CONTROLLER_STATE_CHAR_CAP = 4e3;
|
|
579026
|
+
MODEL_FACING_ACTION_GROUND_TRUTH_CHAR_CAP = 5500;
|
|
579027
|
+
CONTROLLER_STATE_MARKER = "[CONTROLLER STATE v1]";
|
|
579028
|
+
ACTION_GROUND_TRUTH_MARKER = "[RECENT ACTION GROUND TRUTH]";
|
|
579029
|
+
LEGACY_RUNTIME_CONTROL_FRAGMENT_RE = /(?:\bREG-\d+\b|\bfocus supervisor\b|\bworld[ -]state\b|\brecent tool failures\b|\bstop\s*[—-]\s*retry loop\b|\bstagnation replan\b|\bfirst-edit nudge\b|\bintra-run lesson\b|\blocal error-informed nudge\b|\b(?:failure|failing)\s+(?:recovery|replan|loop)\b|\bdoom-loop\b|\b(?:prior\s+)?failure reflection\b|\breflexion\b|\b(?:cross-session|prior)\s+lessons?\b|\bprogress gate\b|\bforecast\b)/i;
|
|
579030
|
+
LEGACY_RUNTIME_CONTROL_BLOCK_START_RE = /(?:\[(?:REG-\d+|FOCUS SUPERVISOR[^\]]*|WORLD[ -]STATE[^\]]*|RECENT TOOL FAILURES|STOP\s*[—-]\s*RETRY LOOP|STAGNATION REPLAN[^\]]*|FIRST-EDIT NUDGE[^\]]*|INTRA-RUN LESSON[^\]]*|LOCAL ERROR-INFORMED NUDGE[^\]]*|FORECAST[^\]]*|PROGRESS GATE[^\]]*|FAIL(?:URE|ING)[^\]]*(?:RECOVERY|REPLAN|LOOP)[^\]]*|DOOM-LOOP[^\]]*)\]|<(?:world-state|focus-supervisor|failure-recovery|reflection|lessons?)[^>]*>)/i;
|
|
579069
579031
|
ASSISTANT_READ_INTENT_RETIRED_MARKER = "[assistant read intent retired: the linked tool result is already available; decide from that evidence instead of restating a read plan]";
|
|
579070
579032
|
RESTORE_NOISE_LINE_RE = /^\s*(?:🔊|E Task timeout reached|E Incomplete:|⚠ Task incomplete|Tokens:\s*[\d,]+|▹\s*continue\b|·\s*(?:Starting fresh|Context (?:auto-)?restored|Nexus P2P network connected|REST API:|Voice feedback enabled|Memory maintenance:)|.*\bSHELL TRANSCRIPT\b.*|.*speaker emoji.*).*$/i;
|
|
579071
579033
|
RUNTIME_GUIDANCE_RE = /\[RUNTIME_GUIDANCE_INTAKE v\d+\][\s\S]*?<<<RUNTIME_GUIDANCE>>>\s*([\s\S]*?)\s*<<<END_RUNTIME_GUIDANCE>>>[\s\S]*?\[\/RUNTIME_GUIDANCE_INTAKE\]/g;
|
|
@@ -581053,6 +581015,37 @@ var init_debugArtifactLibrary = __esm({
|
|
|
581053
581015
|
});
|
|
581054
581016
|
|
|
581055
581017
|
// packages/orchestrator/dist/focusSupervisor.js
|
|
581018
|
+
function satisfactionForRequiredAction(action) {
|
|
581019
|
+
switch (action) {
|
|
581020
|
+
case "read_authoritative_target":
|
|
581021
|
+
case "disambiguate_edit_match":
|
|
581022
|
+
return { kind: "fresh_read" };
|
|
581023
|
+
case "run_verification":
|
|
581024
|
+
return { kind: "verification" };
|
|
581025
|
+
case "update_todos":
|
|
581026
|
+
return { kind: "todo_update" };
|
|
581027
|
+
case "report_blocked":
|
|
581028
|
+
case "report_incomplete":
|
|
581029
|
+
return { kind: "blocked_completion" };
|
|
581030
|
+
default:
|
|
581031
|
+
return { kind: "distinct_action" };
|
|
581032
|
+
}
|
|
581033
|
+
}
|
|
581034
|
+
function inferDirectiveSource(input) {
|
|
581035
|
+
if (/stale|hash|authoritative target|ambiguous/i.test(input.reason)) {
|
|
581036
|
+
return "stale_write";
|
|
581037
|
+
}
|
|
581038
|
+
if (input.requiredNextAction === "run_verification") {
|
|
581039
|
+
return "verification_failure";
|
|
581040
|
+
}
|
|
581041
|
+
if (input.requiredNextAction === "use_cached_evidence") {
|
|
581042
|
+
return "duplicate_action";
|
|
581043
|
+
}
|
|
581044
|
+
if (input.requiredNextAction === "report_blocked" || input.requiredNextAction === "report_incomplete") {
|
|
581045
|
+
return "completion_gate";
|
|
581046
|
+
}
|
|
581047
|
+
return "repeated_failure";
|
|
581048
|
+
}
|
|
581056
581049
|
function resolveFocusSupervisorSilent(envValue = process.env["OMNIUS_FOCUS_SUPERVISOR_SILENT"]) {
|
|
581057
581050
|
const normalized = String(envValue ?? "").trim().toLowerCase();
|
|
581058
581051
|
if (normalized === "0" || normalized === "false" || normalized === "off") {
|
|
@@ -581425,6 +581418,10 @@ var init_focusSupervisor = __esm({
|
|
|
581425
581418
|
availableTools = null;
|
|
581426
581419
|
/** SILENCE: when true, block() downgrades to pass() (never stops a call). */
|
|
581427
581420
|
silent;
|
|
581421
|
+
taskEpoch;
|
|
581422
|
+
directiveTtlTurns;
|
|
581423
|
+
lastObservedTurn = 0;
|
|
581424
|
+
onDirectiveLifecycle;
|
|
581428
581425
|
constructor(options2 = {}) {
|
|
581429
581426
|
this.mode = options2.mode ?? "auto";
|
|
581430
581427
|
this.modelTier = options2.modelTier ?? "large";
|
|
@@ -581433,6 +581430,9 @@ var init_focusSupervisor = __esm({
|
|
|
581433
581430
|
this.availableTools = options2.availableTools ? new Set(Array.from(options2.availableTools)) : null;
|
|
581434
581431
|
this.convergenceBreaker = options2.convergenceBreaker ?? null;
|
|
581435
581432
|
this.familyCwd = options2.cwd;
|
|
581433
|
+
this.taskEpoch = Math.max(0, Math.floor(options2.taskEpoch ?? 0));
|
|
581434
|
+
this.directiveTtlTurns = Math.max(1, Math.floor(options2.directiveTtlTurns ?? (this.modelTier === "large" ? 1 : 2)));
|
|
581435
|
+
this.onDirectiveLifecycle = options2.onDirectiveLifecycle;
|
|
581436
581436
|
}
|
|
581437
581437
|
get enabled() {
|
|
581438
581438
|
return this.mode !== "off";
|
|
@@ -581440,6 +581440,69 @@ var init_focusSupervisor = __esm({
|
|
|
581440
581440
|
get currentDirective() {
|
|
581441
581441
|
return this.directive;
|
|
581442
581442
|
}
|
|
581443
|
+
/**
|
|
581444
|
+
* A task redirect/replacement is a control boundary. Old directives remain
|
|
581445
|
+
* auditable through telemetry but cannot survive into the new task epoch.
|
|
581446
|
+
*/
|
|
581447
|
+
setTaskEpoch(taskEpoch, turn = this.lastObservedTurn) {
|
|
581448
|
+
const next = Math.max(0, Math.floor(taskEpoch));
|
|
581449
|
+
if (next === this.taskEpoch)
|
|
581450
|
+
return;
|
|
581451
|
+
if (this.directive) {
|
|
581452
|
+
this.transitionDirective("superseded", turn, `task epoch changed from ${this.taskEpoch} to ${next}`);
|
|
581453
|
+
}
|
|
581454
|
+
this.taskEpoch = next;
|
|
581455
|
+
this.state = "observe";
|
|
581456
|
+
this.ignoredDirectiveStreak = 0;
|
|
581457
|
+
this.lastIgnoredDirectiveTurn = null;
|
|
581458
|
+
this.repeatedViolationCounts.clear();
|
|
581459
|
+
}
|
|
581460
|
+
/**
|
|
581461
|
+
* Controller integration point for structured detectors. It replaces the
|
|
581462
|
+
* current directive only when the supplied evidence is newer or materially
|
|
581463
|
+
* changes the recovery requirement; callers must not pass model prose alone.
|
|
581464
|
+
*/
|
|
581465
|
+
activateEvidenceDirective(input) {
|
|
581466
|
+
if (!this.enabled)
|
|
581467
|
+
return null;
|
|
581468
|
+
this.lastObservedTurn = Math.max(this.lastObservedTurn, input.turn);
|
|
581469
|
+
return this.setDirective({
|
|
581470
|
+
turn: input.turn,
|
|
581471
|
+
state: input.state ?? "single_next_action",
|
|
581472
|
+
reason: input.reason,
|
|
581473
|
+
requiredNextAction: input.requiredNextAction,
|
|
581474
|
+
forbiddenActionFamilies: input.forbiddenActionFamilies ?? [],
|
|
581475
|
+
source: input.source,
|
|
581476
|
+
evidenceRefs: input.evidenceRefs,
|
|
581477
|
+
evidenceStateVersion: input.evidenceStateVersion,
|
|
581478
|
+
satisfaction: input.satisfaction
|
|
581479
|
+
});
|
|
581480
|
+
}
|
|
581481
|
+
supersedeActiveDirective(reason, turn = this.lastObservedTurn, supersededBy) {
|
|
581482
|
+
this.transitionDirective("superseded", turn, reason, supersededBy);
|
|
581483
|
+
}
|
|
581484
|
+
cancelActiveDirective(reason, turn = this.lastObservedTurn) {
|
|
581485
|
+
this.transitionDirective("cancelled", turn, reason);
|
|
581486
|
+
}
|
|
581487
|
+
/** A compact, factual record for a controller frame; no directive history. */
|
|
581488
|
+
compactDirective(turn = this.lastObservedTurn) {
|
|
581489
|
+
this.lastObservedTurn = Math.max(this.lastObservedTurn, turn);
|
|
581490
|
+
this.expireDirectiveIfNeeded(this.lastObservedTurn);
|
|
581491
|
+
const directive = this.directive;
|
|
581492
|
+
if (!directive)
|
|
581493
|
+
return null;
|
|
581494
|
+
return {
|
|
581495
|
+
id: directive.id,
|
|
581496
|
+
taskEpoch: directive.taskEpoch ?? this.taskEpoch,
|
|
581497
|
+
source: directive.source ?? "manual",
|
|
581498
|
+
state: directive.state,
|
|
581499
|
+
requiredNextAction: directive.requiredNextAction,
|
|
581500
|
+
evidenceRefs: directive.evidenceRefs ?? [],
|
|
581501
|
+
evidenceStateVersion: directive.evidenceStateVersion ?? 0,
|
|
581502
|
+
expiresAfterTurn: directive.expiresAfterTurn,
|
|
581503
|
+
satisfaction: directive.satisfaction
|
|
581504
|
+
};
|
|
581505
|
+
}
|
|
581443
581506
|
/**
|
|
581444
581507
|
* CE-A1: the runner rehydrated evicted evidence back into the model's
|
|
581445
581508
|
* window. Any read-oriented directive is now satisfiable (or already
|
|
@@ -581476,7 +581539,10 @@ var init_focusSupervisor = __esm({
|
|
|
581476
581539
|
shellFailureRequiredNextAction() {
|
|
581477
581540
|
return this.silent && this.modelTier === "small" ? "creative_pivot_or_research" : "use_cached_evidence";
|
|
581478
581541
|
}
|
|
581479
|
-
snapshot() {
|
|
581542
|
+
snapshot(turn) {
|
|
581543
|
+
const observedTurn = turn === void 0 ? this.lastObservedTurn : Math.max(this.lastObservedTurn, Math.max(0, Math.floor(turn)));
|
|
581544
|
+
this.lastObservedTurn = observedTurn;
|
|
581545
|
+
this.expireDirectiveIfNeeded(observedTurn);
|
|
581480
581546
|
return {
|
|
581481
581547
|
mode: this.mode,
|
|
581482
581548
|
enabled: this.enabled,
|
|
@@ -581490,22 +581556,36 @@ var init_focusSupervisor = __esm({
|
|
|
581490
581556
|
observeContext(snapshot) {
|
|
581491
581557
|
this.lastContext = snapshot;
|
|
581492
581558
|
}
|
|
581493
|
-
renderFrame() {
|
|
581559
|
+
renderFrame(turn = this.lastObservedTurn) {
|
|
581560
|
+
this.lastObservedTurn = Math.max(this.lastObservedTurn, turn);
|
|
581561
|
+
this.expireDirectiveIfNeeded(this.lastObservedTurn);
|
|
581494
581562
|
if (!this.enabled || !this.directive)
|
|
581495
581563
|
return null;
|
|
581564
|
+
if (this.modelTier === "large")
|
|
581565
|
+
return null;
|
|
581496
581566
|
const d2 = this.directive;
|
|
581497
581567
|
return [
|
|
581498
|
-
"[
|
|
581568
|
+
"[ACTIVE DIRECTIVE STATE]",
|
|
581569
|
+
`task_epoch=${d2.taskEpoch ?? this.taskEpoch}`,
|
|
581499
581570
|
`state=${d2.state}`,
|
|
581500
581571
|
`directive_id=${d2.id}`,
|
|
581572
|
+
`lifecycle=${d2.lifecycleState ?? "active"}`,
|
|
581573
|
+
`source=${d2.source ?? "manual"}`,
|
|
581501
581574
|
`required_next_action=${d2.requiredNextAction}`,
|
|
581502
|
-
`
|
|
581575
|
+
`evidence_refs=${(d2.evidenceRefs ?? []).join(",") || "none"}`,
|
|
581576
|
+
`evidence_state_version=${d2.evidenceStateVersion ?? 0}`,
|
|
581577
|
+
d2.expiresAfterTurn !== void 0 ? `expires_after_turn=${d2.expiresAfterTurn}` : "expires_after_turn=unknown",
|
|
581578
|
+
d2.satisfaction ? `satisfaction=${d2.satisfaction.kind}` : "",
|
|
581579
|
+
`diagnosis=${d2.reason}`,
|
|
581503
581580
|
d2.forbiddenActionFamilies.length ? `forbidden_action_families=${d2.forbiddenActionFamilies.join(", ")}` : "",
|
|
581504
|
-
d2.ignoredCount > 0 ? `ignored_count=${d2.ignoredCount}` : ""
|
|
581505
|
-
"Follow the required next action before returning to broad exploration or completion."
|
|
581581
|
+
d2.ignoredCount > 0 ? `ignored_count=${d2.ignoredCount}` : ""
|
|
581506
581582
|
].filter(Boolean).join("\n");
|
|
581507
581583
|
}
|
|
581508
581584
|
evaluateProposedCall(input) {
|
|
581585
|
+
this.lastObservedTurn = Math.max(this.lastObservedTurn, input.turn);
|
|
581586
|
+
if (input.taskEpoch !== void 0)
|
|
581587
|
+
this.setTaskEpoch(input.taskEpoch, input.turn);
|
|
581588
|
+
this.expireDirectiveIfNeeded(input.turn);
|
|
581509
581589
|
this.lastContext = input.context ?? this.lastContext;
|
|
581510
581590
|
if (!this.enabled)
|
|
581511
581591
|
return this.pass();
|
|
@@ -581665,14 +581745,14 @@ var init_focusSupervisor = __esm({
|
|
|
581665
581745
|
return this.pass();
|
|
581666
581746
|
}
|
|
581667
581747
|
observeToolResult(input) {
|
|
581748
|
+
this.lastObservedTurn = Math.max(this.lastObservedTurn, input.turn);
|
|
581749
|
+
this.expireDirectiveIfNeeded(input.turn);
|
|
581668
581750
|
if (!this.enabled)
|
|
581669
581751
|
return;
|
|
581670
|
-
if (input.mutated)
|
|
581752
|
+
if (input.mutated)
|
|
581671
581753
|
this.sawMutationSinceFailure = true;
|
|
581672
|
-
|
|
581673
|
-
|
|
581674
|
-
}
|
|
581675
|
-
if (input.success && input.alreadyApplied) {
|
|
581754
|
+
const satisfiesAlreadyApplied = this.directive?.satisfaction?.kind === "distinct_action" || this.directive?.satisfaction?.kind === "fresh_read" && input.usedAuthoritativeTargetEvidence === true && isEditTool(input.toolName);
|
|
581755
|
+
if (input.success && input.alreadyApplied && satisfiesAlreadyApplied) {
|
|
581676
581756
|
this.clearSatisfiedDirective("requested edit already applied", input.turn);
|
|
581677
581757
|
return;
|
|
581678
581758
|
}
|
|
@@ -581707,7 +581787,7 @@ var init_focusSupervisor = __esm({
|
|
|
581707
581787
|
this.lastReason = "runtime-authored control result did not execute the requested tool";
|
|
581708
581788
|
return;
|
|
581709
581789
|
}
|
|
581710
|
-
if (input.toolName === "todo_write" && input.success) {
|
|
581790
|
+
if (input.toolName === "todo_write" && input.success && this.directive?.satisfaction?.kind === "todo_update") {
|
|
581711
581791
|
if (input.noop) {
|
|
581712
581792
|
this.lastDecision = "todo_noop_not_satisfied";
|
|
581713
581793
|
this.lastReason = "todo_write returned no-op; checklist state did not change";
|
|
@@ -581840,10 +581920,11 @@ var init_focusSupervisor = __esm({
|
|
|
581840
581920
|
return;
|
|
581841
581921
|
this.setDirective({
|
|
581842
581922
|
turn,
|
|
581843
|
-
state: "
|
|
581844
|
-
reason
|
|
581845
|
-
requiredNextAction: "
|
|
581846
|
-
forbiddenActionFamilies: ["brute_force"]
|
|
581923
|
+
state: "terminal_incomplete",
|
|
581924
|
+
reason,
|
|
581925
|
+
requiredNextAction: "report_incomplete",
|
|
581926
|
+
forbiddenActionFamilies: ["brute_force"],
|
|
581927
|
+
source: "completion_gate"
|
|
581847
581928
|
});
|
|
581848
581929
|
}
|
|
581849
581930
|
shouldStrictlyIntervene(context2) {
|
|
@@ -581872,7 +581953,12 @@ var init_focusSupervisor = __esm({
|
|
|
581872
581953
|
}
|
|
581873
581954
|
setDirective(input) {
|
|
581874
581955
|
const existing = this.directive;
|
|
581875
|
-
const
|
|
581956
|
+
const evidenceStateVersion = input.evidenceStateVersion ?? 0;
|
|
581957
|
+
const stable = existing && existing.state === input.state && existing.reason === input.reason && existing.requiredNextAction === input.requiredNextAction && (existing.evidenceStateVersion ?? 0) >= evidenceStateVersion;
|
|
581958
|
+
if (existing && !stable) {
|
|
581959
|
+
this.transitionDirective("superseded", input.turn, "replaced by newer evidence or a different recovery requirement");
|
|
581960
|
+
}
|
|
581961
|
+
const source = input.source ?? inferDirectiveSource(input);
|
|
581876
581962
|
const directive = stable ? {
|
|
581877
581963
|
...existing,
|
|
581878
581964
|
forbiddenActionFamilies: uniqueLimited([
|
|
@@ -581880,13 +581966,20 @@ var init_focusSupervisor = __esm({
|
|
|
581880
581966
|
...input.forbiddenActionFamilies
|
|
581881
581967
|
])
|
|
581882
581968
|
} : {
|
|
581883
|
-
id: `focus_${++directiveCounter}`,
|
|
581969
|
+
id: `focus_${this.taskEpoch}_${++directiveCounter}`,
|
|
581884
581970
|
state: input.state,
|
|
581885
581971
|
reason: input.reason,
|
|
581886
581972
|
requiredNextAction: input.requiredNextAction,
|
|
581887
581973
|
forbiddenActionFamilies: uniqueLimited(input.forbiddenActionFamilies),
|
|
581888
581974
|
createdTurn: input.turn,
|
|
581889
|
-
ignoredCount: 0
|
|
581975
|
+
ignoredCount: 0,
|
|
581976
|
+
taskEpoch: this.taskEpoch,
|
|
581977
|
+
lifecycleState: "active",
|
|
581978
|
+
source,
|
|
581979
|
+
evidenceRefs: uniqueLimited(input.evidenceRefs ?? [`turn:${input.turn}`]),
|
|
581980
|
+
evidenceStateVersion,
|
|
581981
|
+
expiresAfterTurn: input.turn + this.directiveTtlTurns,
|
|
581982
|
+
satisfaction: input.satisfaction ?? satisfactionForRequiredAction(input.requiredNextAction)
|
|
581890
581983
|
};
|
|
581891
581984
|
if (!stable && (!existing || existing.state !== input.state || existing.requiredNextAction !== input.requiredNextAction)) {
|
|
581892
581985
|
this.repeatedViolationCounts.clear();
|
|
@@ -581896,12 +581989,45 @@ var init_focusSupervisor = __esm({
|
|
|
581896
581989
|
this.lastReason = directive.reason;
|
|
581897
581990
|
if (!stable)
|
|
581898
581991
|
this.lastIgnoredDirectiveTurn = null;
|
|
581992
|
+
if (!stable) {
|
|
581993
|
+
this.emitDirectiveLifecycle({
|
|
581994
|
+
directive,
|
|
581995
|
+
taskEpoch: this.taskEpoch,
|
|
581996
|
+
transition: "created",
|
|
581997
|
+
turn: input.turn,
|
|
581998
|
+
reason: directive.reason
|
|
581999
|
+
});
|
|
582000
|
+
}
|
|
581899
582001
|
return directive;
|
|
581900
582002
|
}
|
|
581901
|
-
clearSatisfiedDirective(reason,
|
|
581902
|
-
|
|
582003
|
+
clearSatisfiedDirective(reason, turn) {
|
|
582004
|
+
this.transitionDirective("satisfied", turn, reason);
|
|
582005
|
+
}
|
|
582006
|
+
expireDirectiveIfNeeded(turn) {
|
|
582007
|
+
const expires = this.directive?.expiresAfterTurn;
|
|
582008
|
+
if (expires !== void 0 && turn >= expires) {
|
|
582009
|
+
this.transitionDirective("expired", turn, "directive TTL elapsed without new evidence");
|
|
582010
|
+
}
|
|
582011
|
+
}
|
|
582012
|
+
transitionDirective(transition, turn, reason, supersededBy) {
|
|
582013
|
+
const directive = this.directive;
|
|
582014
|
+
if (!directive)
|
|
581903
582015
|
return;
|
|
581904
|
-
|
|
582016
|
+
const resolved = {
|
|
582017
|
+
...directive,
|
|
582018
|
+
lifecycleState: transition,
|
|
582019
|
+
resolvedTurn: turn,
|
|
582020
|
+
resolutionReason: reason,
|
|
582021
|
+
...supersededBy ? { supersededBy } : {}
|
|
582022
|
+
};
|
|
582023
|
+
this.emitDirectiveLifecycle({
|
|
582024
|
+
directive: resolved,
|
|
582025
|
+
taskEpoch: this.taskEpoch,
|
|
582026
|
+
transition,
|
|
582027
|
+
turn,
|
|
582028
|
+
reason
|
|
582029
|
+
});
|
|
582030
|
+
this.lastDecision = transition === "satisfied" ? "directive_satisfied" : `directive_${transition}`;
|
|
581905
582031
|
this.lastReason = reason;
|
|
581906
582032
|
this.directive = null;
|
|
581907
582033
|
this.state = "observe";
|
|
@@ -581909,6 +582035,12 @@ var init_focusSupervisor = __esm({
|
|
|
581909
582035
|
this.lastIgnoredDirectiveTurn = null;
|
|
581910
582036
|
this.repeatedViolationCounts.clear();
|
|
581911
582037
|
}
|
|
582038
|
+
emitDirectiveLifecycle(event) {
|
|
582039
|
+
try {
|
|
582040
|
+
this.onDirectiveLifecycle?.(event);
|
|
582041
|
+
} catch {
|
|
582042
|
+
}
|
|
582043
|
+
}
|
|
581912
582044
|
pass() {
|
|
581913
582045
|
return {
|
|
581914
582046
|
kind: "pass",
|
|
@@ -589537,12 +589669,6 @@ ${parts.join("\n")}
|
|
|
589537
589669
|
const gitContract = renderGitProgressActionContract(this._gitProgress);
|
|
589538
589670
|
if (gitContract)
|
|
589539
589671
|
lines.push(gitContract);
|
|
589540
|
-
const focus = this._focusSupervisor?.snapshot().directive ?? null;
|
|
589541
|
-
if (focus) {
|
|
589542
|
-
lines.push(`focus_required_next_action=${focus.requiredNextAction}`);
|
|
589543
|
-
lines.push(`focus_valid_tools=${this._focusToolsForRequiredAction(focus.requiredNextAction)}`);
|
|
589544
|
-
lines.push(`focus_reason=${focus.reason}`);
|
|
589545
|
-
}
|
|
589546
589672
|
const snapshot = this._currentWorkboardSnapshotForFrame();
|
|
589547
589673
|
const action = snapshot ? this._deriveWorkboardActionContract(snapshot) : null;
|
|
589548
589674
|
if (snapshot && action) {
|
|
@@ -590386,28 +590512,8 @@ ${parts.join("\n")}
|
|
|
590386
590512
|
const pressureCue = pressureCheck(task);
|
|
590387
590513
|
const rawPrompt = getSystemPromptForTier(this.options.modelTier);
|
|
590388
590514
|
const basePrompt = rawPrompt + pressureCue;
|
|
590389
|
-
const
|
|
590390
|
-
const
|
|
590391
|
-
small: `
|
|
590392
|
-
|
|
590393
|
-
## Response batching
|
|
590394
|
-
|
|
590395
|
-
Emit AT MOST 2 tool calls per response. After observing their results, plan the next 2 in your following response. Smaller batches let the orchestrator deliver cache/failure/progress signals to you between actions. Tool calls beyond the cap are dropped.${todoBatchGuidance}`,
|
|
590396
|
-
medium: `
|
|
590397
|
-
|
|
590398
|
-
## Response batching
|
|
590399
|
-
|
|
590400
|
-
Emit AT MOST 4 tool calls per response. After observing their results, plan the next batch in your following response. Smaller batches let the orchestrator deliver cache/failure/progress signals to you between actions. Tool calls beyond the cap are dropped.${todoBatchGuidance}`,
|
|
590401
|
-
large: `
|
|
590402
|
-
|
|
590403
|
-
## Response batching
|
|
590404
|
-
|
|
590405
|
-
Emit AT MOST 6 tool calls per response. Smaller batches receive better feedback (cache/failure/progress signals between actions). Tool calls beyond the cap are dropped.${todoBatchGuidance}`
|
|
590406
|
-
};
|
|
590407
|
-
const batchGuidance = _BATCH_GUIDANCE[this.options.modelTier ?? "large"] ?? _BATCH_GUIDANCE.large;
|
|
590408
|
-
const shellGuidance = "\n\n## Shell command patterns\n\nWhen investigating a build/test/install failure, RUN THE COMMAND WITHOUT TRUNCATION FIRST to see the full error.\nAvoid `| tail -N` / `| head -N` / `| sed -n '1,Np'` on commands you don't yet trust — they drop the part of the output where errors usually appear.\nPipefail is on by default in this orchestrator: a pipeline's exit code reflects the FIRST failing stage, not just the last. So `<cmd> | tail -80` returns non-zero if `<cmd>` failed.\nWhen you DO want to limit context (after diagnosis), prefer `<cmd> 2>&1 | tail -300` (or larger) so you keep enough output to see the actual error block.\nIf your command exited 0 but produced suspiciously short output (~< 800 chars), the orchestrator will inject a [HINT — pipe-to-truncator detected] block telling you to re-run without truncation.";
|
|
590409
|
-
const editTransportGuidance = "\n\n## Existing-file edit loop\n\nFor an existing non-trivial file, use this loop: (1) file_read the implicated range or whole small file, (2) file_patch a contiguous line range or file_edit exact current text, (3) inspect the resulting diff/changed range, and (4) run the declared verifier live. Use batch_edit only for multiple exact replacements built from one fresh read.\nfile_write is for new files, empty/placeholder files, and deliberate replacement of a genuinely small file. Never use file_write as a fallback for stale hashes, old_string mismatches, malformed patch arguments, or repeated edit failures. A 'different approach' means refresh evidence or change the diagnostic/patch shape; it does not mean broaden a local repair into a whole-file rewrite.\nPreviously observed or compacted results are orientation only. Re-run file_read whenever a freshness/hash guard asks for current text, and re-run the exact verifier after every relevant mutation; cached output never proves current file state or completion.";
|
|
590410
|
-
const basePromptWithBatching = basePrompt + batchGuidance + shellGuidance + editTransportGuidance;
|
|
590515
|
+
const toolProtocol = "\n\n## Tool protocol\nUse a bounded tool batch, inspect returned evidence before the next batch, and use structured tool calls. For an existing file, provide fresh target evidence for a mutation; hash and scope validation are enforced by the tools. Verify a claimed end state with current evidence.";
|
|
590516
|
+
const basePromptWithBatching = basePrompt + toolProtocol;
|
|
590411
590517
|
sections.push({
|
|
590412
590518
|
label: "c_instr",
|
|
590413
590519
|
content: basePromptWithBatching,
|
|
@@ -594758,7 +594864,6 @@ ${latest.output || ""}`.trim();
|
|
|
594758
594864
|
`files=${scan.files.length}${scan.truncated ? "+" : ""}`,
|
|
594759
594865
|
`dirs=${scan.dirs.length}`,
|
|
594760
594866
|
`bytes=${totalBytes}`,
|
|
594761
|
-
focusSnapshot?.directive?.requiredNextAction ? `supervisor_required_next_action=${focusSnapshot.directive.requiredNextAction}` : `supervisor_required_next_action=none`,
|
|
594762
594867
|
recentActionLines.length ? `recent_actions=${recentActions.length}` : `recent_actions=0`,
|
|
594763
594868
|
recentActionLines.length ? recentActionLines.join("\n") : "",
|
|
594764
594869
|
""
|
|
@@ -594811,7 +594916,6 @@ ${latest.output || ""}`.trim();
|
|
|
594811
594916
|
`root=${root}`,
|
|
594812
594917
|
`files=${scan.files.length}${scan.truncated ? "+" : ""} dirs=${scan.dirs.length} total_bytes=${totalBytes}`,
|
|
594813
594918
|
`artifact=${artifactDisplay}`,
|
|
594814
|
-
focusSnapshot?.directive?.requiredNextAction ? `supervisor_required_next_action=${focusSnapshot.directive.requiredNextAction}` : `supervisor_required_next_action=none`,
|
|
594815
594919
|
recentActionLines.length ? `recent_actions:
|
|
594816
594920
|
${recentActionLines.join("\n")}` : "recent_actions=none",
|
|
594817
594921
|
"Use this tree for path orientation. It includes empty directories; it does not include file contents.",
|
|
@@ -595398,9 +595502,9 @@ ${String(concreteGoal).replace(/\s+/g, " ").trim().slice(0, 1200)}` : null
|
|
|
595398
595502
|
const artifactContractBlock = this._contractRegistry.format(15);
|
|
595399
595503
|
const todoBlock = this._renderTodoStateBlock(turn);
|
|
595400
595504
|
const gitBlock = this._renderGitProgressBlock(turn);
|
|
595401
|
-
const failureBlock =
|
|
595402
|
-
const churnBlock =
|
|
595403
|
-
const focusBlock =
|
|
595505
|
+
const failureBlock = null;
|
|
595506
|
+
const churnBlock = null;
|
|
595507
|
+
const focusBlock = null;
|
|
595404
595508
|
const actionContractBlock = this._renderNextActionContract(turn);
|
|
595405
595509
|
const trajectoryCheckpoint = await this._refreshTrajectoryCheckpoint(turn, focusBlock, [
|
|
595406
595510
|
workspaceTreeBlock,
|
|
@@ -595416,8 +595520,7 @@ ${String(concreteGoal).replace(/\s+/g, " ").trim().slice(0, 1200)}` : null
|
|
|
595416
595520
|
const toolCacheBlock = recentToolResults ? this._renderKnowledgeBlock(recentToolResults) : null;
|
|
595417
595521
|
const observationBlock = process.env["OMNIUS_DISABLE_OBSERVATION_FRAME"] === "1" ? null : this._observationLedger.renderBlock(5e3);
|
|
595418
595522
|
const anchorsBlock = this.surfaceAnchors(messages2);
|
|
595419
|
-
const pprMemoryBlock =
|
|
595420
|
-
${this._lastPprMemoryLines.slice(0, 5).join("\n")}` : null;
|
|
595523
|
+
const pprMemoryBlock = null;
|
|
595421
595524
|
const activeItems = await this._collectActiveSemanticContextItems({
|
|
595422
595525
|
goalBlock,
|
|
595423
595526
|
filesystemBlock,
|
|
@@ -595506,15 +595609,6 @@ ${this._lastPprMemoryLines.slice(0, 5).join("\n")}` : null;
|
|
|
595506
595609
|
createdTurn: turn,
|
|
595507
595610
|
ttlTurns: 1
|
|
595508
595611
|
}),
|
|
595509
|
-
signalFromBlock("task_state", "turn.focus-supervisor", focusBlock, {
|
|
595510
|
-
id: "focus-supervisor",
|
|
595511
|
-
dedupeKey: "turn.focus-supervisor",
|
|
595512
|
-
semanticKey: "context.focus-supervisor",
|
|
595513
|
-
conflictGroup: "context.focus-supervisor",
|
|
595514
|
-
priority: 98,
|
|
595515
|
-
createdTurn: turn,
|
|
595516
|
-
ttlTurns: 1
|
|
595517
|
-
}),
|
|
595518
595612
|
signalFromBlock("recent_failure", "turn.failures", failureBlock, {
|
|
595519
595613
|
id: "recent-failures",
|
|
595520
595614
|
dedupeKey: "turn.failures",
|
|
@@ -598551,7 +598645,11 @@ Respond with the assessment and take the selected evidence-backed action.`;
|
|
|
598551
598645
|
}
|
|
598552
598646
|
}
|
|
598553
598647
|
const contextComposition = await this.assembleContext(task, context2);
|
|
598554
|
-
|
|
598648
|
+
const staticContextLabels = /* @__PURE__ */ new Set(["c_instr", "c_conventions", "c_state"]);
|
|
598649
|
+
let systemPrompt = contextComposition.sections.filter((section) => staticContextLabels.has(section.label)).map((section) => section.content).join("");
|
|
598650
|
+
const dynamicProjectContext = contextComposition.sections.filter((section) => !staticContextLabels.has(section.label) && section.label !== "c_lessons").map((section) => section.content).join("");
|
|
598651
|
+
if (!systemPrompt)
|
|
598652
|
+
systemPrompt = contextComposition.assembled;
|
|
598555
598653
|
try {
|
|
598556
598654
|
systemPrompt = `${systemPrompt}
|
|
598557
598655
|
|
|
@@ -598623,7 +598721,7 @@ TASK: ${scrubbedTask}` : scrubbedTask;
|
|
|
598623
598721
|
kind: "system_prompt",
|
|
598624
598722
|
capturedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
598625
598723
|
taskPreview: persistentTaskGoal.slice(0, 240),
|
|
598626
|
-
assembledCharCount: systemPrompt.length,
|
|
598724
|
+
assembledCharCount: systemPrompt.length + dynamicProjectContext.length,
|
|
598627
598725
|
totalTokenEstimate: contextComposition.totalTokenEstimate,
|
|
598628
598726
|
sections: contextComposition.sections.map((section, order) => ({
|
|
598629
598727
|
label: section.label,
|
|
@@ -598647,17 +598745,20 @@ TASK: ${scrubbedTask}` : scrubbedTask;
|
|
|
598647
598745
|
const messages2 = [
|
|
598648
598746
|
{ role: "system", content: systemPrompt },
|
|
598649
598747
|
...missionCompletionContract ? [{ role: "system", content: missionCompletionContract }] : [],
|
|
598748
|
+
...dynamicProjectContext ? [
|
|
598749
|
+
{
|
|
598750
|
+
role: "system",
|
|
598751
|
+
content: `[DYNAMIC PROJECT STATE]
|
|
598752
|
+
${dynamicProjectContext}`
|
|
598753
|
+
}
|
|
598754
|
+
] : [],
|
|
598650
598755
|
{ role: "user", content: userContent }
|
|
598651
598756
|
];
|
|
598652
598757
|
const preflightMemoryRecall = await this._buildPreflightTaskMemoryRecall(persistentTaskGoal);
|
|
598653
598758
|
if (preflightMemoryRecall) {
|
|
598654
|
-
messages2.splice(messages2.length - 1, 0, {
|
|
598655
|
-
role: "system",
|
|
598656
|
-
content: preflightMemoryRecall
|
|
598657
|
-
});
|
|
598658
598759
|
this.emit({
|
|
598659
598760
|
type: "status",
|
|
598660
|
-
content: "Preflight memory recall
|
|
598761
|
+
content: "Preflight memory recall retained for telemetry; omitted from model context",
|
|
598661
598762
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
598662
598763
|
});
|
|
598663
598764
|
}
|
|
@@ -598782,17 +598883,17 @@ TASK: ${scrubbedTask}` : scrubbedTask;
|
|
|
598782
598883
|
const reflections = this._reflectionBuffer.getRelevantReflections(persistentTaskGoal, 3);
|
|
598783
598884
|
if (reflections.length > 0) {
|
|
598784
598885
|
const reflectionCtx = this._reflectionBuffer.formatForContext(reflections);
|
|
598785
|
-
|
|
598886
|
+
void reflectionCtx;
|
|
598786
598887
|
this.emit({
|
|
598787
598888
|
type: "status",
|
|
598788
|
-
content: `Reflexion:
|
|
598889
|
+
content: `Reflexion: retained ${reflections.length} prior failure reflection(s) for telemetry only`,
|
|
598789
598890
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
598790
598891
|
});
|
|
598791
598892
|
}
|
|
598792
598893
|
}
|
|
598793
598894
|
} catch {
|
|
598794
598895
|
}
|
|
598795
|
-
if (
|
|
598896
|
+
if (false) {
|
|
598796
598897
|
try {
|
|
598797
598898
|
const failureHandoff = buildFailureModeHandoff({
|
|
598798
598899
|
taskGoal: persistentTaskGoal,
|
|
@@ -598809,8 +598910,7 @@ TASK: ${scrubbedTask}` : scrubbedTask;
|
|
|
598809
598910
|
priority: 85,
|
|
598810
598911
|
createdTurn: 0
|
|
598811
598912
|
});
|
|
598812
|
-
|
|
598813
|
-
this._contextLedger.upsert(signal);
|
|
598913
|
+
void signal;
|
|
598814
598914
|
}
|
|
598815
598915
|
} catch {
|
|
598816
598916
|
}
|
|
@@ -599605,7 +599705,7 @@ ${lastCompletionGateFeedback.trim().slice(0, 4e3)}` : ""
|
|
|
599605
599705
|
});
|
|
599606
599706
|
} else {
|
|
599607
599707
|
const directive = this._failingApproachDirective(faSignal);
|
|
599608
|
-
|
|
599708
|
+
void directive;
|
|
599609
599709
|
this.emit({
|
|
599610
599710
|
type: "adversary_reaction",
|
|
599611
599711
|
adversary: {
|
|
@@ -599642,7 +599742,7 @@ Respond with EXACTLY this structure before your next tool call:
|
|
|
599642
599742
|
NEXT ACTION: <a single creative edit — file_write / file_edit / batch_edit — that tests the picked hypothesis>
|
|
599643
599743
|
|
|
599644
599744
|
If the hypothesis cannot be tested by a creative edit, ask the human via task_complete with summary 'BLOCKED: <reason>'.`;
|
|
599645
|
-
|
|
599745
|
+
void replan;
|
|
599646
599746
|
stagnationCooldownUntilTurn = turn + 8;
|
|
599647
599747
|
const _tel58 = this._describeTopClusterTelemetry();
|
|
599648
599748
|
const _telSuffix58 = _tel58 ? `; rca3_preamble=applied; top_cluster=${_tel58.code} (${_tel58.observations}×); has_hint=${_tel58.hasHint}` : `; rca3_preamble=none`;
|
|
@@ -599673,7 +599773,7 @@ Respond with EXACTLY this structure before your next tool call:
|
|
|
599673
599773
|
WHY: <one sentence>
|
|
599674
599774
|
FALSIFICATION: <observable signal that would refute the pick>
|
|
599675
599775
|
NEXT ACTION: <a single targeted edit — file_edit / file_patch / batch_edit; file_write only for a verified-new file>`;
|
|
599676
|
-
|
|
599776
|
+
void _replan60;
|
|
599677
599777
|
stagnationCooldownUntilTurn = turn + REG60_COOLDOWN_TURNS;
|
|
599678
599778
|
const _tel60 = this._describeTopClusterTelemetry();
|
|
599679
599779
|
const _telSuffix60 = _tel60 ? `; rca3_preamble=applied; top_cluster=${_tel60.code} (${_tel60.observations}×); has_hint=${_tel60.hasHint}` : `; rca3_preamble=none`;
|
|
@@ -599738,7 +599838,7 @@ Respond with EXACTLY this structure before your next tool call:
|
|
|
599738
599838
|
].join("\n");
|
|
599739
599839
|
}
|
|
599740
599840
|
}
|
|
599741
|
-
|
|
599841
|
+
void _stagBody;
|
|
599742
599842
|
stagnationCooldownUntilTurn = turn + 5;
|
|
599743
599843
|
try {
|
|
599744
599844
|
const memMod = await Promise.resolve().then(() => (init_dist(), dist_exports));
|
|
@@ -599770,12 +599870,7 @@ Respond with EXACTLY this structure before your next tool call:
|
|
|
599770
599870
|
const recipes = this._episodeStore ? memMod.lookupBySignature(this._episodeStore, sig, 1) : [];
|
|
599771
599871
|
if (recipes.length > 0) {
|
|
599772
599872
|
const r2 = recipes[0];
|
|
599773
|
-
|
|
599774
|
-
role: "system",
|
|
599775
|
-
content: `[STAGNATION RECIPE — found from prior run with same failure shape]
|
|
599776
|
-
${r2.content}
|
|
599777
|
-
If this matches your current shape, try it before continuing.`
|
|
599778
|
-
});
|
|
599873
|
+
void r2;
|
|
599779
599874
|
this.emit({
|
|
599780
599875
|
type: "status",
|
|
599781
599876
|
content: `[STAGNATION RECIPE] surfaced prior recipe (sig=${sig}) for current failure shape`,
|
|
@@ -599943,30 +600038,6 @@ If this matches your current shape, try it before continuing.`
|
|
|
599943
600038
|
``,
|
|
599944
600039
|
` (e) REPORT BLOCKED: only when evidence shows a missing dependency, ambiguous requirement, or external service issue. State the blocker and prerequisite; do not call \`task_complete\` merely because this detector fired.`
|
|
599945
600040
|
];
|
|
599946
|
-
messages2.push({
|
|
599947
|
-
role: "system",
|
|
599948
|
-
content: [
|
|
599949
|
-
`[STUCK DETECTOR HALT — REG-44]`,
|
|
599950
|
-
``,
|
|
599951
|
-
`Window: last ${_windowCalls.length} tool calls.`,
|
|
599952
|
-
` • Reads/exploration calls: ${_readCount}`,
|
|
599953
|
-
` • Productive mutations: ${_mutationCount}`,
|
|
599954
|
-
` • Stale (cached/blocked/no-op) results: ${_staleCount}`,
|
|
599955
|
-
` • Triggers fired: ${_trigLabels.join(", ")}`,
|
|
599956
|
-
``,
|
|
599957
|
-
`You are consuming turns without accumulating decision-ready evidence or verified progress. Every shape of “stuck” — read-heavy without a narrowing question, repeated cache hits, blocked-shell loops, no-op todo updates, or blind mutation retries — can produce this signal. The exact tool names do not decide the fix; the freshest evidence does.`,
|
|
599958
|
-
``,
|
|
599959
|
-
..._reg44ChoiceLines,
|
|
599960
|
-
``,
|
|
599961
|
-
`Recent failures (real or synthetic):`,
|
|
599962
|
-
_failureBlocks,
|
|
599963
|
-
``,
|
|
599964
|
-
_staleSamples.length > 0 ? `Stale-result samples in this window:
|
|
599965
|
-
${_staleSamples.join("\n")}` : ``,
|
|
599966
|
-
``,
|
|
599967
|
-
`Do NOT in your next response: re-read a file you've already read this turn, re-run a shell command that just got blocked, or update todos without changing them. Those are the moves that landed you here.`
|
|
599968
|
-
].filter(Boolean).join("\n")
|
|
599969
|
-
});
|
|
599970
600041
|
this.emit({
|
|
599971
600042
|
type: "status",
|
|
599972
600043
|
content: `REG-44 STUCK detector fired at turn ${turn} — triggers=[${_trigLabels.join(",")}], reads=${_readCount}, mutations=${_mutationCount}, stale=${_staleCount}, window=${_windowCalls.length}`,
|
|
@@ -600037,10 +600108,7 @@ ${_staleSamples.join("\n")}` : ``,
|
|
|
600037
600108
|
callable: _smaCallable
|
|
600038
600109
|
}).then((_smaResult) => {
|
|
600039
600110
|
if (_smaResult.injection && !_smaResult.directive.parseFallback) {
|
|
600040
|
-
|
|
600041
|
-
role: "system",
|
|
600042
|
-
content: _smaResult.injection
|
|
600043
|
-
});
|
|
600111
|
+
void _smaResult.injection;
|
|
600044
600112
|
this.emit({
|
|
600045
600113
|
type: "status",
|
|
600046
600114
|
content: `REG-49 stuck-meta-analyzer fired at turn ${turn} — diagnosis="${_smaResult.directive.diagnosis.slice(0, 80)}", next=${_smaResult.directive.next_action.tool}, ${_smaResult.durationMs}ms`,
|
|
@@ -600131,19 +600199,6 @@ ${_staleSamples.join("\n")}` : ``,
|
|
|
600131
600199
|
``,
|
|
600132
600200
|
`Do NOT in your next response: write to ${_wtWorstPath} again without first running and reading the failing command's output.`
|
|
600133
600201
|
];
|
|
600134
|
-
messages2.push({
|
|
600135
|
-
role: "system",
|
|
600136
|
-
content: [
|
|
600137
|
-
`[WRITE-THRASH HALT — REG-50]`,
|
|
600138
|
-
``,
|
|
600139
|
-
`In the last ${_wtWindow.length} tool calls you have written the same file ${_wtWorstCount} times:`,
|
|
600140
|
-
` ${_wtWorstPath}`,
|
|
600141
|
-
``,
|
|
600142
|
-
`No successful test/build/typecheck command ran between writes — you are iterating the file blind, hoping the next variation works. This is a write-thrash anti-pattern. Repeated edits without verification confirm nothing.`,
|
|
600143
|
-
``,
|
|
600144
|
-
..._reg50ChoiceLines
|
|
600145
|
-
].join("\n")
|
|
600146
|
-
});
|
|
600147
600202
|
this.emit({
|
|
600148
600203
|
type: "status",
|
|
600149
600204
|
content: `REG-50 WRITE-THRASH halt fired at turn ${turn} — file=${_wtWorstPath}, count=${_wtWorstCount}/${_wtThreshold}, no successful verify in window`,
|
|
@@ -600210,10 +600265,7 @@ ${_staleSamples.join("\n")}` : ``,
|
|
|
600210
600265
|
callable: _smaCallable50
|
|
600211
600266
|
}).then((_smaResult) => {
|
|
600212
600267
|
if (_smaResult.injection && !_smaResult.directive.parseFallback) {
|
|
600213
|
-
|
|
600214
|
-
role: "system",
|
|
600215
|
-
content: _smaResult.injection
|
|
600216
|
-
});
|
|
600268
|
+
void _smaResult.injection;
|
|
600217
600269
|
this.emit({
|
|
600218
600270
|
type: "status",
|
|
600219
600271
|
content: `REG-50 → SSMA fired at turn ${turn} — diagnosis="${_smaResult.directive.diagnosis.slice(0, 80)}", next=${_smaResult.directive.next_action.tool}, ${_smaResult.durationMs}ms`,
|
|
@@ -600277,19 +600329,6 @@ ${_staleSamples.join("\n")}` : ``,
|
|
|
600277
600329
|
``,
|
|
600278
600330
|
`Do NOT in your next response: call file_edit or batch_edit on ${_efWorstPath} again with another guess at old_string.`
|
|
600279
600331
|
];
|
|
600280
|
-
messages2.push({
|
|
600281
|
-
role: "system",
|
|
600282
|
-
content: [
|
|
600283
|
-
`[EDIT-FAIL-THRASH HALT — REG-53]`,
|
|
600284
|
-
``,
|
|
600285
|
-
`In the last ${_efWindow.length} tool calls you have failed file_edit/batch_edit on the same file ${_efWorstCount} times:`,
|
|
600286
|
-
` ${_efWorstPath}`,
|
|
600287
|
-
``,
|
|
600288
|
-
`Each failure means your old_string did not match the file content. Your remembered version of this file has diverged from what's on disk — likely because an earlier edit succeeded and shifted things, or because you guessed at the file's content.`,
|
|
600289
|
-
``,
|
|
600290
|
-
..._reg53ChoiceLines
|
|
600291
|
-
].join("\n")
|
|
600292
|
-
});
|
|
600293
600332
|
this.emit({
|
|
600294
600333
|
type: "status",
|
|
600295
600334
|
content: `REG-53 EDIT-FAIL-THRASH halt fired at turn ${turn} — file=${_efWorstPath}, failures=${_efWorstCount}/${_efThreshold}`,
|
|
@@ -600367,10 +600406,7 @@ ${_staleSamples.join("\n")}` : ``,
|
|
|
600367
600406
|
callable: _pfvCallable
|
|
600368
600407
|
}).then((_pfvResult) => {
|
|
600369
600408
|
if (_pfvResult.injection && !_pfvResult.verdict.parseFallback && _pfvResult.verdict.verdict !== "continue") {
|
|
600370
|
-
|
|
600371
|
-
role: "system",
|
|
600372
|
-
content: _pfvResult.injection
|
|
600373
|
-
});
|
|
600409
|
+
void _pfvResult.injection;
|
|
600374
600410
|
this.emit({
|
|
600375
600411
|
type: "status",
|
|
600376
600412
|
content: `REG-51 PFV fired at turn ${turn} — verdict=${_pfvResult.verdict.verdict}, trigger=${_pfvTriggerReason}, ssmaCount=${this._ssmaFiredCount}, ${_pfvResult.durationMs}ms`,
|
|
@@ -600435,18 +600471,6 @@ ${_staleSamples.join("\n")}` : ``,
|
|
|
600435
600471
|
].join("\n");
|
|
600436
600472
|
}
|
|
600437
600473
|
}
|
|
600438
|
-
messages2.push({
|
|
600439
|
-
role: "system",
|
|
600440
|
-
content: [
|
|
600441
|
-
`[STICKY ESCALATION — REG-45 — failure persists across turns]`,
|
|
600442
|
-
``,
|
|
600443
|
-
`You have an unresolved high-attempt failure that you may have stopped trying to fix. Every turn that this remains unresolved, this reflection will resurface so the issue stays visible:`,
|
|
600444
|
-
``,
|
|
600445
|
-
_body,
|
|
600446
|
-
``,
|
|
600447
|
-
`If this failure is genuinely irrelevant now (e.g. the goal moved on), the only way to clear this notice is to make a successful attempt of the same call (or close-equivalent) — that resets the failure record. Otherwise, address it now.`
|
|
600448
|
-
].join("\n")
|
|
600449
|
-
});
|
|
600450
600474
|
this._stickyEscalationsSurfacedThisTurn.add(_stem);
|
|
600451
600475
|
this._reflectionsInjectedThisTurn.add(_stem);
|
|
600452
600476
|
this.emit({
|
|
@@ -600922,10 +600946,11 @@ ${memoryLines.join("\n")}`
|
|
|
600922
600946
|
const echoBoostedTemp = this._echoTempBoostTurns > 0 ? Math.max(this.options.temperature ?? 0, 0.7) : this.options.temperature;
|
|
600923
600947
|
if (this._echoTempBoostTurns > 0)
|
|
600924
600948
|
this._echoTempBoostTurns--;
|
|
600925
|
-
|
|
600926
|
-
|
|
600927
|
-
|
|
600928
|
-
|
|
600949
|
+
this._stripLegacyControlMessages(requestMessages);
|
|
600950
|
+
requestMessages.push({
|
|
600951
|
+
role: "system",
|
|
600952
|
+
content: this._buildRecentActionGroundTruth(turn)
|
|
600953
|
+
});
|
|
600929
600954
|
this._retireLinkedAssistantReadIntents(requestMessages);
|
|
600930
600955
|
const chatRequest = {
|
|
600931
600956
|
messages: requestMessages,
|
|
@@ -601470,10 +601495,7 @@ Corrective action: try a different approach first: read relevant files, adjust a
|
|
|
601470
601495
|
const pattern = rawPattern;
|
|
601471
601496
|
if (pattern.tool === tc.name && (pattern.count ?? 0) >= 2 && !currentRunToolAlreadySucceeded && !this._errorGuidanceInjected.has(sig)) {
|
|
601472
601497
|
this._errorGuidanceInjected.add(sig);
|
|
601473
|
-
|
|
601474
|
-
role: "system",
|
|
601475
|
-
content: `[LEARNED FROM EXPERIENCE] ${tc.name} has failed ${pattern.count} times with "${pattern.errorType}" errors. Guidance: ${pattern.guidance}`
|
|
601476
|
-
});
|
|
601498
|
+
void pattern;
|
|
601477
601499
|
}
|
|
601478
601500
|
}
|
|
601479
601501
|
}
|
|
@@ -601688,7 +601710,7 @@ Corrective action: try a different approach first: read relevant files, adjust a
|
|
|
601688
601710
|
``,
|
|
601689
601711
|
_localFailureNudge
|
|
601690
601712
|
].join("\n");
|
|
601691
|
-
|
|
601713
|
+
void reg61SteerMsg;
|
|
601692
601714
|
this.emit({
|
|
601693
601715
|
type: "status",
|
|
601694
601716
|
content: `REG-61 STEER — nudge injected for '${tc.name}' at turn ${turn}; tool ALLOWED; gate stays active${_dbgLoop.detected ? `; REG-66 debug-loop variant (${_dbgLoop.kind} "${_debugLoopSampleSafe.slice(0, 60)}" ${_dbgLoop.count}×)` : ""}`,
|
|
@@ -602031,11 +602053,8 @@ Read the current file if needed, make a different concrete edit, or move to veri
|
|
|
602031
602053
|
].join("\n");
|
|
602032
602054
|
}
|
|
602033
602055
|
}
|
|
602034
|
-
|
|
602035
|
-
|
|
602036
|
-
} else {
|
|
602037
|
-
pushSoftInjection("system", _reflBody);
|
|
602038
|
-
}
|
|
602056
|
+
void _isEscalation;
|
|
602057
|
+
void _reflBody;
|
|
602039
602058
|
this.emit({
|
|
602040
602059
|
type: "status",
|
|
602041
602060
|
content: `REG-26 reflection surfaced for stem '${_reflStem.slice(0, 60)}' (attempts=${_reflEntry.attempts}, distinct_errors=${_reflEntry.errorSignatures?.size ?? 0}, escalation=${_isEscalation})`,
|
|
@@ -602231,7 +602250,7 @@ ${cachedResult}`,
|
|
|
602231
602250
|
});
|
|
602232
602251
|
if (focusDecision.kind === "block_tool_call" && this._maybeAutoDelegate(tc, focusDecision.directive, messages2, turn)) {
|
|
602233
602252
|
} else if (focusDecision.kind === "inject_guidance") {
|
|
602234
|
-
|
|
602253
|
+
void focusDecision.message;
|
|
602235
602254
|
} else if (!repeatShortCircuit) {
|
|
602236
602255
|
repeatShortCircuit = {
|
|
602237
602256
|
success: focusDecision.success,
|
|
@@ -602606,21 +602625,7 @@ ${cachedResult}`,
|
|
|
602606
602625
|
});
|
|
602607
602626
|
if (process.env["OMNIUS_DISABLE_REG59"] !== "1") {
|
|
602608
602627
|
const _errCtx59 = this._buildErrorContextPreamble();
|
|
602609
|
-
|
|
602610
|
-
role: "system",
|
|
602611
|
-
content: `[STAGNATION REPLAN — REG-59 same-error escalation]
|
|
602612
|
-
The error cluster you keep hitting has occurred 5+ times. Your current approach is NOT working. STOP retrying it.
|
|
602613
|
-
` + _errCtx59 + `
|
|
602614
|
-
Respond with EXACTLY this structure before your next tool call:
|
|
602615
|
-
HYPOTHESES (3 NEW theories — must be DIFFERENT from anything tried so far):
|
|
602616
|
-
1. ...
|
|
602617
|
-
2. ...
|
|
602618
|
-
3. ...
|
|
602619
|
-
PICK: <number 1-3>
|
|
602620
|
-
WHY: <one sentence — what makes this hypothesis NEW>
|
|
602621
|
-
FALSIFICATION: <observable signal that would refute the pick>
|
|
602622
|
-
NEXT ACTION: <single tool call that tests the picked hypothesis — preferably a creative edit, not a read>`
|
|
602623
|
-
});
|
|
602628
|
+
void _errCtx59;
|
|
602624
602629
|
stagnationCooldownUntilTurn = turn + 8;
|
|
602625
602630
|
const _tel59 = this._describeTopClusterTelemetry();
|
|
602626
602631
|
const _telSuffix59 = _tel59 ? `; rca3_preamble=applied; top_cluster=${_tel59.code} (${_tel59.observations}×); has_hint=${_tel59.hasHint}` : `; rca3_preamble=none`;
|
|
@@ -603643,7 +603648,7 @@ Respond with EXACTLY this structure before your next tool call:
|
|
|
603643
603648
|
``,
|
|
603644
603649
|
this._renderLocalFailureNudge(turn)
|
|
603645
603650
|
].join("\n");
|
|
603646
|
-
|
|
603651
|
+
void opaqueMessage;
|
|
603647
603652
|
this.emit({
|
|
603648
603653
|
type: "status",
|
|
603649
603654
|
content: `REG-32 opaque-error local nudge fired for stem '${_refStem.slice(0, 60)}'`,
|
|
@@ -604311,8 +604316,7 @@ Then use file_read on individual FILES inside it.`);
|
|
|
604311
604316
|
createdTurn: turn,
|
|
604312
604317
|
ttlTurns: 4
|
|
604313
604318
|
});
|
|
604314
|
-
|
|
604315
|
-
this._contextLedger.upsert(signal);
|
|
604319
|
+
void signal;
|
|
604316
604320
|
lastShellPivotTurn = turn;
|
|
604317
604321
|
this.emit({
|
|
604318
604322
|
type: "status",
|
|
@@ -604321,7 +604325,7 @@ Then use file_read on individual FILES inside it.`);
|
|
|
604321
604325
|
});
|
|
604322
604326
|
}
|
|
604323
604327
|
}
|
|
604324
|
-
if (
|
|
604328
|
+
if (false) {
|
|
604325
604329
|
const runtimeHandoff = buildFailureModeHandoff({
|
|
604326
604330
|
taskGoal: persistentTaskGoal,
|
|
604327
604331
|
errorPatterns: this._taskRelevantErrorPatterns,
|
|
@@ -604338,8 +604342,7 @@ Then use file_read on individual FILES inside it.`);
|
|
|
604338
604342
|
createdTurn: turn,
|
|
604339
604343
|
ttlTurns: 4
|
|
604340
604344
|
});
|
|
604341
|
-
|
|
604342
|
-
this._contextLedger.upsert(signal);
|
|
604345
|
+
void signal;
|
|
604343
604346
|
lastFailureHandoffTurn = turn;
|
|
604344
604347
|
}
|
|
604345
604348
|
}
|
|
@@ -604366,8 +604369,7 @@ Then use file_read on individual FILES inside it.`);
|
|
|
604366
604369
|
return {
|
|
604367
604370
|
tc,
|
|
604368
604371
|
output,
|
|
604369
|
-
success: result.success
|
|
604370
|
-
...runtimeSystemGuidance ? { systemGuidance: runtimeSystemGuidance } : {}
|
|
604372
|
+
success: result.success
|
|
604371
604373
|
};
|
|
604372
604374
|
};
|
|
604373
604375
|
const rawToolCalls = msg.toolCalls;
|
|
@@ -604494,12 +604496,7 @@ ${sr.result.output}`;
|
|
|
604494
604496
|
const r2 = await executeSingle(tc);
|
|
604495
604497
|
if (r2) {
|
|
604496
604498
|
messages2.push(this.buildModelFacingToolMessage(r2.output, r2.tc.id, r2.tc.name, r2.tc.arguments, r2.success));
|
|
604497
|
-
|
|
604498
|
-
messages2.push({
|
|
604499
|
-
role: "system",
|
|
604500
|
-
content: r2.systemGuidance
|
|
604501
|
-
});
|
|
604502
|
-
}
|
|
604499
|
+
void r2.systemGuidance;
|
|
604503
604500
|
if (r2.tc.name === "task_complete") {
|
|
604504
604501
|
if (!r2.success) {
|
|
604505
604502
|
messages2.push({
|
|
@@ -604608,12 +604605,7 @@ ${sr.result.output}`;
|
|
|
604608
604605
|
for (const r2 of results) {
|
|
604609
604606
|
if (r2) {
|
|
604610
604607
|
messages2.push(this.buildModelFacingToolMessage(r2.output, r2.tc.id, r2.tc.name, r2.tc.arguments, r2.success));
|
|
604611
|
-
|
|
604612
|
-
messages2.push({
|
|
604613
|
-
role: "system",
|
|
604614
|
-
content: r2.systemGuidance
|
|
604615
|
-
});
|
|
604616
|
-
}
|
|
604608
|
+
void r2.systemGuidance;
|
|
604617
604609
|
if (r2.tc.name === "task_complete") {
|
|
604618
604610
|
if (!r2.success) {
|
|
604619
604611
|
messages2.push({
|
|
@@ -604704,21 +604696,7 @@ ${sr.result.output}`;
|
|
|
604704
604696
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
604705
604697
|
});
|
|
604706
604698
|
const partialResults = this._taskState.completedSteps.length > 0 ? this._taskState.completedSteps.join(". ") : `Progress made before loop: ${topRepeated}`;
|
|
604707
|
-
|
|
604708
|
-
role: "system",
|
|
604709
|
-
content: `LOOP CIRCUIT BREAKER: ${loopInterventionCount} interventions attempted but repetition continues.
|
|
604710
|
-
|
|
604711
|
-
MANDATORY: Change state before taking another action. Choose one:
|
|
604712
|
-
1. Try a completely different approach
|
|
604713
|
-
2. Re-read the exact current target once if the loop is caused by a stale edit
|
|
604714
|
-
3. Run verification if files changed since the last successful check
|
|
604715
|
-
4. Call ask_user if user input is the real blocker
|
|
604716
|
-
5. Report blocked/incomplete with the concrete blocker if no safe progress path remains
|
|
604717
|
-
|
|
604718
|
-
Your partial progress: ${partialResults}
|
|
604719
|
-
|
|
604720
|
-
Do not call task_complete solely because this circuit breaker fired.`
|
|
604721
|
-
});
|
|
604699
|
+
void partialResults;
|
|
604722
604700
|
loopInterventionCount = 0;
|
|
604723
604701
|
}
|
|
604724
604702
|
const findings = [];
|
|
@@ -604816,10 +604794,7 @@ Only call task_complete when the task is actually complete and the evidence is f
|
|
|
604816
604794
|
callable: _smaCallable
|
|
604817
604795
|
}).then((_smaResult) => {
|
|
604818
604796
|
if (_smaResult.injection && !_smaResult.directive.parseFallback) {
|
|
604819
|
-
|
|
604820
|
-
role: "system",
|
|
604821
|
-
content: _smaResult.injection
|
|
604822
|
-
});
|
|
604797
|
+
void _smaResult.injection;
|
|
604823
604798
|
this.emit({
|
|
604824
604799
|
type: "status",
|
|
604825
604800
|
content: `REG-49 stuck-meta-analyzer fired (loop-intervention path) at turn ${turn} — diagnosis="${_smaResult.directive.diagnosis.slice(0, 80)}", next=${_smaResult.directive.next_action.tool}, ${_smaResult.durationMs}ms`,
|
|
@@ -605229,13 +605204,11 @@ ${this.options.maxTurns && this.options.maxTurns > 0 ? `You have ${this.options.
|
|
|
605229
605204
|
const bfEchoBoostedTemp = this._echoTempBoostTurns > 0 ? Math.max(this.options.temperature ?? 0, 0.7) : this.options.temperature;
|
|
605230
605205
|
if (this._echoTempBoostTurns > 0)
|
|
605231
605206
|
this._echoTempBoostTurns--;
|
|
605232
|
-
|
|
605233
|
-
|
|
605234
|
-
|
|
605235
|
-
|
|
605236
|
-
|
|
605237
|
-
});
|
|
605238
|
-
}
|
|
605207
|
+
this._stripLegacyControlMessages(modelFacingMessages);
|
|
605208
|
+
modelFacingMessages.push({
|
|
605209
|
+
role: "system",
|
|
605210
|
+
content: this._buildRecentActionGroundTruth(turn)
|
|
605211
|
+
});
|
|
605239
605212
|
const chatRequest = {
|
|
605240
605213
|
messages: modelFacingMessages,
|
|
605241
605214
|
tools: toolDefs,
|
|
@@ -605394,12 +605367,7 @@ ${this.options.maxTurns && this.options.maxTurns > 0 ? `You have ${this.options.
|
|
|
605394
605367
|
messages2.push(this.buildModelFacingToolMessage(r2.output, r2.tc.id, r2.tc.name, r2.tc.arguments, r2.success));
|
|
605395
605368
|
this._toolLastUsedTurn.set(r2.tc.name, turn);
|
|
605396
605369
|
this._advanceContextTreeOnToolCall(r2.tc.name, this._buildExactArgsKey(r2.tc.arguments ?? {}), turn, messages2);
|
|
605397
|
-
|
|
605398
|
-
messages2.push({
|
|
605399
|
-
role: "system",
|
|
605400
|
-
content: r2.systemGuidance
|
|
605401
|
-
});
|
|
605402
|
-
}
|
|
605370
|
+
void r2.systemGuidance;
|
|
605403
605371
|
if (r2.tc.name === "task_complete") {
|
|
605404
605372
|
if (!r2.success) {
|
|
605405
605373
|
messages2.push({
|
|
@@ -608187,8 +608155,7 @@ ${tail}`;
|
|
|
608187
608155
|
createdTurn: turn,
|
|
608188
608156
|
ttlTurns: 20
|
|
608189
608157
|
});
|
|
608190
|
-
|
|
608191
|
-
this._contextLedger.upsert(signal);
|
|
608158
|
+
void signal;
|
|
608192
608159
|
}
|
|
608193
608160
|
this.emit({
|
|
608194
608161
|
type: "user_interrupt",
|
|
@@ -608623,37 +608590,13 @@ Describe what you see and integrate this into your current approach.` : "[User s
|
|
|
608623
608590
|
let middle = messages2.slice(headEndIdx, recentStart);
|
|
608624
608591
|
if (middle.length === 0)
|
|
608625
608592
|
return messages2;
|
|
608626
|
-
const
|
|
608627
|
-
|
|
608628
|
-
|
|
608629
|
-
|
|
608630
|
-
"[PROBLEM-FRAME VALIDATION — REG-51",
|
|
608631
|
-
"[EDIT-FAIL-THRASH HALT — REG-53]"
|
|
608632
|
-
];
|
|
608633
|
-
const isDefenseDirective = (msg) => {
|
|
608634
|
-
const c9 = typeof msg.content === "string" ? msg.content : "";
|
|
608635
|
-
return msg.role === "system" && DEFENSE_DIRECTIVE_PREFIXES.some((pfx) => c9.startsWith(pfx));
|
|
608636
|
-
};
|
|
608637
|
-
const stickyDefenses = [];
|
|
608638
|
-
const filteredMiddle = [];
|
|
608639
|
-
for (const msg of middle) {
|
|
608640
|
-
if (isDefenseDirective(msg))
|
|
608641
|
-
stickyDefenses.push(msg);
|
|
608642
|
-
else
|
|
608643
|
-
filteredMiddle.push(msg);
|
|
608644
|
-
}
|
|
608645
|
-
const filteredRecent = [];
|
|
608646
|
-
for (const msg of recent) {
|
|
608647
|
-
if (isDefenseDirective(msg))
|
|
608648
|
-
stickyDefenses.push(msg);
|
|
608649
|
-
else
|
|
608650
|
-
filteredRecent.push(msg);
|
|
608651
|
-
}
|
|
608652
|
-
const stickyToKeep = stickyDefenses.slice(-10);
|
|
608653
|
-
if (stickyToKeep.length > 0) {
|
|
608593
|
+
const filteredMiddle = middle.filter((message2) => !this._isLegacyControlMessage(message2));
|
|
608594
|
+
const filteredRecent = recent.filter((message2) => !this._isLegacyControlMessage(message2));
|
|
608595
|
+
const retiredLegacyCount = middle.length + recent.length - filteredMiddle.length - filteredRecent.length;
|
|
608596
|
+
if (retiredLegacyCount > 0) {
|
|
608654
608597
|
this.emit({
|
|
608655
608598
|
type: "status",
|
|
608656
|
-
content: `
|
|
608599
|
+
content: `Controller cleanup retired ${retiredLegacyCount} legacy REG/recovery message(s) during compaction`,
|
|
608657
608600
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
608658
608601
|
});
|
|
608659
608602
|
}
|
|
@@ -608921,7 +608864,6 @@ ${telegramPersonaHead}` : stripped
|
|
|
608921
608864
|
let result = [
|
|
608922
608865
|
...narrowedHead,
|
|
608923
608866
|
compactionMsg,
|
|
608924
|
-
...stickyToKeep,
|
|
608925
608867
|
...filteredRecent
|
|
608926
608868
|
];
|
|
608927
608869
|
const fileRecoveryBudget = Math.floor((this._branchRoutingContextWindow() || 32768) * 0.15);
|
|
@@ -609021,10 +608963,9 @@ ${content.slice(0, 8e3)}${truncated ? "\n[truncated recovery; use a narrow live
|
|
|
609021
608963
|
createdTurn: this._taskState.toolCallCount,
|
|
609022
608964
|
ttlTurns: 8
|
|
609023
608965
|
});
|
|
609024
|
-
|
|
609025
|
-
this._contextLedger.upsert(signal);
|
|
608966
|
+
void signal;
|
|
609026
608967
|
}
|
|
609027
|
-
if (
|
|
608968
|
+
if (false) {
|
|
609028
608969
|
try {
|
|
609029
608970
|
const compactFailureHandoff = buildFailureModeHandoff({
|
|
609030
608971
|
taskGoal: this._taskState.goal,
|
|
@@ -609041,8 +608982,7 @@ ${content.slice(0, 8e3)}${truncated ? "\n[truncated recovery; use a narrow live
|
|
|
609041
608982
|
createdTurn: this._taskState.toolCallCount,
|
|
609042
608983
|
ttlTurns: 8
|
|
609043
608984
|
});
|
|
609044
|
-
|
|
609045
|
-
this._contextLedger.upsert(signal);
|
|
608985
|
+
void signal;
|
|
609046
608986
|
}
|
|
609047
608987
|
} catch {
|
|
609048
608988
|
}
|
|
@@ -609084,7 +609024,6 @@ ${content.slice(0, 8e3)}${truncated ? "\n[truncated recovery; use a narrow live
|
|
|
609084
609024
|
result = [
|
|
609085
609025
|
...narrowedHead,
|
|
609086
609026
|
compactionMsg,
|
|
609087
|
-
...stickyToKeep,
|
|
609088
609027
|
...protectedRecoveryMessages,
|
|
609089
609028
|
...trimmedRecent
|
|
609090
609029
|
];
|
|
@@ -609290,22 +609229,49 @@ ${trimmedNew}`;
|
|
|
609290
609229
|
this._recentToolOutcomes.shift();
|
|
609291
609230
|
}
|
|
609292
609231
|
}
|
|
609293
|
-
/**
|
|
609232
|
+
/**
|
|
609233
|
+
* The only late control block visible to a model. It is regenerated from
|
|
609234
|
+
* authoritative run state on each request; it never carries prompt history.
|
|
609235
|
+
* Large models receive state only. Small/medium models may receive one
|
|
609236
|
+
* bounded directive with an explicit expiry and exit condition.
|
|
609237
|
+
*/
|
|
609294
609238
|
_buildRecentActionGroundTruth(turn) {
|
|
609295
609239
|
const activePaths = [...this._taskState.modifiedFiles.entries()].map(([rawPath, rawAction]) => ({
|
|
609296
609240
|
path: this._normalizeEvidencePath(rawPath),
|
|
609297
609241
|
rawAction
|
|
609298
|
-
})).filter((entry) => entry.path && !entry.path.startsWith(".omnius/")).slice(-
|
|
609299
|
-
|
|
609300
|
-
|
|
609242
|
+
})).filter((entry) => entry.path && !entry.path.startsWith(".omnius/")).slice(-5);
|
|
609243
|
+
const todos = this.readSessionTodos() ?? [];
|
|
609244
|
+
const todoCounts = todos.reduce((counts, todo) => {
|
|
609245
|
+
const status = String(todo.status ?? "pending");
|
|
609246
|
+
if (status === "completed")
|
|
609247
|
+
counts.completed++;
|
|
609248
|
+
else if (status === "blocked")
|
|
609249
|
+
counts.blocked++;
|
|
609250
|
+
else if (status === "in_progress")
|
|
609251
|
+
counts.inProgress++;
|
|
609252
|
+
else
|
|
609253
|
+
counts.pending++;
|
|
609254
|
+
return counts;
|
|
609255
|
+
}, { completed: 0, blocked: 0, inProgress: 0, pending: 0 });
|
|
609256
|
+
const activeLeaf = todos.find((todo) => ["in_progress", "pending", "open", "needs_changes"].includes(String(todo.status ?? "")));
|
|
609301
609257
|
const verifier = this._worldFacts.lastTest;
|
|
609302
609258
|
const verifierState = verifier?.summary ? `outcome=${verifier.passed ? "passed" : "failed"} turn=${verifier.turn ?? "?"}` : "outcome=not_recorded";
|
|
609303
609259
|
const verifierRequired = this._compileFixLoop?.active === true && this._compileFixLoop.verifierDirtySinceTurn !== null;
|
|
609260
|
+
const intent = this._taskState.originalGoal || this._taskState.goal || this._taskState.currentStep || "unspecified";
|
|
609304
609261
|
const lines = [
|
|
609305
|
-
"[
|
|
609306
|
-
`turn=${turn}
|
|
609262
|
+
"[CONTROLLER STATE v1]",
|
|
609263
|
+
`task_epoch=${this._taskEpoch} turn=${turn} state_version=${this._adversaryStateVersion}`,
|
|
609264
|
+
`user_intent=${intent.replace(/\s+/g, " ").slice(0, 700)}`,
|
|
609265
|
+
`active_leaf=${String(activeLeaf?.content ?? this._taskState.currentStep ?? this._taskState.nextAction ?? "none").replace(/\s+/g, " ").slice(0, 360)}`,
|
|
609266
|
+
`todo_counts=completed:${todoCounts.completed},in_progress:${todoCounts.inProgress},pending:${todoCounts.pending},blocked:${todoCounts.blocked}`,
|
|
609307
609267
|
`verifier=${verifierState}`
|
|
609308
609268
|
];
|
|
609269
|
+
const tier = this.options.modelTier ?? "large";
|
|
609270
|
+
const directive = this._focusSupervisor?.snapshot().directive;
|
|
609271
|
+
if (directive && tier !== "large") {
|
|
609272
|
+
const expiresTurn = Math.max(turn + 1, directive.createdTurn + 6);
|
|
609273
|
+
lines.push(`active_directive=next_action:${directive.requiredNextAction}; evidence:${directive.reason.replace(/\s+/g, " ").slice(0, 260)}; expires_turn:${expiresTurn}; exit_when:action_evidence_or_verified_mutation_or_user_redirect`);
|
|
609274
|
+
}
|
|
609309
609275
|
for (const entry of activePaths) {
|
|
609310
609276
|
const action = /creat/i.test(entry.rawAction) ? "created" : /delet/i.test(entry.rawAction) ? "deleted" : "modified";
|
|
609311
609277
|
const evidence = this._evidenceLedger.get(entry.path);
|
|
@@ -609318,8 +609284,20 @@ ${trimmedNew}`;
|
|
|
609318
609284
|
const doNot = action === "created" ? "do_not_create_again" : action === "modified" ? "do_not_full_rewrite_without_fresh_read" : "do_not_recreate_without_authoritative_target";
|
|
609319
609285
|
lines.push(`${action} path=${entry.path} hash=${hash} bytes=${bytes} ${resultState} stateVersion=${outcome?.stateVersion ?? this._adversaryStateVersion} turn=${outcome?.turn ?? turn} next_valid_action=${nextAction} ${doNot}`);
|
|
609320
609286
|
}
|
|
609321
|
-
lines.push("
|
|
609322
|
-
return lines.join("\n").slice(0,
|
|
609287
|
+
lines.push("action_ground_truth=tool-derived only; controller artifacts and bookkeeping do not count as progress");
|
|
609288
|
+
return lines.join("\n").slice(0, 4200);
|
|
609289
|
+
}
|
|
609290
|
+
/** Legacy REG/recovery prose is retained in telemetry only, never in model history. */
|
|
609291
|
+
_isLegacyControlMessage(message2) {
|
|
609292
|
+
if (message2.role !== "system" || typeof message2.content !== "string")
|
|
609293
|
+
return false;
|
|
609294
|
+
return /^(?:\[(?:FIRST-EDIT NUDGE|STAGNATION(?: REPLAN| RECIPE)|STUCK DETECTOR HALT|STUCK-STATE META-ANALYZER|WRITE-THRASH HALT|EDIT-FAIL-THRASH HALT|PROBLEM-FRAME VALIDATION|STICKY ESCALATION|INTRA-RUN LESSON|LEARNED FROM EXPERIENCE|FOCUS SUPERVISOR|REG-\d+ directive active|OPAQUE LOCAL ERROR|LOCAL ERROR-INFORMED NUDGE|PRIOR LESSONS|FAILURE-MODE INTAKE|REFLECTION|Associative Memory)|LOOP CIRCUIT BREAKER)/.test(message2.content);
|
|
609295
|
+
}
|
|
609296
|
+
_stripLegacyControlMessages(messages2) {
|
|
609297
|
+
for (let index = messages2.length - 1; index >= 0; index--) {
|
|
609298
|
+
if (this._isLegacyControlMessage(messages2[index]))
|
|
609299
|
+
messages2.splice(index, 1);
|
|
609300
|
+
}
|
|
609323
609301
|
}
|
|
609324
609302
|
/** Mark a workboard target complete when a confirmed creation satisfies it. */
|
|
609325
609303
|
_reconcileCreationGroundTruth(toolName, args, result, turn) {
|