@sema-agent/core 7.11.1 → 7.11.2
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/CHANGELOG.md +20 -8
- package/dist/core/runner/compaction-knobs.d.ts +45 -0
- package/dist/core/runner/compaction-knobs.js +3 -0
- package/dist/core/runner/contracts.d.ts +8 -1
- package/dist/core/runner/run-attachment-seats.d.ts +20 -0
- package/dist/core/runner/run-attachment-seats.js +187 -0
- package/dist/core/runner/run-brain-sinks.d.ts +29 -0
- package/dist/core/runner/run-brain-sinks.js +61 -0
- package/dist/core/runner/run-clock-and-content.d.ts +52 -0
- package/dist/core/runner/run-clock-and-content.js +26 -0
- package/dist/core/runner/run-compaction-machinery.d.ts +35 -0
- package/dist/core/runner/run-compaction-machinery.js +98 -0
- package/dist/core/runner/run-git-lane.d.ts +64 -0
- package/dist/core/runner/run-git-lane.js +102 -0
- package/dist/core/runner/run-identity-wiring.d.ts +96 -0
- package/dist/core/runner/run-identity-wiring.js +84 -0
- package/dist/core/runner/run-reasoning-seat.d.ts +27 -0
- package/dist/core/runner/run-reasoning-seat.js +48 -0
- package/dist/core/runner/run-recovery-lanes.d.ts +54 -0
- package/dist/core/runner/run-recovery-lanes.js +180 -0
- package/dist/core/runner/run-stop-and-final-verify.d.ts +32 -0
- package/dist/core/runner/run-stop-and-final-verify.js +159 -0
- package/dist/core/runner/run-telemetry-and-budget-seats.d.ts +38 -0
- package/dist/core/runner/run-telemetry-and-budget-seats.js +159 -0
- package/dist/core/runner/run-tool-mount-facts.d.ts +26 -0
- package/dist/core/runner/run-tool-mount-facts.js +58 -0
- package/dist/core/runner/run-turn-boundary.d.ts +0 -35
- package/dist/core/runner/run-turn-boundary.js +1 -3
- package/dist/core/runner/runtask.js +94 -1116
- package/dist/tools/fs/fs-bash.js +3 -2
- package/package.json +1 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { CONFIG_CATALOG_VERSION, declarationReasons, resolveEffectiveConfig } from "../../config/catalog.js";
|
|
2
|
+
import { engineVersion } from "../version.js";
|
|
3
|
+
import { emitTrace } from "../trace.js";
|
|
4
|
+
import { writeFamilyOfCanonical } from "./tool-end-body.js";
|
|
5
|
+
export function runToolMountFacts(input) {
|
|
6
|
+
const { spec, prepared, rs } = input;
|
|
7
|
+
const todoToolMounted = rs.attach.attachState !== undefined && prepared.tools.some((t) => t.name === "TodoWrite");
|
|
8
|
+
const taskToolsMounted = rs.attach.attachState !== undefined && prepared.tools.some((t) => t.name === "TaskCreate");
|
|
9
|
+
const writeFamilyByName = new Map();
|
|
10
|
+
if (rs.attach.attachState !== undefined) {
|
|
11
|
+
for (const t of prepared.tools) {
|
|
12
|
+
const family = writeFamilyOfCanonical(t.name);
|
|
13
|
+
if (family !== undefined)
|
|
14
|
+
for (const n of [t.name, ...(t.aliases ?? [])])
|
|
15
|
+
writeFamilyByName.set(n, family);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const writeFamilyOf = (name) => writeFamilyByName.get(name) ?? writeFamilyOfCanonical(name);
|
|
19
|
+
const toolStartAt = new Map();
|
|
20
|
+
const startedToolCallIds = new Set();
|
|
21
|
+
emitTrace(rs.telemetry.tracer, () => ({ kind: "task.start", version: 1, taskId: rs.telemetry.taskId, runId: rs.telemetry.runId, model: prepared.model.id, engineVersion: engineVersion(), ts: rs.telemetry.taskStart }));
|
|
22
|
+
emitTrace(rs.telemetry.tracer, () => ({
|
|
23
|
+
kind: "prompt.assembled",
|
|
24
|
+
version: 1,
|
|
25
|
+
taskId: rs.telemetry.taskId,
|
|
26
|
+
constitution: prepared.promptManifest.constitution,
|
|
27
|
+
blocks: prepared.promptManifest.blocks,
|
|
28
|
+
...(prepared.promptManifest.sections ? { sections: prepared.promptManifest.sections } : {}),
|
|
29
|
+
...(prepared.promptManifest.tools ? { tools: prepared.promptManifest.tools } : {}),
|
|
30
|
+
...(prepared.promptManifest.snapshot ? { snapshot: prepared.promptManifest.snapshot } : {}),
|
|
31
|
+
...(prepared.promptManifest.lowering ? { lowering: prepared.promptManifest.lowering } : {}),
|
|
32
|
+
...(prepared.promptManifest.toolDisclosure ? { toolDisclosure: prepared.promptManifest.toolDisclosure } : {}),
|
|
33
|
+
totalChars: prepared.promptManifest.blocks.reduce((n, b) => n + b.chars, 0),
|
|
34
|
+
ts: rs.telemetry.taskStart,
|
|
35
|
+
}));
|
|
36
|
+
emitTrace(rs.telemetry.tracer, () => {
|
|
37
|
+
const reasons = declarationReasons(spec.configOverrides);
|
|
38
|
+
return {
|
|
39
|
+
kind: "config.assembled",
|
|
40
|
+
version: 1,
|
|
41
|
+
taskId: rs.telemetry.taskId,
|
|
42
|
+
catalogVersion: CONFIG_CATALOG_VERSION,
|
|
43
|
+
fields: resolveEffectiveConfig(spec, { modelMaxTokens: prepared.model.maxTokens }),
|
|
44
|
+
...(Object.keys(reasons).length > 0 ? { overrideReasons: reasons } : {}),
|
|
45
|
+
ts: rs.telemetry.taskStart,
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
if (prepared.turnSnapshot !== undefined) {
|
|
49
|
+
prepared.turnSnapshot.onChange = (snap) => emitTrace(rs.telemetry.tracer, () => ({
|
|
50
|
+
kind: "prompt.snapshot_changed",
|
|
51
|
+
version: 1,
|
|
52
|
+
taskId: rs.telemetry.taskId,
|
|
53
|
+
snapshot: { cacheIdentity: snap.cacheIdentity, elements: { ...snap.elements } },
|
|
54
|
+
ts: Date.now(),
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
return { todoToolMounted, taskToolsMounted, writeFamilyOf, toolStartAt, startedToolCallIds };
|
|
58
|
+
}
|
|
@@ -1,41 +1,6 @@
|
|
|
1
1
|
import type { Model } from "../../internal/llm.js";
|
|
2
2
|
import type { Stats } from "./assemble-result.js";
|
|
3
3
|
import type { Prepared, RunState, TurnBoundaryDeps } from "./contracts.js";
|
|
4
|
-
/**
|
|
5
|
-
* §17.4 (design/64 GAP-25): stop attempting within-task compaction after this many CONSECUTIVE
|
|
6
|
-
* failures in one task — a never-recovering summary gateway must not burn an API call at every turn
|
|
7
|
-
* boundary (CC: MAX_CONSECUTIVE_AUTOCOMPACT_FAILURES = 3). Reset on any success; an open breaker also
|
|
8
|
-
* skips the end-of-task attempt in `finish()` (teardown unaffected). Per-task scope.
|
|
9
|
-
*
|
|
10
|
-
* RB-190 — this used to say "a flaky/never-recovering gateway", and the word `flaky` was not true. Because
|
|
11
|
-
* any success zeroes the counter, a gateway that alternates never reaches three CONSECUTIVE failures and
|
|
12
|
-
* the breaker never opens; it keeps paying for a call at every failed boundary, indefinitely.
|
|
13
|
-
*
|
|
14
|
-
* The behaviour is right and stays: a gateway succeeding half the time is compacting half the time, and
|
|
15
|
-
* opening the breaker on it would disable compaction outright and let the context overflow — trading a
|
|
16
|
-
* wasted call for a failed task. What was wrong is the comment claiming a guarantee the code does not
|
|
17
|
-
* make. An alternating gateway is deliberately NOT caught here; if that ever needs catching it wants a
|
|
18
|
-
* different signal (a failure RATE over a window), not a consecutive counter.
|
|
19
|
-
*/
|
|
20
|
-
export declare const MAX_CONSECUTIVE_COMPACTION_FAILURES = 3;
|
|
21
|
-
/**
|
|
22
|
-
* §25.2 anti-thrash (LONGRUN-1b, search [84]): after a compaction, the context must regrow past
|
|
23
|
-
* (tokensBefore − freed) × this factor — the post-compaction size in trigger units — before another
|
|
24
|
-
* summary call fires. An EFFECTIVE compaction (freed large) leaves the floor far below the threshold,
|
|
25
|
-
* so behavior is unchanged; an INEFFECTIVE one (small window, chunky turns, large summary ⇒ freed
|
|
26
|
-
* small, still at/over the threshold) raises the floor so attempts space out instead of firing at
|
|
27
|
-
* every boundary (measured: 26/39 boundaries, +135% wall). The floor binds only when post-compaction
|
|
28
|
-
* size > threshold/1.5 ≈ compaction freed <33% headroom. Degrades gracefully: the retained summary
|
|
29
|
-
* chain keeps early facts; only the un-summarized tail falls back to trim.
|
|
30
|
-
*/
|
|
31
|
-
export declare const COMPACTION_REGROWTH_FACTOR = 1.5;
|
|
32
|
-
/**
|
|
33
|
-
* design/84 Seam C reuse guard (b): a compaction that frees fewer than this many (structural) tokens is
|
|
34
|
-
* treated as NO-EFFECTIVE-COMPACTION and does NOT raise the anti-thrash floor. Guards against a reused
|
|
35
|
-
* provider summary (or a pathological LLM summary) that reclaims no headroom yet suppresses the next real
|
|
36
|
-
* summary by inflating the floor to trigger×factor.
|
|
37
|
-
*/
|
|
38
|
-
export declare const COMPACTION_FREED_EPSILON = 256;
|
|
39
4
|
/**
|
|
40
5
|
* What the driver hands the turn-boundary lane, once per leg. The four seats are the four positional
|
|
41
6
|
* parameters the factory used to take; the Input is a carrier of REFERENCES, not a snapshot — the handler
|
|
@@ -13,9 +13,7 @@ import { formatDiagnosticsBlock } from "../lsp-diagnostics.js";
|
|
|
13
13
|
import { workflowSizeGuidelineChangeNotice } from "../../orchestration/workflow-size-guideline.js";
|
|
14
14
|
import { awaitChargeWithSlowDisclosure, discloseUnevaluableWindow, ENV_DUE_GOVERNANCE_READ_BUDGET_MS, GOVERNANCE_READ_STALLED, LIMIT_APPROACH_DEFAULT_THRESHOLDS, limitApproachFrames, platformLimitTerminal, raceUntilDeadline } from "./clock-and-limits.js";
|
|
15
15
|
import { gitRestateOption } from "./git-leg-delivery.js";
|
|
16
|
-
|
|
17
|
-
export const COMPACTION_REGROWTH_FACTOR = 1.5;
|
|
18
|
-
export const COMPACTION_FREED_EPSILON = 256;
|
|
16
|
+
import { COMPACTION_FREED_EPSILON, COMPACTION_REGROWTH_FACTOR, MAX_CONSECUTIVE_COMPACTION_FAILURES } from "./compaction-knobs.js";
|
|
19
17
|
const BATCH_CONTEXT_MIN_KEEP_BYTES = 160;
|
|
20
18
|
const BATCH_TRUNCATION_MARKER = "\n…[truncated]";
|
|
21
19
|
export function createTurnBoundary(input) {
|