@tangle-network/agent-eval 0.144.0 → 0.144.3
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 +36 -0
- package/dist/analyst/index.d.ts +88 -23
- package/dist/analyst/index.d.ts.map +1 -1
- package/dist/analyst/index.js +4 -4
- package/dist/{analyze-runs-BScZvqMV.js → analyze-runs-DWIvOAGk.js} +2 -2
- package/dist/{analyze-runs-BScZvqMV.js.map → analyze-runs-DWIvOAGk.js.map} +1 -1
- package/dist/{benchmark-DxaZfy0w.d.ts → benchmark-CP6kWfj8.d.ts} +3 -3
- package/dist/{benchmark-DxaZfy0w.d.ts.map → benchmark-CP6kWfj8.d.ts.map} +1 -1
- package/dist/{benchmark-command-4c7N_rlw.js → benchmark-command-CQPKRUr-.js} +332 -111
- package/dist/benchmark-command-CQPKRUr-.js.map +1 -0
- package/dist/benchmarks/index.d.ts +1 -1
- package/dist/benchmarks/index.js +1 -1
- package/dist/{benchmarks-05UGZ8sZ.js → benchmarks-CkG1bWFa.js} +4 -4
- package/dist/{benchmarks-05UGZ8sZ.js.map → benchmarks-CkG1bWFa.js.map} +1 -1
- package/dist/campaign/index.d.ts +6 -6
- package/dist/campaign/index.js +4 -4
- package/dist/{campaign-BKOtvRAB.js → campaign-DjGFyPxH.js} +74 -40
- package/dist/campaign-DjGFyPxH.js.map +1 -0
- package/dist/cli.js +2 -2
- package/dist/{client-Cgl6KasJ.d.ts → client-Bbht4xxl.d.ts} +4 -4
- package/dist/{client-Cgl6KasJ.d.ts.map → client-Bbht4xxl.d.ts.map} +1 -1
- package/dist/{completion-verifier-D15NHYSk.d.ts → completion-verifier-EJERfFwF.d.ts} +3 -3
- package/dist/{completion-verifier-D15NHYSk.d.ts.map → completion-verifier-EJERfFwF.d.ts.map} +1 -1
- package/dist/contract/index.d.ts +8 -8
- package/dist/contract/index.js +10 -8
- package/dist/contract/index.js.map +1 -1
- package/dist/control.d.ts +2 -2
- package/dist/control.js +1 -1
- package/dist/{default-registry-DfHJEwYh.js → default-registry-SOyHB6qG.js} +2 -2
- package/dist/{default-registry-DfHJEwYh.js.map → default-registry-SOyHB6qG.js.map} +1 -1
- package/dist/{default-registry-D3uqKbo6.d.ts → default-registry-iXfu2trt.d.ts} +5 -5
- package/dist/{default-registry-D3uqKbo6.d.ts.map → default-registry-iXfu2trt.d.ts.map} +1 -1
- package/dist/{dspy-rlm-engine-CBFwlyaY.js → dspy-rlm-engine-IRCG8kdi.js} +61 -105
- package/dist/dspy-rlm-engine-IRCG8kdi.js.map +1 -0
- package/dist/{eval-campaign-YdkpWWoT.js → eval-campaign-lZcDIwQM.js} +3 -3
- package/dist/{eval-campaign-YdkpWWoT.js.map → eval-campaign-lZcDIwQM.js.map} +1 -1
- package/dist/{exact-types-B0lJV3tu.d.ts → exact-types-BygCBR4L.d.ts} +2 -2
- package/dist/{exact-types-B0lJV3tu.d.ts.map → exact-types-BygCBR4L.d.ts.map} +1 -1
- package/dist/{external-optimizer-contracts-iK0yu4AR.d.ts → external-optimizer-contracts-CdmX2K2S.d.ts} +47 -10
- package/dist/external-optimizer-contracts-CdmX2K2S.d.ts.map +1 -0
- package/dist/{feedback-trajectory-BCHqzLh3.d.ts → feedback-trajectory-CSIkRLQX.d.ts} +3 -3
- package/dist/{feedback-trajectory-BCHqzLh3.d.ts.map → feedback-trajectory-CSIkRLQX.d.ts.map} +1 -1
- package/dist/hosted/index.d.ts +3 -3
- package/dist/{index-DgbFl4cv.d.ts → index-BuHs_OnD.d.ts} +17 -12
- package/dist/{index-DgbFl4cv.d.ts.map → index-BuHs_OnD.d.ts.map} +1 -1
- package/dist/{index-D2enbqA0.d.ts → index-CNOCxBLh.d.ts} +2 -2
- package/dist/{index-D2enbqA0.d.ts.map → index-CNOCxBLh.d.ts.map} +1 -1
- package/dist/{index-DFLVtPZ9.d.ts → index-DGIzNtRv.d.ts} +2 -2
- package/dist/{index-DFLVtPZ9.d.ts.map → index-DGIzNtRv.d.ts.map} +1 -1
- package/dist/{index-DtMpBKVF.d.ts → index-D_qTihaQ.d.ts} +5 -5
- package/dist/{index-DtMpBKVF.d.ts.map → index-D_qTihaQ.d.ts.map} +1 -1
- package/dist/index.d.ts +20 -20
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -17
- package/dist/{insight-report-Bh_8ksel.d.ts → insight-report-D5m1z0_n.d.ts} +3 -3
- package/dist/{insight-report-Bh_8ksel.d.ts.map → insight-report-D5m1z0_n.d.ts.map} +1 -1
- package/dist/ledger-core/index.js +1 -1
- package/dist/{ledger-core-Dxz0Rkwa.js → ledger-core-DXZIqu17.js} +3 -3
- package/dist/ledger-core-DXZIqu17.js.map +1 -0
- package/dist/{llm-client-B3WXSH5Y.js → llm-client-D3EoChAU.js} +7 -7
- package/dist/llm-client-D3EoChAU.js.map +1 -0
- package/dist/meta-eval/index.d.ts +1 -1
- package/dist/{mint-Ctwk079K.js → mint-DD-0oQTA.js} +2 -2
- package/dist/{mint-Ctwk079K.js.map → mint-DD-0oQTA.js.map} +1 -1
- package/dist/multishot/index.d.ts +1 -1
- package/dist/openapi.json +1 -1
- package/dist/{propose-review-control-DLXz4FCX.js → propose-review-control-BciUCZoh.js} +2 -2
- package/dist/{propose-review-control-DLXz4FCX.js.map → propose-review-control-BciUCZoh.js.map} +1 -1
- package/dist/{release-report-B_bQOHM-.d.ts → release-report-BZRWdq_t.d.ts} +3 -3
- package/dist/{release-report-B_bQOHM-.d.ts.map → release-report-BZRWdq_t.d.ts.map} +1 -1
- package/dist/{release-report-B5XPBvAU.js → release-report-Sl0xfkFv.js} +2 -2
- package/dist/{release-report-B5XPBvAU.js.map → release-report-Sl0xfkFv.js.map} +1 -1
- package/dist/{replay-DjUfTrHD.js → replay-CqOsGjzU.js} +2 -9
- package/dist/replay-CqOsGjzU.js.map +1 -0
- package/dist/{replay-BuJM6kLh.d.ts → replay-DQ-55DC_.d.ts} +4 -4
- package/dist/{replay-BuJM6kLh.d.ts.map → replay-DQ-55DC_.d.ts.map} +1 -1
- package/dist/reporting.d.ts +3 -3
- package/dist/reporting.js +1 -1
- package/dist/{researcher-C6lzl-rP.d.ts → researcher-BSiCoM1s.d.ts} +3 -3
- package/dist/{researcher-C6lzl-rP.d.ts.map → researcher-BSiCoM1s.d.ts.map} +1 -1
- package/dist/{reward-hacking-DjTi9HLb.js → reward-hacking-CyuzxKly.js} +2 -2
- package/dist/{reward-hacking-DjTi9HLb.js.map → reward-hacking-CyuzxKly.js.map} +1 -1
- package/dist/{reward-hacking-CEVVmy3h.d.ts → reward-hacking-DFgkEY4p.d.ts} +2 -2
- package/dist/{reward-hacking-CEVVmy3h.d.ts.map → reward-hacking-DFgkEY4p.d.ts.map} +1 -1
- package/dist/rl.d.ts +5 -5
- package/dist/rl.js +4 -4
- package/dist/rollout/index.d.ts +1 -1
- package/dist/rollout/index.js +2 -2
- package/dist/{rollout-8nj3mYvx.js → rollout-C2fD1cf4.js} +2 -2
- package/dist/{rollout-8nj3mYvx.js.map → rollout-C2fD1cf4.js.map} +1 -1
- package/dist/{rubric-predictive-validity-C2CthIfY.d.ts → rubric-predictive-validity-C4r4Y-q8.d.ts} +2 -2
- package/dist/{rubric-predictive-validity-C2CthIfY.d.ts.map → rubric-predictive-validity-C4r4Y-q8.d.ts.map} +1 -1
- package/dist/{run-evidence-8Ou28QSa.d.ts → run-evidence-H1vRpIdT.d.ts} +3 -3
- package/dist/{run-evidence-8Ou28QSa.d.ts.map → run-evidence-H1vRpIdT.d.ts.map} +1 -1
- package/dist/{run-record-vRgqWmJw.js → run-record-CWN8-VsV.js} +40 -14
- package/dist/{run-record-vRgqWmJw.js.map → run-record-CWN8-VsV.js.map} +1 -1
- package/dist/{run-record-Tb3TTtUn.d.ts → run-record-ooo9FWns.d.ts} +5 -9
- package/dist/{run-record-Tb3TTtUn.d.ts.map → run-record-ooo9FWns.d.ts.map} +1 -1
- package/dist/{semantic-concept-judge-DJQtFr95.js → semantic-concept-judge-Do5aM9wP.js} +3 -3
- package/dist/{semantic-concept-judge-DJQtFr95.js.map → semantic-concept-judge-Do5aM9wP.js.map} +1 -1
- package/dist/{server-Cu4M3NSO.js → server-Df00sdwz.js} +3 -3
- package/dist/{server-Cu4M3NSO.js.map → server-Df00sdwz.js.map} +1 -1
- package/dist/{single-run-lock-t1si1ob7.js → single-run-lock-D5iN0Xzb.js} +719 -187
- package/dist/single-run-lock-D5iN0Xzb.js.map +1 -0
- package/dist/{skill-usage-BiVEU0QY.d.ts → skill-usage-DtpLou9L.d.ts} +28 -9
- package/dist/skill-usage-DtpLou9L.d.ts.map +1 -0
- package/dist/{skillopt-optimization-method-Ds8J1_K8.js → skillopt-optimization-method-C4FX42dy.js} +42 -210
- package/dist/skillopt-optimization-method-C4FX42dy.js.map +1 -0
- package/dist/{skillopt-optimization-method-B7o01OdX.d.ts → skillopt-optimization-method-CvSJGdm3.d.ts} +12 -8
- package/dist/{skillopt-optimization-method-B7o01OdX.d.ts.map → skillopt-optimization-method-CvSJGdm3.d.ts.map} +1 -1
- package/dist/{summary-report-o3eJ3gxG.d.ts → summary-report-BOM6dfP7.d.ts} +2 -2
- package/dist/{summary-report-o3eJ3gxG.d.ts.map → summary-report-BOM6dfP7.d.ts.map} +1 -1
- package/dist/{tool-groups-Bqy4A3QB.d.ts → tool-groups-CMmsgTzj.d.ts} +7 -7
- package/dist/{tool-groups-Bqy4A3QB.d.ts.map → tool-groups-CMmsgTzj.d.ts.map} +1 -1
- package/dist/traces.d.ts +4 -4
- package/dist/traces.js +1 -1
- package/dist/types-BjMFz88h.d.ts.map +1 -1
- package/dist/{types-KEqL1pZc.d.ts → types-DcJxgsLy.d.ts} +8 -6
- package/dist/{types-KEqL1pZc.d.ts.map → types-DcJxgsLy.d.ts.map} +1 -1
- package/dist/{types-D3jh6F98.d.ts → types-y8jrxXWd.d.ts} +2 -2
- package/dist/{types-D3jh6F98.d.ts.map → types-y8jrxXWd.d.ts.map} +1 -1
- package/dist/wire/index.d.ts +1 -1
- package/dist/wire/index.js +1 -1
- package/docs/eval-surface-map.md +4 -0
- package/docs/trace-analysis.md +43 -32
- package/package.json +1 -1
- package/dist/benchmark-command-4c7N_rlw.js.map +0 -1
- package/dist/campaign-BKOtvRAB.js.map +0 -1
- package/dist/dspy-rlm-engine-CBFwlyaY.js.map +0 -1
- package/dist/external-optimizer-contracts-iK0yu4AR.d.ts.map +0 -1
- package/dist/ledger-core-Dxz0Rkwa.js.map +0 -1
- package/dist/llm-client-B3WXSH5Y.js.map +0 -1
- package/dist/replay-DjUfTrHD.js.map +0 -1
- package/dist/single-run-lock-t1si1ob7.js.map +0 -1
- package/dist/skill-usage-BiVEU0QY.d.ts.map +0 -1
- package/dist/skillopt-optimization-method-Ds8J1_K8.js.map +0 -1
package/dist/{skillopt-optimization-method-Ds8J1_K8.js → skillopt-optimization-method-C4FX42dy.js}
RENAMED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { c as ValidationError, i as JudgeError, t as AgentEvalError } from "./errors-D-LKuDhb.js";
|
|
2
2
|
import { i as CostLedger, t as CostAccountingIncompleteError } from "./cost-ledger-DMFxsLKr.js";
|
|
3
|
-
import { f as maximumChargeForLlmRequest, l as costReceiptFromLlm, m as stripFencedJson, u as costReceiptFromLlmError } from "./llm-client-
|
|
3
|
+
import { f as maximumChargeForLlmRequest, l as costReceiptFromLlm, m as stripFencedJson, u as costReceiptFromLlmError } from "./llm-client-D3EoChAU.js";
|
|
4
4
|
import { a as clamp01, o as combineAbortSignals, t as assertProposalFindings } from "./proposal-findings-2GIUo1et.js";
|
|
5
|
-
import {
|
|
6
|
-
import { p as mapConcurrent } from "./ledger-core-
|
|
5
|
+
import { A as removeCredentialEnvironment, D as isCandidateText, E as assertNoCredentialValues, M as resolveExternalOptimizerProcessLimits, N as safePathComponent, O as isExternalTextCandidate, T as assertJsonValue, d as closeExternalOptimizerResources, f as runWithCleanup, j as resolveExternalOptimizerCallbackLimits, k as isRecord, l as startExternalOptimizerCallback, n as createRunCostLedger, p as startExternalOptimizerModelProxy, r as fsCampaignStorage, t as acquireSingleRunLock, u as runExternalOptimizerProcess, v as canonicalJson, w as assertExternalOptimizerModelBudget, y as contentHash } from "./single-run-lock-D5iN0Xzb.js";
|
|
6
|
+
import { p as mapConcurrent } from "./ledger-core-DXZIqu17.js";
|
|
7
7
|
import { E as pairedBootstrap, H as weightedComposite, M as pairedRiskDifferenceScore, N as pairedSignTest, O as pairedDeltaTieFraction, T as pairedBinaryScale, d as confidenceInterval, j as pairedRiskDifferenceExact } from "./statistics-ByxzSiOM.js";
|
|
8
8
|
import { t as DEFAULT_REDACTION_RULES } from "./redact-7Aq1ukl-.js";
|
|
9
|
-
import { a as campaignCellCostProvenance, o as campaignCellExecutionEvidence, t as detectRewardHacking, u as projectCampaignCellQuality } from "./reward-hacking-
|
|
9
|
+
import { a as campaignCellCostProvenance, o as campaignCellExecutionEvidence, t as detectRewardHacking, u as projectCampaignCellQuality } from "./reward-hacking-CyuzxKly.js";
|
|
10
10
|
import { z } from "zod";
|
|
11
11
|
import { writeFileSync } from "node:fs";
|
|
12
12
|
import { basename, isAbsolute, join } from "node:path";
|
|
13
13
|
import { createHash, randomBytes } from "node:crypto";
|
|
14
|
-
import { createServer } from "node:http";
|
|
15
14
|
import { execSync } from "node:child_process";
|
|
16
15
|
import { mkdir } from "node:fs/promises";
|
|
17
16
|
import { homedir, tmpdir } from "node:os";
|
|
@@ -1649,204 +1648,6 @@ function designedCellIds(scenarios, reps) {
|
|
|
1649
1648
|
return ids;
|
|
1650
1649
|
}
|
|
1651
1650
|
//#endregion
|
|
1652
|
-
//#region src/campaign/external-optimizer-callback.ts
|
|
1653
|
-
const MAX_CALLBACK_BODY_BYTES = 1e6;
|
|
1654
|
-
async function startExternalOptimizerCallback(args) {
|
|
1655
|
-
assertCallbackConfig(args);
|
|
1656
|
-
args.signal?.throwIfAborted();
|
|
1657
|
-
let evaluations = 0;
|
|
1658
|
-
let accepting = true;
|
|
1659
|
-
let closePromise;
|
|
1660
|
-
const activeControllers = /* @__PURE__ */ new Set();
|
|
1661
|
-
const activeHandlers = /* @__PURE__ */ new Set();
|
|
1662
|
-
const proposedCandidateHashes = /* @__PURE__ */ new Set();
|
|
1663
|
-
let observationSequence = 0;
|
|
1664
|
-
const server = createServer((request, response) => {
|
|
1665
|
-
if (!accepting) {
|
|
1666
|
-
sendJsonIfOpen(response, 503, { error: "external optimizer callback is closing" });
|
|
1667
|
-
return;
|
|
1668
|
-
}
|
|
1669
|
-
const controller = new AbortController();
|
|
1670
|
-
const abortRequest = () => {
|
|
1671
|
-
request.destroy();
|
|
1672
|
-
response.destroy();
|
|
1673
|
-
};
|
|
1674
|
-
activeControllers.add(controller);
|
|
1675
|
-
controller.signal.addEventListener("abort", abortRequest, { once: true });
|
|
1676
|
-
let handler;
|
|
1677
|
-
handler = handleCallback(request, response, controller.signal, args, () => {
|
|
1678
|
-
const accepted = args.acceptEvaluation ? args.acceptEvaluation() : evaluations + 1;
|
|
1679
|
-
if (accepted === void 0) return void 0;
|
|
1680
|
-
if (!Number.isSafeInteger(accepted) || accepted <= 0) throw new Error("external optimizer callback: invalid accepted evaluation count");
|
|
1681
|
-
if (accepted > args.maxEvaluations) return void 0;
|
|
1682
|
-
evaluations += 1;
|
|
1683
|
-
return accepted;
|
|
1684
|
-
}, (observation) => {
|
|
1685
|
-
if (!args.observe) return;
|
|
1686
|
-
args.observe({
|
|
1687
|
-
...observation,
|
|
1688
|
-
sequence: ++observationSequence
|
|
1689
|
-
});
|
|
1690
|
-
}, proposedCandidateHashes).finally(() => {
|
|
1691
|
-
controller.signal.removeEventListener("abort", abortRequest);
|
|
1692
|
-
activeControllers.delete(controller);
|
|
1693
|
-
activeHandlers.delete(handler);
|
|
1694
|
-
});
|
|
1695
|
-
activeHandlers.add(handler);
|
|
1696
|
-
handler.catch(() => void 0);
|
|
1697
|
-
});
|
|
1698
|
-
const port = await listenLocal(server);
|
|
1699
|
-
const close = () => {
|
|
1700
|
-
closePromise ??= closeCallbackServer();
|
|
1701
|
-
return closePromise;
|
|
1702
|
-
};
|
|
1703
|
-
const onAbort = () => {
|
|
1704
|
-
close().catch(() => void 0);
|
|
1705
|
-
};
|
|
1706
|
-
args.signal?.addEventListener("abort", onAbort, { once: true });
|
|
1707
|
-
if (args.signal?.aborted) onAbort();
|
|
1708
|
-
return {
|
|
1709
|
-
url: `http://127.0.0.1:${port}/evaluate`,
|
|
1710
|
-
token: args.token,
|
|
1711
|
-
evaluations: () => evaluations,
|
|
1712
|
-
close
|
|
1713
|
-
};
|
|
1714
|
-
async function closeCallbackServer() {
|
|
1715
|
-
args.signal?.removeEventListener("abort", onAbort);
|
|
1716
|
-
accepting = false;
|
|
1717
|
-
const closingServer = closeServer(server);
|
|
1718
|
-
server.closeIdleConnections?.();
|
|
1719
|
-
for (const controller of activeControllers) controller.abort();
|
|
1720
|
-
const [serverResult] = await Promise.allSettled([closingServer, waitForActiveHandlers(activeHandlers)]);
|
|
1721
|
-
if (activeControllers.size !== 0 || activeHandlers.size !== 0) throw new Error("external optimizer callback closed with active request work");
|
|
1722
|
-
if (serverResult?.status === "rejected") throw serverResult.reason;
|
|
1723
|
-
}
|
|
1724
|
-
}
|
|
1725
|
-
async function handleCallback(request, response, signal, args, nextEvaluation, observe, proposedCandidateHashes) {
|
|
1726
|
-
try {
|
|
1727
|
-
if (request.method !== "POST" || request.url !== "/evaluate") {
|
|
1728
|
-
sendJsonIfOpen(response, 404, { error: "not found" });
|
|
1729
|
-
return;
|
|
1730
|
-
}
|
|
1731
|
-
if (request.headers.authorization !== `Bearer ${args.token}`) {
|
|
1732
|
-
sendJsonIfOpen(response, 401, { error: "unauthorized" });
|
|
1733
|
-
return;
|
|
1734
|
-
}
|
|
1735
|
-
let body;
|
|
1736
|
-
try {
|
|
1737
|
-
body = await readJson(request);
|
|
1738
|
-
} catch {
|
|
1739
|
-
observe({
|
|
1740
|
-
kind: "refusal",
|
|
1741
|
-
reason: "invalid-request"
|
|
1742
|
-
});
|
|
1743
|
-
sendJsonIfOpen(response, 400, { error: "request body must be bounded valid JSON" });
|
|
1744
|
-
return;
|
|
1745
|
-
}
|
|
1746
|
-
if (!isRecord(body) || !isExternalTextCandidate(body.candidate) || typeof body.exampleId !== "string") {
|
|
1747
|
-
observe({
|
|
1748
|
-
kind: "refusal",
|
|
1749
|
-
reason: "invalid-request"
|
|
1750
|
-
});
|
|
1751
|
-
sendJsonIfOpen(response, 400, { error: "candidate and exampleId are required strings" });
|
|
1752
|
-
return;
|
|
1753
|
-
}
|
|
1754
|
-
const candidate = cloneCandidate(body.candidate);
|
|
1755
|
-
const candidateHash = contentHash({
|
|
1756
|
-
kind: "external-text-candidate",
|
|
1757
|
-
candidate
|
|
1758
|
-
});
|
|
1759
|
-
if (!proposedCandidateHashes.has(candidateHash)) {
|
|
1760
|
-
observe({
|
|
1761
|
-
kind: "proposal",
|
|
1762
|
-
candidate,
|
|
1763
|
-
candidateHash
|
|
1764
|
-
});
|
|
1765
|
-
proposedCandidateHashes.add(candidateHash);
|
|
1766
|
-
}
|
|
1767
|
-
const count = nextEvaluation();
|
|
1768
|
-
if (count === void 0) {
|
|
1769
|
-
observe({
|
|
1770
|
-
kind: "refusal",
|
|
1771
|
-
reason: "evaluation-limit",
|
|
1772
|
-
candidate,
|
|
1773
|
-
candidateHash,
|
|
1774
|
-
exampleId: body.exampleId
|
|
1775
|
-
});
|
|
1776
|
-
sendJsonIfOpen(response, 429, { error: "evaluation limit reached" });
|
|
1777
|
-
return;
|
|
1778
|
-
}
|
|
1779
|
-
let result;
|
|
1780
|
-
try {
|
|
1781
|
-
result = await args.evaluate({
|
|
1782
|
-
candidate,
|
|
1783
|
-
exampleId: body.exampleId
|
|
1784
|
-
}, signal);
|
|
1785
|
-
} catch {
|
|
1786
|
-
observe({
|
|
1787
|
-
kind: "refusal",
|
|
1788
|
-
reason: "evaluation-failed",
|
|
1789
|
-
candidate,
|
|
1790
|
-
candidateHash,
|
|
1791
|
-
exampleId: body.exampleId
|
|
1792
|
-
});
|
|
1793
|
-
sendJsonIfOpen(response, 500, { error: "evaluation failed" });
|
|
1794
|
-
return;
|
|
1795
|
-
}
|
|
1796
|
-
observe({
|
|
1797
|
-
kind: "evaluation",
|
|
1798
|
-
candidate,
|
|
1799
|
-
candidateHash,
|
|
1800
|
-
exampleId: body.exampleId,
|
|
1801
|
-
evaluationNumber: count,
|
|
1802
|
-
response: structuredClone(result)
|
|
1803
|
-
});
|
|
1804
|
-
sendJsonIfOpen(response, 200, result);
|
|
1805
|
-
} catch {
|
|
1806
|
-
sendJsonIfOpen(response, 500, { error: "evaluation failed" });
|
|
1807
|
-
}
|
|
1808
|
-
}
|
|
1809
|
-
async function waitForActiveHandlers(activeHandlers) {
|
|
1810
|
-
while (activeHandlers.size > 0) await Promise.allSettled([...activeHandlers]);
|
|
1811
|
-
}
|
|
1812
|
-
function sendJsonIfOpen(response, status, body) {
|
|
1813
|
-
if (response.destroyed || response.writableEnded) return;
|
|
1814
|
-
sendJson(response, status, body);
|
|
1815
|
-
}
|
|
1816
|
-
function readJson(request) {
|
|
1817
|
-
return new Promise((resolvePromise, reject) => {
|
|
1818
|
-
let size = 0;
|
|
1819
|
-
const chunks = [];
|
|
1820
|
-
request.on("data", (chunk) => {
|
|
1821
|
-
size += chunk.length;
|
|
1822
|
-
if (size > MAX_CALLBACK_BODY_BYTES) {
|
|
1823
|
-
reject(/* @__PURE__ */ new Error("callback body too large"));
|
|
1824
|
-
request.destroy();
|
|
1825
|
-
return;
|
|
1826
|
-
}
|
|
1827
|
-
chunks.push(chunk);
|
|
1828
|
-
});
|
|
1829
|
-
request.on("error", reject);
|
|
1830
|
-
request.on("end", () => {
|
|
1831
|
-
try {
|
|
1832
|
-
resolvePromise(JSON.parse(Buffer.concat(chunks).toString("utf8")));
|
|
1833
|
-
} catch (error) {
|
|
1834
|
-
reject(error);
|
|
1835
|
-
}
|
|
1836
|
-
});
|
|
1837
|
-
});
|
|
1838
|
-
}
|
|
1839
|
-
function assertCallbackConfig(args) {
|
|
1840
|
-
if (typeof args.token !== "string" || !args.token.trim()) throw new Error("external optimizer callback: token must be non-empty");
|
|
1841
|
-
if (!Number.isSafeInteger(args.maxEvaluations) || args.maxEvaluations <= 0) throw new Error("external optimizer callback: maxEvaluations must be a positive safe integer");
|
|
1842
|
-
if (args.acceptEvaluation !== void 0 && typeof args.acceptEvaluation !== "function") throw new Error("external optimizer callback: acceptEvaluation must be a function");
|
|
1843
|
-
if (typeof args.evaluate !== "function") throw new Error("external optimizer callback: evaluate must be a function");
|
|
1844
|
-
if (args.observe !== void 0 && typeof args.observe !== "function") throw new Error("external optimizer callback: observe must be a function");
|
|
1845
|
-
}
|
|
1846
|
-
function cloneCandidate(candidate) {
|
|
1847
|
-
return typeof candidate === "string" ? candidate : { ...candidate };
|
|
1848
|
-
}
|
|
1849
|
-
//#endregion
|
|
1850
1651
|
//#region src/campaign/external-optimizer-run-budget.ts
|
|
1851
1652
|
function externalOptimizerRunKey(input) {
|
|
1852
1653
|
if (!input.attemptId.trim() || input.attemptId.trim() !== input.attemptId) throw new Error("external optimizer attemptId must be trimmed and non-empty");
|
|
@@ -2099,10 +1900,11 @@ async function executeCell(args) {
|
|
|
2099
1900
|
if (cached.status === "hit") {
|
|
2100
1901
|
const receiptProblem = cachedCellReceiptProblem(cached.cell, args.costLedger, stableCostTags);
|
|
2101
1902
|
if (receiptProblem === void 0) {
|
|
2102
|
-
|
|
1903
|
+
const cell = withCurrentAgentModelEvidence(cached.cell, args.costLedger, stableCostTags);
|
|
1904
|
+
enforceDispatchUsage(cell, args.opts.expectUsage ?? "warn");
|
|
2103
1905
|
return {
|
|
2104
1906
|
cell: {
|
|
2105
|
-
...
|
|
1907
|
+
...cell,
|
|
2106
1908
|
cached: true
|
|
2107
1909
|
},
|
|
2108
1910
|
artifactsByPath: {}
|
|
@@ -2246,7 +2048,7 @@ async function executeCell(args) {
|
|
|
2246
2048
|
...agentCost.cachedTokens > 0 ? { cached: agentCost.cachedTokens } : {},
|
|
2247
2049
|
...agentCost.cacheWriteTokens !== void 0 && agentCost.cacheWriteTokens > 0 ? { cacheWrite: agentCost.cacheWriteTokens } : {}
|
|
2248
2050
|
};
|
|
2249
|
-
const
|
|
2051
|
+
const agentModelEvidence = modelEvidenceFromReceipts(agentReceipts);
|
|
2250
2052
|
const dispatchResult = {
|
|
2251
2053
|
cellId: args.slot.cellId,
|
|
2252
2054
|
artifact,
|
|
@@ -2303,7 +2105,7 @@ async function executeCell(args) {
|
|
|
2303
2105
|
costProvenance: agentCost.costProvenance,
|
|
2304
2106
|
costCallIds,
|
|
2305
2107
|
tokenUsage,
|
|
2306
|
-
...
|
|
2108
|
+
...agentModelEvidence,
|
|
2307
2109
|
durationMs: Date.now() - startMs,
|
|
2308
2110
|
seed: args.slot.cellSeed,
|
|
2309
2111
|
cached: false,
|
|
@@ -2619,6 +2421,25 @@ function assertScheduleCachesReusable(args) {
|
|
|
2619
2421
|
}
|
|
2620
2422
|
if (blocked.length > 0) throw invalidCachedCellsError(blocked);
|
|
2621
2423
|
}
|
|
2424
|
+
function modelEvidenceFromReceipts(receipts) {
|
|
2425
|
+
const models = [...new Set(receipts.map((receipt) => receipt.model))];
|
|
2426
|
+
if (models.length === 0) return {};
|
|
2427
|
+
return {
|
|
2428
|
+
resolvedModels: models,
|
|
2429
|
+
...models.length === 1 ? { resolvedModel: models[0] } : {}
|
|
2430
|
+
};
|
|
2431
|
+
}
|
|
2432
|
+
function withCurrentAgentModelEvidence(cached, costLedger, stableCostTags) {
|
|
2433
|
+
const cachedCallIds = new Set(cached.costCallIds ?? []);
|
|
2434
|
+
const receipts = costLedger.list({
|
|
2435
|
+
channel: "agent",
|
|
2436
|
+
tags: stableCostTags
|
|
2437
|
+
}).filter((receipt) => cachedCallIds.has(receipt.callId));
|
|
2438
|
+
const cell = { ...cached };
|
|
2439
|
+
delete cell.resolvedModel;
|
|
2440
|
+
delete cell.resolvedModels;
|
|
2441
|
+
return Object.assign(cell, modelEvidenceFromReceipts(receipts));
|
|
2442
|
+
}
|
|
2622
2443
|
function cachedCellReceiptProblem(cached, costLedger, stableCostTags) {
|
|
2623
2444
|
const reportsPaidActivity = cached.costProvenance.kind !== "observed" || cached.costUsd > 0 || cached.tokenUsage.input > 0 || cached.tokenUsage.output > 0;
|
|
2624
2445
|
if (cached.costCallIds === void 0) {
|
|
@@ -5392,7 +5213,8 @@ function externalOptimizerRunnerIdentity(runner, module) {
|
|
|
5392
5213
|
return {
|
|
5393
5214
|
command: runner?.command ?? "python",
|
|
5394
5215
|
args: [...runner?.args ?? ["-m", module]],
|
|
5395
|
-
environment: removeCredentialEnvironment(runner?.env ?? {})
|
|
5216
|
+
environment: removeCredentialEnvironment(runner?.env ?? {}),
|
|
5217
|
+
limits: resolveExternalOptimizerProcessLimits(runner?.limits)
|
|
5396
5218
|
};
|
|
5397
5219
|
}
|
|
5398
5220
|
function snapshotExternalOptimizerRunner(runner) {
|
|
@@ -5400,7 +5222,8 @@ function snapshotExternalOptimizerRunner(runner) {
|
|
|
5400
5222
|
return {
|
|
5401
5223
|
...runner,
|
|
5402
5224
|
...runner.args ? { args: [...runner.args] } : {},
|
|
5403
|
-
...runner.env ? { env: { ...runner.env } } : {}
|
|
5225
|
+
...runner.env ? { env: { ...runner.env } } : {},
|
|
5226
|
+
...runner.limits ? { limits: { ...runner.limits } } : {}
|
|
5404
5227
|
};
|
|
5405
5228
|
}
|
|
5406
5229
|
function snapshotJson(value, label) {
|
|
@@ -5498,6 +5321,7 @@ function snapshotGepaOptimizationConfig(config) {
|
|
|
5498
5321
|
recipe: structuredClone(config.recipe),
|
|
5499
5322
|
...config.engineModules ? { engineModules: [...config.engineModules] } : {},
|
|
5500
5323
|
...config.optimizer ? { optimizer: snapshotOptimizerModel(config.optimizer) } : {},
|
|
5324
|
+
...config.evaluationCallbackLimits ? { evaluationCallbackLimits: { ...config.evaluationCallbackLimits } } : {},
|
|
5501
5325
|
...runner ? { runner } : {}
|
|
5502
5326
|
};
|
|
5503
5327
|
}
|
|
@@ -5516,6 +5340,7 @@ function assertGepaOptimizationConfig(config) {
|
|
|
5516
5340
|
const evidenceLimit = config.maxEvidenceChars ?? 1e5;
|
|
5517
5341
|
if (JSON.stringify(config.objective).length > evidenceLimit || JSON.stringify(config.background ?? "").length > evidenceLimit) throw new Error("gepaOptimizationMethod: objective and background must each fit maxEvidenceChars");
|
|
5518
5342
|
assertEngineModules(config.engineModules);
|
|
5343
|
+
resolveExternalOptimizerCallbackLimits(config.evaluationCallbackLimits, "gepaOptimizationMethod: evaluationCallbackLimits");
|
|
5519
5344
|
if (config.optimizer !== void 0) {
|
|
5520
5345
|
assertOptimizerModel(config.optimizer, "gepaOptimizationMethod: optimizer");
|
|
5521
5346
|
if (config.engineModules?.length) throw new Error("gepaOptimizationMethod: optimizer cannot be combined with engineModules because proxied reflection requires the built-in GEPA engine");
|
|
@@ -5727,6 +5552,7 @@ function gepaOptimizationMethod(config) {
|
|
|
5727
5552
|
selectionSet,
|
|
5728
5553
|
maxCandidateChars,
|
|
5729
5554
|
maxEvidenceChars,
|
|
5555
|
+
evaluationCallbackLimits: resolveExternalOptimizerCallbackLimits(config.evaluationCallbackLimits),
|
|
5730
5556
|
optimizerModel: config.optimizer ? {
|
|
5731
5557
|
model: config.optimizer.model,
|
|
5732
5558
|
callRef: config.optimizer.callRef,
|
|
@@ -5776,6 +5602,7 @@ function gepaOptimizationMethod(config) {
|
|
|
5776
5602
|
acceptEvaluation: () => runBudget.acceptEvaluation(),
|
|
5777
5603
|
evaluate,
|
|
5778
5604
|
observe: observationLog.observe,
|
|
5605
|
+
...config.evaluationCallbackLimits ? { limits: config.evaluationCallbackLimits } : {},
|
|
5779
5606
|
...signal ? { signal } : {}
|
|
5780
5607
|
});
|
|
5781
5608
|
const runnerEnv = bridgeRunner?.env ?? {};
|
|
@@ -6680,6 +6507,7 @@ function campaignMeasurementDigest(campaign) {
|
|
|
6680
6507
|
costProvenance: cell.costProvenance,
|
|
6681
6508
|
costCallIds: [...cell.costCallIds ?? []].sort(),
|
|
6682
6509
|
tokenUsage: cell.tokenUsage,
|
|
6510
|
+
resolvedModels: [...cell.resolvedModels ?? []].sort(),
|
|
6683
6511
|
resolvedModel: cell.resolvedModel ?? null,
|
|
6684
6512
|
durationMs: cell.durationMs,
|
|
6685
6513
|
seed: cell.seed,
|
|
@@ -7004,6 +6832,7 @@ function snapshotSkillOptOptimizationConfig(config) {
|
|
|
7004
6832
|
...config,
|
|
7005
6833
|
trainer: structuredClone(config.trainer),
|
|
7006
6834
|
optimizer: snapshotOptimizerModel(config.optimizer),
|
|
6835
|
+
...config.evaluationCallbackLimits ? { evaluationCallbackLimits: { ...config.evaluationCallbackLimits } } : {},
|
|
7007
6836
|
...runner ? { runner } : {}
|
|
7008
6837
|
};
|
|
7009
6838
|
}
|
|
@@ -7056,6 +6885,7 @@ function assertSkillOptOptimizationConfig(config) {
|
|
|
7056
6885
|
assertJsonValue(config.trainer.overrides ?? {}, "skillOptOptimizationMethod: trainer.overrides");
|
|
7057
6886
|
assertNoCredentialValues(config.trainer.overrides ?? {}, "skillOptOptimizationMethod: trainer.overrides", "optimizer");
|
|
7058
6887
|
assertOptimizerModel(config.optimizer, "skillOptOptimizationMethod: optimizer");
|
|
6888
|
+
resolveExternalOptimizerCallbackLimits(config.evaluationCallbackLimits, "skillOptOptimizationMethod: evaluationCallbackLimits");
|
|
7059
6889
|
const evidenceLimit = config.maxEvidenceChars ?? 1e5;
|
|
7060
6890
|
if (JSON.stringify(config.objective).length > evidenceLimit || JSON.stringify(config.background ?? "").length > evidenceLimit) throw new Error("skillOptOptimizationMethod: objective and background must each fit maxEvidenceChars");
|
|
7061
6891
|
}
|
|
@@ -7136,6 +6966,7 @@ function skillOptOptimizationMethod(config) {
|
|
|
7136
6966
|
hardScoreThreshold: config.hardScoreThreshold ?? 1,
|
|
7137
6967
|
maxCandidateChars,
|
|
7138
6968
|
maxEvidenceChars,
|
|
6969
|
+
evaluationCallbackLimits: resolveExternalOptimizerCallbackLimits(config.evaluationCallbackLimits),
|
|
7139
6970
|
runner: externalOptimizerRunnerIdentity(bridgeRunner, "agent_eval_rpc.skillopt_bridge")
|
|
7140
6971
|
};
|
|
7141
6972
|
const compatibleRunId = externalOptimizerCompatibleRunKey(runMaterial);
|
|
@@ -7179,6 +7010,7 @@ function skillOptOptimizationMethod(config) {
|
|
|
7179
7010
|
acceptEvaluation: () => runBudget.acceptEvaluation(),
|
|
7180
7011
|
evaluate,
|
|
7181
7012
|
observe: observationLog.observe,
|
|
7013
|
+
...config.evaluationCallbackLimits ? { limits: config.evaluationCallbackLimits } : {},
|
|
7182
7014
|
...signal ? { signal } : {}
|
|
7183
7015
|
});
|
|
7184
7016
|
const runnerEnv = bridgeRunner?.env ?? {};
|
|
@@ -7332,4 +7164,4 @@ function skillOptOptimizationMethod(config) {
|
|
|
7332
7164
|
//#endregion
|
|
7333
7165
|
export { assertCampaignSplitIdentity as $, assertOptimizationResult as A, summarizeAgentReceiptIntegrity as At, surfaceContentHash as B, detectScale as C, decidePairedPromotion as Ct, runCanaries as D, BackendIntegrityError as Dt, pairHoldout as E, pairedDeltaTest as Et, assertCodeSurfaceIdentity as F, DEFAULT_MUTATION_PRIMITIVES as G, campaignBreakdown as H, assertComponentSurface as I, planCampaignRun as J, buildReflectionPrompt as K, codeSurfaceIdentityMaterial as L, compareOptimizationMethods as M, JudgeParseError as Mt, costFromLedgerSummary as N, composeGate as O, assertRealAgentReceipts as Ot, optimizationTokenUsageFromSummary as P, assertCampaignDesign as Q, componentSurfaceIdentityMaterial as R, defaultProductionGate as S, recoverTruncatedJson as St, heldoutSignificance as T, minimumPairsForPairedDeltaTest as Tt, campaignMeanComposite as U, surfaceHash as V, compareRankKeys as W, resolveRunDir as X, runCampaign as Y, tangleTracesRoot as Z, buildEvidenceVector as _, crowdingDistance as _t, emitLoopProvenance as a, REFERENCE_EQUIVALENCE_JUDGE_VERSION as at, powerPreflight as b, paretoFrontierWithCrowding as bt, provenanceRecordPath as c, DEFAULT_RED_TEAM_CORPUS as ct, runImprovementLoop as d, scoreRedTeamOutput as dt, campaignScenarioIdentity as et, runOptimization as f, toolNamesForRun as ft, gepaOptimizationMethod as g, llmJudge as gt, labelTrustRank as h, hashScenarios as ht, canonicalDigest as i, REFERENCE_EQUIVALENCE_INPUT_LIMITS as it, combineComparisonCosts as j, summarizeBackendIntegrity as jt, externalTextOptimizationMethod as k, assertRealBackend as kt, provenanceSpansPath as l, redTeamDataset as lt, isProposedCandidate as m, HoldoutLockedError as mt, buildLoopProvenanceRecord as n, campaignSplitDigestFromIdentities as nt, loopProvenanceArgsFromResult as o, createReferenceEquivalenceJudge as ot, runEval as p, Dataset as pt, parseReflectionResponse as q, campaignMeasurementDigest as r, openAutoPr as rt, loopProvenanceSpans as s, runReferenceEquivalenceJudge as st, skillOptOptimizationMethod as t, campaignSplitDigest as tt, verifyLoopProvenanceRecord as u, redTeamReport as ut, paretoPolicy as v, dominates as vt, dimensionRegressions as w, pairedDecisionShape as wt, heldOutGate as x, scalarScore as xt, paretoSignificanceGate as y, paretoFrontier as yt, renderSurfaceDiff as z };
|
|
7334
7166
|
|
|
7335
|
-
//# sourceMappingURL=skillopt-optimization-method-
|
|
7167
|
+
//# sourceMappingURL=skillopt-optimization-method-C4FX42dy.js.map
|