@tangle-network/agent-interface 5.10.23 → 5.10.24
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/README.md
CHANGED
|
@@ -432,3 +432,23 @@ confer access. Hosts unable to resolve the saved pins must fail closed rather th
|
|
|
432
432
|
inline JSON into instructions, substitute a newer generation or silently omit them.
|
|
433
433
|
|
|
434
434
|
Profile collection admission uses the shared [contract limits](src/contract-limits.ts) before parsing elements or encoding record keys. Training receipts and knowledge references retain their own typed limits in [the profile schema](src/profile-schema.ts). Opaque metadata is admitted and detached by value as bounded portable data; accessors are refused and cross-key object identity is not preserved. Snapshot validation precedes the final detached copy, preserving explicit undefined fields, canonical hashes and nested isolation. The generic serialized-JSON byte bound is not a whole-profile transport limit.
|
|
435
|
+
|
|
436
|
+
## Profile experiment model and accounting evidence
|
|
437
|
+
|
|
438
|
+
Profile experiments keep their legacy fixed task model unless `modelBinding`
|
|
439
|
+
explicitly selects `profile-default`. That policy binds static authored model
|
|
440
|
+
hints and an exact resolved model/snapshot for each arm. The original task model
|
|
441
|
+
must match the baseline. Schema and Eval share
|
|
442
|
+
`agentProfileImprovementExpectedModel()`; the source-owning executor passes its
|
|
443
|
+
actual profile to that helper and independently observes the returned identity
|
|
444
|
+
for each run. Contradictory defaults, routing/fallback hints and unsupported
|
|
445
|
+
dynamic values refuse. A configured model string alone is not served evidence.
|
|
446
|
+
|
|
447
|
+
Complete profile run receipts and shared `AgentCandidateFixedSpend` remain
|
|
448
|
+
strict. The opt-in `AgentProfileImprovementRecordedRunReceipt` uses the same
|
|
449
|
+
receipt and evidence identities, with a profile-only unavailable accounting
|
|
450
|
+
branch for execution or grading. Every required counter/cost is an explicit
|
|
451
|
+
known value or null, with a reason. `agentProfileImprovementRecordedRunReceiptSchema`
|
|
452
|
+
retains these records; complete comparison/proposal schemas refuse them. An
|
|
453
|
+
unknown amount is neither observed nor estimated zero. Raw native facts outside
|
|
454
|
+
the fixed-spend counters remain in the authoritative evidence references.
|
|
@@ -15577,6 +15577,81 @@ export declare const agentImprovementProposalSchema: z.ZodObject<{
|
|
|
15577
15577
|
stateDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
15578
15578
|
}, z.core.$strict>;
|
|
15579
15579
|
change: z.ZodTuple<[z.ZodType<import("./profile-diff.js").AgentProfileDiff, unknown, z.core.$ZodTypeInternals<import("./profile-diff.js").AgentProfileDiff, unknown>>], z.ZodType<import("./profile-diff.js").AgentProfileDiff, unknown, z.core.$ZodTypeInternals<import("./profile-diff.js").AgentProfileDiff, unknown>>>;
|
|
15580
|
+
modelBinding: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
15581
|
+
kind: z.ZodLiteral<"fixed-task">;
|
|
15582
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
15583
|
+
kind: z.ZodLiteral<"profile-default">;
|
|
15584
|
+
baseline: z.ZodObject<{
|
|
15585
|
+
authored: z.ZodObject<{
|
|
15586
|
+
default: z.ZodOptional<z.ZodString>;
|
|
15587
|
+
small: z.ZodOptional<z.ZodString>;
|
|
15588
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
15589
|
+
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
15590
|
+
none: "none";
|
|
15591
|
+
minimal: "minimal";
|
|
15592
|
+
low: "low";
|
|
15593
|
+
medium: "medium";
|
|
15594
|
+
high: "high";
|
|
15595
|
+
xhigh: "xhigh";
|
|
15596
|
+
ultracode: "ultracode";
|
|
15597
|
+
}>>;
|
|
15598
|
+
maxVisibleOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
15599
|
+
maxReasoningTokens: z.ZodOptional<z.ZodNumber>;
|
|
15600
|
+
maxTotalOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
15601
|
+
metadata: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
|
|
15602
|
+
}, z.core.$strict>;
|
|
15603
|
+
resolved: z.ZodObject<{
|
|
15604
|
+
requested: z.ZodString;
|
|
15605
|
+
provider: z.ZodString;
|
|
15606
|
+
model: z.ZodString;
|
|
15607
|
+
snapshot: z.ZodString;
|
|
15608
|
+
reasoningEffort: z.ZodEnum<{
|
|
15609
|
+
none: "none";
|
|
15610
|
+
minimal: "minimal";
|
|
15611
|
+
low: "low";
|
|
15612
|
+
medium: "medium";
|
|
15613
|
+
high: "high";
|
|
15614
|
+
xhigh: "xhigh";
|
|
15615
|
+
ultracode: "ultracode";
|
|
15616
|
+
}>;
|
|
15617
|
+
}, z.core.$strict>;
|
|
15618
|
+
}, z.core.$strict>;
|
|
15619
|
+
candidate: z.ZodObject<{
|
|
15620
|
+
authored: z.ZodObject<{
|
|
15621
|
+
default: z.ZodOptional<z.ZodString>;
|
|
15622
|
+
small: z.ZodOptional<z.ZodString>;
|
|
15623
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
15624
|
+
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
15625
|
+
none: "none";
|
|
15626
|
+
minimal: "minimal";
|
|
15627
|
+
low: "low";
|
|
15628
|
+
medium: "medium";
|
|
15629
|
+
high: "high";
|
|
15630
|
+
xhigh: "xhigh";
|
|
15631
|
+
ultracode: "ultracode";
|
|
15632
|
+
}>>;
|
|
15633
|
+
maxVisibleOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
15634
|
+
maxReasoningTokens: z.ZodOptional<z.ZodNumber>;
|
|
15635
|
+
maxTotalOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
15636
|
+
metadata: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
|
|
15637
|
+
}, z.core.$strict>;
|
|
15638
|
+
resolved: z.ZodObject<{
|
|
15639
|
+
requested: z.ZodString;
|
|
15640
|
+
provider: z.ZodString;
|
|
15641
|
+
model: z.ZodString;
|
|
15642
|
+
snapshot: z.ZodString;
|
|
15643
|
+
reasoningEffort: z.ZodEnum<{
|
|
15644
|
+
none: "none";
|
|
15645
|
+
minimal: "minimal";
|
|
15646
|
+
low: "low";
|
|
15647
|
+
medium: "medium";
|
|
15648
|
+
high: "high";
|
|
15649
|
+
xhigh: "xhigh";
|
|
15650
|
+
ultracode: "ultracode";
|
|
15651
|
+
}>;
|
|
15652
|
+
}, z.core.$strict>;
|
|
15653
|
+
}, z.core.$strict>;
|
|
15654
|
+
}, z.core.$strict>], "kind">>;
|
|
15580
15655
|
candidateLineage: z.ZodObject<{
|
|
15581
15656
|
source: z.ZodEnum<{
|
|
15582
15657
|
"frontier-author": "frontier-author";
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import type { AgentProfileImprovementAccounting, AgentProfileImprovementUnavailableAccounting, AgentProfileImprovementExperiment, AgentProfileImprovementTask } from "./agent-profile-improvement.js";
|
|
2
3
|
import type { AgentImprovementSurface } from "./agent-candidate.js";
|
|
4
|
+
import type { AgentProfile } from "./agent-profile.js";
|
|
3
5
|
import type { AgentProfileDiff } from "./profile-diff.js";
|
|
4
6
|
export declare const agentProfileImprovementTaskSchema: z.ZodObject<{
|
|
5
7
|
kind: z.ZodLiteral<"agent-profile-improvement-task">;
|
|
@@ -202,6 +204,91 @@ export declare const agentProfileImprovementExecutionRefSchema: z.ZodObject<{
|
|
|
202
204
|
/** One strict canonical profile patch in an ordered measured change. */
|
|
203
205
|
export declare const agentProfileImprovementChangeStepSchema: z.ZodType<AgentProfileDiff, unknown, z.core.$ZodTypeInternals<AgentProfileDiff, unknown>>;
|
|
204
206
|
export declare const agentProfileImprovementChangeSchema: z.ZodTuple<[z.ZodType<AgentProfileDiff, unknown, z.core.$ZodTypeInternals<AgentProfileDiff, unknown>>], z.ZodType<AgentProfileDiff, unknown, z.core.$ZodTypeInternals<AgentProfileDiff, unknown>>>;
|
|
207
|
+
export declare const agentProfileImprovementModelBindingSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
208
|
+
kind: z.ZodLiteral<"fixed-task">;
|
|
209
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
210
|
+
kind: z.ZodLiteral<"profile-default">;
|
|
211
|
+
baseline: z.ZodObject<{
|
|
212
|
+
authored: z.ZodObject<{
|
|
213
|
+
default: z.ZodOptional<z.ZodString>;
|
|
214
|
+
small: z.ZodOptional<z.ZodString>;
|
|
215
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
216
|
+
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
217
|
+
none: "none";
|
|
218
|
+
minimal: "minimal";
|
|
219
|
+
low: "low";
|
|
220
|
+
medium: "medium";
|
|
221
|
+
high: "high";
|
|
222
|
+
xhigh: "xhigh";
|
|
223
|
+
ultracode: "ultracode";
|
|
224
|
+
}>>;
|
|
225
|
+
maxVisibleOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
226
|
+
maxReasoningTokens: z.ZodOptional<z.ZodNumber>;
|
|
227
|
+
maxTotalOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
228
|
+
metadata: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
|
|
229
|
+
}, z.core.$strict>;
|
|
230
|
+
resolved: z.ZodObject<{
|
|
231
|
+
requested: z.ZodString;
|
|
232
|
+
provider: z.ZodString;
|
|
233
|
+
model: z.ZodString;
|
|
234
|
+
snapshot: z.ZodString;
|
|
235
|
+
reasoningEffort: z.ZodEnum<{
|
|
236
|
+
none: "none";
|
|
237
|
+
minimal: "minimal";
|
|
238
|
+
low: "low";
|
|
239
|
+
medium: "medium";
|
|
240
|
+
high: "high";
|
|
241
|
+
xhigh: "xhigh";
|
|
242
|
+
ultracode: "ultracode";
|
|
243
|
+
}>;
|
|
244
|
+
}, z.core.$strict>;
|
|
245
|
+
}, z.core.$strict>;
|
|
246
|
+
candidate: z.ZodObject<{
|
|
247
|
+
authored: z.ZodObject<{
|
|
248
|
+
default: z.ZodOptional<z.ZodString>;
|
|
249
|
+
small: z.ZodOptional<z.ZodString>;
|
|
250
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
251
|
+
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
252
|
+
none: "none";
|
|
253
|
+
minimal: "minimal";
|
|
254
|
+
low: "low";
|
|
255
|
+
medium: "medium";
|
|
256
|
+
high: "high";
|
|
257
|
+
xhigh: "xhigh";
|
|
258
|
+
ultracode: "ultracode";
|
|
259
|
+
}>>;
|
|
260
|
+
maxVisibleOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
261
|
+
maxReasoningTokens: z.ZodOptional<z.ZodNumber>;
|
|
262
|
+
maxTotalOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
263
|
+
metadata: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
|
|
264
|
+
}, z.core.$strict>;
|
|
265
|
+
resolved: z.ZodObject<{
|
|
266
|
+
requested: z.ZodString;
|
|
267
|
+
provider: z.ZodString;
|
|
268
|
+
model: z.ZodString;
|
|
269
|
+
snapshot: z.ZodString;
|
|
270
|
+
reasoningEffort: z.ZodEnum<{
|
|
271
|
+
none: "none";
|
|
272
|
+
minimal: "minimal";
|
|
273
|
+
low: "low";
|
|
274
|
+
medium: "medium";
|
|
275
|
+
high: "high";
|
|
276
|
+
xhigh: "xhigh";
|
|
277
|
+
ultracode: "ultracode";
|
|
278
|
+
}>;
|
|
279
|
+
}, z.core.$strict>;
|
|
280
|
+
}, z.core.$strict>;
|
|
281
|
+
}, z.core.$strict>], "kind">;
|
|
282
|
+
/** One model-policy interpretation for schema, measurement and the source-owning executor.
|
|
283
|
+
* Pass the actual profile when sealing/executing to prove its authored default matches the binding.
|
|
284
|
+
* The host must independently observe the exact returned model and snapshot for each run. */
|
|
285
|
+
export declare function agentProfileImprovementExpectedModel(experiment: Pick<AgentProfileImprovementExperiment, "modelBinding" | "change">, task: Pick<AgentProfileImprovementTask, "model">, arm: "baseline" | "candidate", profile?: AgentProfile): {
|
|
286
|
+
requested: string;
|
|
287
|
+
provider: string;
|
|
288
|
+
model: string;
|
|
289
|
+
snapshot: string;
|
|
290
|
+
reasoningEffort: "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "ultracode";
|
|
291
|
+
};
|
|
205
292
|
export declare const agentProfileImprovementExperimentSchema: z.ZodObject<{
|
|
206
293
|
kind: z.ZodLiteral<"agent-profile-improvement-experiment">;
|
|
207
294
|
digestAlgorithm: z.ZodLiteral<"rfc8785-sha256">;
|
|
@@ -245,6 +332,81 @@ export declare const agentProfileImprovementExperimentSchema: z.ZodObject<{
|
|
|
245
332
|
stateDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
246
333
|
}, z.core.$strict>;
|
|
247
334
|
change: z.ZodTuple<[z.ZodType<AgentProfileDiff, unknown, z.core.$ZodTypeInternals<AgentProfileDiff, unknown>>], z.ZodType<AgentProfileDiff, unknown, z.core.$ZodTypeInternals<AgentProfileDiff, unknown>>>;
|
|
335
|
+
modelBinding: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
336
|
+
kind: z.ZodLiteral<"fixed-task">;
|
|
337
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
338
|
+
kind: z.ZodLiteral<"profile-default">;
|
|
339
|
+
baseline: z.ZodObject<{
|
|
340
|
+
authored: z.ZodObject<{
|
|
341
|
+
default: z.ZodOptional<z.ZodString>;
|
|
342
|
+
small: z.ZodOptional<z.ZodString>;
|
|
343
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
344
|
+
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
345
|
+
none: "none";
|
|
346
|
+
minimal: "minimal";
|
|
347
|
+
low: "low";
|
|
348
|
+
medium: "medium";
|
|
349
|
+
high: "high";
|
|
350
|
+
xhigh: "xhigh";
|
|
351
|
+
ultracode: "ultracode";
|
|
352
|
+
}>>;
|
|
353
|
+
maxVisibleOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
354
|
+
maxReasoningTokens: z.ZodOptional<z.ZodNumber>;
|
|
355
|
+
maxTotalOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
356
|
+
metadata: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
|
|
357
|
+
}, z.core.$strict>;
|
|
358
|
+
resolved: z.ZodObject<{
|
|
359
|
+
requested: z.ZodString;
|
|
360
|
+
provider: z.ZodString;
|
|
361
|
+
model: z.ZodString;
|
|
362
|
+
snapshot: z.ZodString;
|
|
363
|
+
reasoningEffort: z.ZodEnum<{
|
|
364
|
+
none: "none";
|
|
365
|
+
minimal: "minimal";
|
|
366
|
+
low: "low";
|
|
367
|
+
medium: "medium";
|
|
368
|
+
high: "high";
|
|
369
|
+
xhigh: "xhigh";
|
|
370
|
+
ultracode: "ultracode";
|
|
371
|
+
}>;
|
|
372
|
+
}, z.core.$strict>;
|
|
373
|
+
}, z.core.$strict>;
|
|
374
|
+
candidate: z.ZodObject<{
|
|
375
|
+
authored: z.ZodObject<{
|
|
376
|
+
default: z.ZodOptional<z.ZodString>;
|
|
377
|
+
small: z.ZodOptional<z.ZodString>;
|
|
378
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
379
|
+
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
380
|
+
none: "none";
|
|
381
|
+
minimal: "minimal";
|
|
382
|
+
low: "low";
|
|
383
|
+
medium: "medium";
|
|
384
|
+
high: "high";
|
|
385
|
+
xhigh: "xhigh";
|
|
386
|
+
ultracode: "ultracode";
|
|
387
|
+
}>>;
|
|
388
|
+
maxVisibleOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
389
|
+
maxReasoningTokens: z.ZodOptional<z.ZodNumber>;
|
|
390
|
+
maxTotalOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
391
|
+
metadata: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
|
|
392
|
+
}, z.core.$strict>;
|
|
393
|
+
resolved: z.ZodObject<{
|
|
394
|
+
requested: z.ZodString;
|
|
395
|
+
provider: z.ZodString;
|
|
396
|
+
model: z.ZodString;
|
|
397
|
+
snapshot: z.ZodString;
|
|
398
|
+
reasoningEffort: z.ZodEnum<{
|
|
399
|
+
none: "none";
|
|
400
|
+
minimal: "minimal";
|
|
401
|
+
low: "low";
|
|
402
|
+
medium: "medium";
|
|
403
|
+
high: "high";
|
|
404
|
+
xhigh: "xhigh";
|
|
405
|
+
ultracode: "ultracode";
|
|
406
|
+
}>;
|
|
407
|
+
}, z.core.$strict>;
|
|
408
|
+
}, z.core.$strict>;
|
|
409
|
+
}, z.core.$strict>], "kind">>;
|
|
248
410
|
candidateLineage: z.ZodObject<{
|
|
249
411
|
source: z.ZodEnum<{
|
|
250
412
|
"frontier-author": "frontier-author";
|
|
@@ -411,6 +573,50 @@ export declare const agentProfileImprovementRunCellSchema: z.ZodObject<{
|
|
|
411
573
|
attempt: z.ZodNumber;
|
|
412
574
|
digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
413
575
|
}, z.core.$strict>;
|
|
576
|
+
export declare const agentProfileImprovementUnavailableAccountingSchema: z.ZodObject<{
|
|
577
|
+
availability: z.ZodLiteral<"unavailable">;
|
|
578
|
+
reason: z.ZodString;
|
|
579
|
+
facts: z.ZodObject<{
|
|
580
|
+
inputTokens: z.ZodNullable<z.ZodNumber>;
|
|
581
|
+
outputTokens: z.ZodNullable<z.ZodNumber>;
|
|
582
|
+
cachedInputTokens: z.ZodNullable<z.ZodNumber>;
|
|
583
|
+
reasoningTokens: z.ZodNullable<z.ZodNumber>;
|
|
584
|
+
modelCalls: z.ZodNullable<z.ZodNumber>;
|
|
585
|
+
costUsdNanos: z.ZodNullable<z.ZodNumber>;
|
|
586
|
+
costProvenance: z.ZodNullable<z.ZodEnum<{
|
|
587
|
+
observed: "observed";
|
|
588
|
+
estimated: "estimated";
|
|
589
|
+
}>>;
|
|
590
|
+
}, z.core.$strict>;
|
|
591
|
+
}, z.core.$strict>;
|
|
592
|
+
export declare const agentProfileImprovementAccountingSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
593
|
+
inputTokens: z.ZodNumber;
|
|
594
|
+
outputTokens: z.ZodNumber;
|
|
595
|
+
cachedInputTokens: z.ZodNumber;
|
|
596
|
+
reasoningTokens: z.ZodNumber;
|
|
597
|
+
modelCalls: z.ZodNumber;
|
|
598
|
+
costUsdNanos: z.ZodNumber;
|
|
599
|
+
costProvenance: z.ZodEnum<{
|
|
600
|
+
observed: "observed";
|
|
601
|
+
estimated: "estimated";
|
|
602
|
+
}>;
|
|
603
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
604
|
+
availability: z.ZodLiteral<"unavailable">;
|
|
605
|
+
reason: z.ZodString;
|
|
606
|
+
facts: z.ZodObject<{
|
|
607
|
+
inputTokens: z.ZodNullable<z.ZodNumber>;
|
|
608
|
+
outputTokens: z.ZodNullable<z.ZodNumber>;
|
|
609
|
+
cachedInputTokens: z.ZodNullable<z.ZodNumber>;
|
|
610
|
+
reasoningTokens: z.ZodNullable<z.ZodNumber>;
|
|
611
|
+
modelCalls: z.ZodNullable<z.ZodNumber>;
|
|
612
|
+
costUsdNanos: z.ZodNullable<z.ZodNumber>;
|
|
613
|
+
costProvenance: z.ZodNullable<z.ZodEnum<{
|
|
614
|
+
observed: "observed";
|
|
615
|
+
estimated: "estimated";
|
|
616
|
+
}>>;
|
|
617
|
+
}, z.core.$strict>;
|
|
618
|
+
}, z.core.$strict>]>;
|
|
619
|
+
export declare function isAgentProfileImprovementAccountingUnavailable(accounting: AgentProfileImprovementAccounting): accounting is AgentProfileImprovementUnavailableAccounting;
|
|
414
620
|
export declare const agentProfileImprovementRunReceiptSchema: z.ZodObject<{
|
|
415
621
|
kind: z.ZodLiteral<"agent-profile-improvement-run">;
|
|
416
622
|
digestAlgorithm: z.ZodLiteral<"rfc8785-sha256">;
|
|
@@ -568,6 +774,194 @@ export declare const agentProfileImprovementRunReceiptSchema: z.ZodObject<{
|
|
|
568
774
|
}, z.core.$strict>;
|
|
569
775
|
digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
570
776
|
}, z.core.$strict>;
|
|
777
|
+
/** Opt-in recording preserves gaps; the publishable comparison still accepts only complete receipts. */
|
|
778
|
+
export declare const agentProfileImprovementRecordedRunReceiptSchema: z.ZodObject<{
|
|
779
|
+
usage: z.ZodUnion<readonly [z.ZodObject<{
|
|
780
|
+
inputTokens: z.ZodNumber;
|
|
781
|
+
outputTokens: z.ZodNumber;
|
|
782
|
+
cachedInputTokens: z.ZodNumber;
|
|
783
|
+
reasoningTokens: z.ZodNumber;
|
|
784
|
+
modelCalls: z.ZodNumber;
|
|
785
|
+
costUsdNanos: z.ZodNumber;
|
|
786
|
+
costProvenance: z.ZodEnum<{
|
|
787
|
+
observed: "observed";
|
|
788
|
+
estimated: "estimated";
|
|
789
|
+
}>;
|
|
790
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
791
|
+
availability: z.ZodLiteral<"unavailable">;
|
|
792
|
+
reason: z.ZodString;
|
|
793
|
+
facts: z.ZodObject<{
|
|
794
|
+
inputTokens: z.ZodNullable<z.ZodNumber>;
|
|
795
|
+
outputTokens: z.ZodNullable<z.ZodNumber>;
|
|
796
|
+
cachedInputTokens: z.ZodNullable<z.ZodNumber>;
|
|
797
|
+
reasoningTokens: z.ZodNullable<z.ZodNumber>;
|
|
798
|
+
modelCalls: z.ZodNullable<z.ZodNumber>;
|
|
799
|
+
costUsdNanos: z.ZodNullable<z.ZodNumber>;
|
|
800
|
+
costProvenance: z.ZodNullable<z.ZodEnum<{
|
|
801
|
+
observed: "observed";
|
|
802
|
+
estimated: "estimated";
|
|
803
|
+
}>>;
|
|
804
|
+
}, z.core.$strict>;
|
|
805
|
+
}, z.core.$strict>]>;
|
|
806
|
+
grading: z.ZodObject<{
|
|
807
|
+
usage: z.ZodUnion<readonly [z.ZodObject<{
|
|
808
|
+
inputTokens: z.ZodNumber;
|
|
809
|
+
outputTokens: z.ZodNumber;
|
|
810
|
+
cachedInputTokens: z.ZodNumber;
|
|
811
|
+
reasoningTokens: z.ZodNumber;
|
|
812
|
+
modelCalls: z.ZodNumber;
|
|
813
|
+
costUsdNanos: z.ZodNumber;
|
|
814
|
+
costProvenance: z.ZodEnum<{
|
|
815
|
+
observed: "observed";
|
|
816
|
+
estimated: "estimated";
|
|
817
|
+
}>;
|
|
818
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
819
|
+
availability: z.ZodLiteral<"unavailable">;
|
|
820
|
+
reason: z.ZodString;
|
|
821
|
+
facts: z.ZodObject<{
|
|
822
|
+
inputTokens: z.ZodNullable<z.ZodNumber>;
|
|
823
|
+
outputTokens: z.ZodNullable<z.ZodNumber>;
|
|
824
|
+
cachedInputTokens: z.ZodNullable<z.ZodNumber>;
|
|
825
|
+
reasoningTokens: z.ZodNullable<z.ZodNumber>;
|
|
826
|
+
modelCalls: z.ZodNullable<z.ZodNumber>;
|
|
827
|
+
costUsdNanos: z.ZodNullable<z.ZodNumber>;
|
|
828
|
+
costProvenance: z.ZodNullable<z.ZodEnum<{
|
|
829
|
+
observed: "observed";
|
|
830
|
+
estimated: "estimated";
|
|
831
|
+
}>>;
|
|
832
|
+
}, z.core.$strict>;
|
|
833
|
+
}, z.core.$strict>]>;
|
|
834
|
+
grader: z.ZodObject<{
|
|
835
|
+
name: z.ZodString;
|
|
836
|
+
version: z.ZodString;
|
|
837
|
+
format: z.ZodLiteral<"tangle-grader">;
|
|
838
|
+
artifact: z.ZodObject<{
|
|
839
|
+
locator: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
840
|
+
kind: z.ZodLiteral<"s3">;
|
|
841
|
+
bucket: z.ZodString;
|
|
842
|
+
key: z.ZodString;
|
|
843
|
+
region: z.ZodOptional<z.ZodString>;
|
|
844
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
845
|
+
kind: z.ZodLiteral<"ipfs">;
|
|
846
|
+
cid: z.ZodString;
|
|
847
|
+
path: z.ZodOptional<z.ZodString>;
|
|
848
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
849
|
+
kind: z.ZodLiteral<"private-cas">;
|
|
850
|
+
namespace: z.ZodString;
|
|
851
|
+
digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
852
|
+
}, z.core.$strict>], "kind">;
|
|
853
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
854
|
+
byteLength: z.ZodNumber;
|
|
855
|
+
}, z.core.$strict>;
|
|
856
|
+
}, z.core.$strict>;
|
|
857
|
+
evidence: z.ZodObject<{
|
|
858
|
+
kind: z.ZodString;
|
|
859
|
+
identity: z.ZodString;
|
|
860
|
+
digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
861
|
+
}, z.core.$strict>;
|
|
862
|
+
timing: z.ZodObject<{
|
|
863
|
+
startedAtMs: z.ZodNumber;
|
|
864
|
+
endedAtMs: z.ZodNumber;
|
|
865
|
+
durationMs: z.ZodNumber;
|
|
866
|
+
}, z.core.$strict>;
|
|
867
|
+
score: z.ZodNumber;
|
|
868
|
+
passed: z.ZodBoolean;
|
|
869
|
+
dimensions: z.ZodArray<z.ZodObject<{
|
|
870
|
+
name: z.ZodString;
|
|
871
|
+
score: z.ZodNumber;
|
|
872
|
+
}, z.core.$strict>>;
|
|
873
|
+
}, z.core.$strict>;
|
|
874
|
+
kind: z.ZodLiteral<"agent-profile-improvement-run">;
|
|
875
|
+
digestAlgorithm: z.ZodLiteral<"rfc8785-sha256">;
|
|
876
|
+
executionId: z.ZodString;
|
|
877
|
+
executionRef: z.ZodObject<{
|
|
878
|
+
identity: z.ZodString;
|
|
879
|
+
digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
880
|
+
kind: z.ZodLiteral<"agent-profile-improvement-execution-ref">;
|
|
881
|
+
}, z.core.$strict>;
|
|
882
|
+
runCell: z.ZodObject<{
|
|
883
|
+
kind: z.ZodLiteral<"agent-profile-improvement-run-cell">;
|
|
884
|
+
experimentDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
885
|
+
arm: z.ZodEnum<{
|
|
886
|
+
baseline: "baseline";
|
|
887
|
+
candidate: "candidate";
|
|
888
|
+
}>;
|
|
889
|
+
stateDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
890
|
+
suiteDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
891
|
+
taskDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
892
|
+
taskIndex: z.ZodNumber;
|
|
893
|
+
repetition: z.ZodNumber;
|
|
894
|
+
seed: z.ZodNumber;
|
|
895
|
+
attempt: z.ZodNumber;
|
|
896
|
+
digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
897
|
+
}, z.core.$strict>;
|
|
898
|
+
runRecord: z.ZodObject<{
|
|
899
|
+
kind: z.ZodString;
|
|
900
|
+
identity: z.ZodString;
|
|
901
|
+
digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
902
|
+
}, z.core.$strict>;
|
|
903
|
+
billing: z.ZodTuple<[z.ZodObject<{
|
|
904
|
+
kind: z.ZodString;
|
|
905
|
+
identity: z.ZodString;
|
|
906
|
+
digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
907
|
+
}, z.core.$strict>], z.ZodObject<{
|
|
908
|
+
kind: z.ZodString;
|
|
909
|
+
identity: z.ZodString;
|
|
910
|
+
digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
911
|
+
}, z.core.$strict>>;
|
|
912
|
+
timing: z.ZodObject<{
|
|
913
|
+
startedAtMs: z.ZodNumber;
|
|
914
|
+
endedAtMs: z.ZodNumber;
|
|
915
|
+
durationMs: z.ZodNumber;
|
|
916
|
+
}, z.core.$strict>;
|
|
917
|
+
steps: z.ZodNumber;
|
|
918
|
+
resolvedModel: z.ZodObject<{
|
|
919
|
+
requested: z.ZodString;
|
|
920
|
+
provider: z.ZodString;
|
|
921
|
+
model: z.ZodString;
|
|
922
|
+
snapshot: z.ZodString;
|
|
923
|
+
reasoningEffort: z.ZodEnum<{
|
|
924
|
+
none: "none";
|
|
925
|
+
minimal: "minimal";
|
|
926
|
+
low: "low";
|
|
927
|
+
medium: "medium";
|
|
928
|
+
high: "high";
|
|
929
|
+
xhigh: "xhigh";
|
|
930
|
+
ultracode: "ultracode";
|
|
931
|
+
}>;
|
|
932
|
+
}, z.core.$strict>;
|
|
933
|
+
limits: z.ZodObject<{
|
|
934
|
+
timeoutMs: z.ZodNumber;
|
|
935
|
+
maxSteps: z.ZodNumber;
|
|
936
|
+
maxModelCalls: z.ZodNumber;
|
|
937
|
+
maxInputTokens: z.ZodNumber;
|
|
938
|
+
maxOutputTokens: z.ZodNumber;
|
|
939
|
+
maxTotalTokens: z.ZodOptional<z.ZodNumber>;
|
|
940
|
+
maxCostUsd: z.ZodNumber;
|
|
941
|
+
}, z.core.$strict>;
|
|
942
|
+
trace: z.ZodObject<{
|
|
943
|
+
evidence: z.ZodObject<{
|
|
944
|
+
kind: z.ZodString;
|
|
945
|
+
identity: z.ZodString;
|
|
946
|
+
digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
947
|
+
}, z.core.$strict>;
|
|
948
|
+
eventCount: z.ZodNumber;
|
|
949
|
+
modelCallCount: z.ZodNumber;
|
|
950
|
+
}, z.core.$strict>;
|
|
951
|
+
output: z.ZodObject<{
|
|
952
|
+
kind: z.ZodString;
|
|
953
|
+
identity: z.ZodString;
|
|
954
|
+
digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
955
|
+
}, z.core.$strict>;
|
|
956
|
+
outcome: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
957
|
+
status: z.ZodLiteral<"succeeded">;
|
|
958
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
959
|
+
status: z.ZodLiteral<"failed">;
|
|
960
|
+
code: z.ZodString;
|
|
961
|
+
message: z.ZodString;
|
|
962
|
+
}, z.core.$strict>], "status">;
|
|
963
|
+
digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
964
|
+
}, z.core.$strict>;
|
|
571
965
|
export declare const agentProfileImprovementMeasuredComparisonSchema: z.ZodObject<{
|
|
572
966
|
overall: z.ZodObject<{
|
|
573
967
|
direction: z.ZodLiteral<"higher-is-better">;
|
|
@@ -790,6 +1184,81 @@ export declare const agentProfileImprovementMeasuredComparisonSchema: z.ZodObjec
|
|
|
790
1184
|
stateDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
791
1185
|
}, z.core.$strict>;
|
|
792
1186
|
change: z.ZodTuple<[z.ZodType<AgentProfileDiff, unknown, z.core.$ZodTypeInternals<AgentProfileDiff, unknown>>], z.ZodType<AgentProfileDiff, unknown, z.core.$ZodTypeInternals<AgentProfileDiff, unknown>>>;
|
|
1187
|
+
modelBinding: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1188
|
+
kind: z.ZodLiteral<"fixed-task">;
|
|
1189
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1190
|
+
kind: z.ZodLiteral<"profile-default">;
|
|
1191
|
+
baseline: z.ZodObject<{
|
|
1192
|
+
authored: z.ZodObject<{
|
|
1193
|
+
default: z.ZodOptional<z.ZodString>;
|
|
1194
|
+
small: z.ZodOptional<z.ZodString>;
|
|
1195
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
1196
|
+
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
1197
|
+
none: "none";
|
|
1198
|
+
minimal: "minimal";
|
|
1199
|
+
low: "low";
|
|
1200
|
+
medium: "medium";
|
|
1201
|
+
high: "high";
|
|
1202
|
+
xhigh: "xhigh";
|
|
1203
|
+
ultracode: "ultracode";
|
|
1204
|
+
}>>;
|
|
1205
|
+
maxVisibleOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
1206
|
+
maxReasoningTokens: z.ZodOptional<z.ZodNumber>;
|
|
1207
|
+
maxTotalOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
1208
|
+
metadata: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
|
|
1209
|
+
}, z.core.$strict>;
|
|
1210
|
+
resolved: z.ZodObject<{
|
|
1211
|
+
requested: z.ZodString;
|
|
1212
|
+
provider: z.ZodString;
|
|
1213
|
+
model: z.ZodString;
|
|
1214
|
+
snapshot: z.ZodString;
|
|
1215
|
+
reasoningEffort: z.ZodEnum<{
|
|
1216
|
+
none: "none";
|
|
1217
|
+
minimal: "minimal";
|
|
1218
|
+
low: "low";
|
|
1219
|
+
medium: "medium";
|
|
1220
|
+
high: "high";
|
|
1221
|
+
xhigh: "xhigh";
|
|
1222
|
+
ultracode: "ultracode";
|
|
1223
|
+
}>;
|
|
1224
|
+
}, z.core.$strict>;
|
|
1225
|
+
}, z.core.$strict>;
|
|
1226
|
+
candidate: z.ZodObject<{
|
|
1227
|
+
authored: z.ZodObject<{
|
|
1228
|
+
default: z.ZodOptional<z.ZodString>;
|
|
1229
|
+
small: z.ZodOptional<z.ZodString>;
|
|
1230
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
1231
|
+
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
1232
|
+
none: "none";
|
|
1233
|
+
minimal: "minimal";
|
|
1234
|
+
low: "low";
|
|
1235
|
+
medium: "medium";
|
|
1236
|
+
high: "high";
|
|
1237
|
+
xhigh: "xhigh";
|
|
1238
|
+
ultracode: "ultracode";
|
|
1239
|
+
}>>;
|
|
1240
|
+
maxVisibleOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
1241
|
+
maxReasoningTokens: z.ZodOptional<z.ZodNumber>;
|
|
1242
|
+
maxTotalOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
1243
|
+
metadata: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
|
|
1244
|
+
}, z.core.$strict>;
|
|
1245
|
+
resolved: z.ZodObject<{
|
|
1246
|
+
requested: z.ZodString;
|
|
1247
|
+
provider: z.ZodString;
|
|
1248
|
+
model: z.ZodString;
|
|
1249
|
+
snapshot: z.ZodString;
|
|
1250
|
+
reasoningEffort: z.ZodEnum<{
|
|
1251
|
+
none: "none";
|
|
1252
|
+
minimal: "minimal";
|
|
1253
|
+
low: "low";
|
|
1254
|
+
medium: "medium";
|
|
1255
|
+
high: "high";
|
|
1256
|
+
xhigh: "xhigh";
|
|
1257
|
+
ultracode: "ultracode";
|
|
1258
|
+
}>;
|
|
1259
|
+
}, z.core.$strict>;
|
|
1260
|
+
}, z.core.$strict>;
|
|
1261
|
+
}, z.core.$strict>], "kind">>;
|
|
793
1262
|
candidateLineage: z.ZodObject<{
|
|
794
1263
|
source: z.ZodEnum<{
|
|
795
1264
|
"frontier-author": "frontier-author";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { changedAgentProfileAxes } from "./profile-diff.js";
|
|
2
|
+
import { applyAgentProfileDiff, changedAgentProfileAxes } from "./profile-diff.js";
|
|
3
3
|
import { agentCandidateLineageSchema, isGeneratedCandidateSource, } from "./agent-candidate-lineage-schema.js";
|
|
4
4
|
import { canonicalCandidateDigest, isCanonicalJsonValue, omitTopLevelDigest, sha256DigestSchema, } from "./agent-candidate-schema-common.js";
|
|
5
5
|
import { refineAgentExecutionWithinLimits } from "./agent-execution-limits.js";
|
|
@@ -8,7 +8,7 @@ import { agentCandidateBenchmarkDimensionSchema, agentCandidateFixedSpendSchema,
|
|
|
8
8
|
import { agentCandidateEvaluationPolicySchema, createMeasuredComparisonIdentityRegistry, measuredComparisonCommonShape, refineMeasuredComparisonSummary, } from "./agent-improvement-measurement-schema.js";
|
|
9
9
|
import { agentImprovementSourceSchema } from "./agent-improvement-source.js";
|
|
10
10
|
import { numbersApproximatelyEqual } from "./number-validation.js";
|
|
11
|
-
import { agentProfileDiffSchema } from "./profile-schema.js";
|
|
11
|
+
import { agentProfileDiffSchema, agentProfileModelHintsSchema } from "./profile-schema.js";
|
|
12
12
|
const profileImprovementScenarioSchema = z
|
|
13
13
|
.object({
|
|
14
14
|
id: z.string().min(1).max(500),
|
|
@@ -158,6 +158,54 @@ export const agentProfileImprovementChangeSchema = z
|
|
|
158
158
|
});
|
|
159
159
|
}
|
|
160
160
|
});
|
|
161
|
+
const profileModelBindingArmSchema = z.strictObject({
|
|
162
|
+
authored: agentProfileModelHintsSchema,
|
|
163
|
+
resolved: agentCandidateResolvedModelSchema,
|
|
164
|
+
});
|
|
165
|
+
export const agentProfileImprovementModelBindingSchema = z.discriminatedUnion("kind", [
|
|
166
|
+
z.strictObject({ kind: z.literal("fixed-task") }),
|
|
167
|
+
z.strictObject({
|
|
168
|
+
kind: z.literal("profile-default"),
|
|
169
|
+
baseline: profileModelBindingArmSchema,
|
|
170
|
+
candidate: profileModelBindingArmSchema,
|
|
171
|
+
}),
|
|
172
|
+
]);
|
|
173
|
+
/** One model-policy interpretation for schema, measurement and the source-owning executor.
|
|
174
|
+
* Pass the actual profile when sealing/executing to prove its authored default matches the binding.
|
|
175
|
+
* The host must independently observe the exact returned model and snapshot for each run. */
|
|
176
|
+
export function agentProfileImprovementExpectedModel(experiment, task, arm, profile) {
|
|
177
|
+
const policy = agentProfileImprovementModelBindingSchema.parse(experiment.modelBinding ?? { kind: "fixed-task" });
|
|
178
|
+
if (policy.kind === "fixed-task")
|
|
179
|
+
return agentCandidateResolvedModelSchema.parse(task.model);
|
|
180
|
+
for (const binding of [policy.baseline, policy.candidate]) {
|
|
181
|
+
const { authored, resolved } = binding;
|
|
182
|
+
const { default: requested, provider, reasoningEffort } = authored;
|
|
183
|
+
const concrete = (value) => value !== undefined && /^[A-Za-z0-9][A-Za-z0-9._:/@+-]*$/.test(value);
|
|
184
|
+
if (!concrete(requested) || !concrete(provider) || reasoningEffort === undefined ||
|
|
185
|
+
authored.small !== undefined || authored.metadata !== undefined)
|
|
186
|
+
throw new Error("profile model binding requires an exact static default/provider/effort without fallback or metadata routing");
|
|
187
|
+
const model = requested.startsWith(`${provider}/`)
|
|
188
|
+
? requested.slice(provider.length + 1) : requested;
|
|
189
|
+
if (resolved.requested !== requested || resolved.provider !== provider ||
|
|
190
|
+
resolved.reasoningEffort !== reasoningEffort || resolved.model !== model ||
|
|
191
|
+
!concrete(resolved.snapshot))
|
|
192
|
+
throw new Error("profile model binding contradicts its authored default or exact resolved identity");
|
|
193
|
+
}
|
|
194
|
+
if (canonicalCandidateDigest(task.model) !== canonicalCandidateDigest(policy.baseline.resolved))
|
|
195
|
+
throw new Error("profile model treatment task.model must equal the exact baseline model");
|
|
196
|
+
const changed = experiment.change.reduce((value, diff) => applyAgentProfileDiff(value, diff), { model: policy.baseline.authored });
|
|
197
|
+
if (changed.seats?.length || Object.values(changed.modes ?? {}).some(value => value.model !== undefined) || Object.values(changed.subagents ?? {}).some(value => value.model !== undefined))
|
|
198
|
+
throw new Error("profile model binding does not permit fallback or alternate model routes");
|
|
199
|
+
if (canonicalCandidateDigest(changed.model) !== canonicalCandidateDigest(policy.candidate.authored))
|
|
200
|
+
throw new Error("profile model binding contradicts the measured profile changes");
|
|
201
|
+
const expected = policy[arm];
|
|
202
|
+
if (profile && (canonicalCandidateDigest(profile.model) !== canonicalCandidateDigest(expected.authored) ||
|
|
203
|
+
profile.seats?.length ||
|
|
204
|
+
Object.values(profile.modes ?? {}).some(value => value.model !== undefined) ||
|
|
205
|
+
Object.values(profile.subagents ?? {}).some(value => value.model !== undefined)))
|
|
206
|
+
throw new Error("profile model binding does not describe the exact static single-model profile");
|
|
207
|
+
return expected.resolved;
|
|
208
|
+
}
|
|
161
209
|
export const agentProfileImprovementExperimentSchema = z
|
|
162
210
|
.object({
|
|
163
211
|
kind: z.literal("agent-profile-improvement-experiment"),
|
|
@@ -167,6 +215,7 @@ export const agentProfileImprovementExperimentSchema = z
|
|
|
167
215
|
baseline: agentProfileImprovementArmSchema,
|
|
168
216
|
candidate: agentProfileImprovementArmSchema,
|
|
169
217
|
change: agentProfileImprovementChangeSchema,
|
|
218
|
+
modelBinding: agentProfileImprovementModelBindingSchema.optional(),
|
|
170
219
|
candidateLineage: agentCandidateLineageSchema,
|
|
171
220
|
benchmark: agentProfileImprovementSuiteInputsSchema,
|
|
172
221
|
policy: agentCandidateEvaluationPolicySchema,
|
|
@@ -174,6 +223,14 @@ export const agentProfileImprovementExperimentSchema = z
|
|
|
174
223
|
})
|
|
175
224
|
.strict()
|
|
176
225
|
.superRefine((experiment, ctx) => {
|
|
226
|
+
try {
|
|
227
|
+
for (const task of experiment.benchmark.tasks)
|
|
228
|
+
for (const arm of ["baseline", "candidate"])
|
|
229
|
+
agentProfileImprovementExpectedModel(experiment, task, arm);
|
|
230
|
+
}
|
|
231
|
+
catch (error) {
|
|
232
|
+
ctx.addIssue({ code: "custom", path: ["modelBinding"], message: error instanceof Error ? error.message : "Invalid profile model binding" });
|
|
233
|
+
}
|
|
177
234
|
if (experiment.baseline.stateDigest !== experiment.source.sourceDigest) {
|
|
178
235
|
ctx.addIssue({
|
|
179
236
|
code: "custom",
|
|
@@ -260,8 +317,7 @@ const timingSchema = z
|
|
|
260
317
|
});
|
|
261
318
|
}
|
|
262
319
|
});
|
|
263
|
-
const
|
|
264
|
-
.object({
|
|
320
|
+
const profileGradingShape = {
|
|
265
321
|
grader: agentCandidateBenchmarkGraderIdentitySchema,
|
|
266
322
|
evidence: profileImprovementEvidenceSchema,
|
|
267
323
|
timing: timingSchema,
|
|
@@ -269,9 +325,8 @@ const agentProfileImprovementGradingSchema = z
|
|
|
269
325
|
score: z.number().finite(),
|
|
270
326
|
passed: z.boolean(),
|
|
271
327
|
dimensions: z.array(agentCandidateBenchmarkDimensionSchema),
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
.superRefine((grading, ctx) => {
|
|
328
|
+
};
|
|
329
|
+
function refineProfileGrading(grading, ctx) {
|
|
275
330
|
const names = grading.dimensions.map((dimension) => dimension.name);
|
|
276
331
|
if (new Set(names).size !== names.length) {
|
|
277
332
|
ctx.addIssue({
|
|
@@ -287,9 +342,31 @@ const agentProfileImprovementGradingSchema = z
|
|
|
287
342
|
message: "profile improvement grading evidence must be distinct from its grader",
|
|
288
343
|
});
|
|
289
344
|
}
|
|
345
|
+
}
|
|
346
|
+
const agentProfileImprovementGradingSchema = z.strictObject(profileGradingShape).superRefine(refineProfileGrading);
|
|
347
|
+
export const agentProfileImprovementUnavailableAccountingSchema = z.strictObject({
|
|
348
|
+
availability: z.literal("unavailable"),
|
|
349
|
+
reason: z.string().min(1).max(4000),
|
|
350
|
+
facts: z.strictObject({
|
|
351
|
+
inputTokens: agentCandidateFixedSpendSchema.shape.inputTokens.nullable(),
|
|
352
|
+
outputTokens: agentCandidateFixedSpendSchema.shape.outputTokens.nullable(),
|
|
353
|
+
cachedInputTokens: agentCandidateFixedSpendSchema.shape.cachedInputTokens.nullable(),
|
|
354
|
+
reasoningTokens: agentCandidateFixedSpendSchema.shape.reasoningTokens.nullable(),
|
|
355
|
+
modelCalls: agentCandidateFixedSpendSchema.shape.modelCalls.nullable(),
|
|
356
|
+
costUsdNanos: agentCandidateFixedSpendSchema.shape.costUsdNanos.nullable(),
|
|
357
|
+
costProvenance: agentCandidateFixedSpendSchema.shape.costProvenance.nullable(),
|
|
358
|
+
}),
|
|
359
|
+
}).superRefine((accounting, ctx) => {
|
|
360
|
+
if (!Object.values(accounting.facts).includes(null))
|
|
361
|
+
ctx.addIssue({ code: "custom", path: ["facts"], message: "complete accounting must use the fixed-spend contract" });
|
|
362
|
+
if ((accounting.facts.costUsdNanos === null) !== (accounting.facts.costProvenance === null))
|
|
363
|
+
ctx.addIssue({ code: "custom", path: ["facts", "costProvenance"], message: "known cost and provenance must be retained together" });
|
|
290
364
|
});
|
|
291
|
-
export const
|
|
292
|
-
|
|
365
|
+
export const agentProfileImprovementAccountingSchema = z.union([agentCandidateFixedSpendSchema, agentProfileImprovementUnavailableAccountingSchema]);
|
|
366
|
+
export function isAgentProfileImprovementAccountingUnavailable(accounting) {
|
|
367
|
+
return "availability" in accounting;
|
|
368
|
+
}
|
|
369
|
+
const profileRunReceiptShape = {
|
|
293
370
|
kind: z.literal("agent-profile-improvement-run"),
|
|
294
371
|
digestAlgorithm: z.literal("rfc8785-sha256"),
|
|
295
372
|
executionId: z.string().min(1).max(500),
|
|
@@ -324,9 +401,8 @@ export const agentProfileImprovementRunReceiptSchema = z
|
|
|
324
401
|
]),
|
|
325
402
|
grading: agentProfileImprovementGradingSchema,
|
|
326
403
|
digest: sha256DigestSchema,
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
.superRefine((receipt, ctx) => {
|
|
404
|
+
};
|
|
405
|
+
function refineProfileRunReceipt(receipt, ctx) {
|
|
330
406
|
if (evidenceKey(receipt.output) === evidenceKey(receipt.grading.evidence)) {
|
|
331
407
|
ctx.addIssue({
|
|
332
408
|
code: "custom",
|
|
@@ -334,7 +410,8 @@ export const agentProfileImprovementRunReceiptSchema = z
|
|
|
334
410
|
message: "profile improvement grading evidence must be distinct from the agent output",
|
|
335
411
|
});
|
|
336
412
|
}
|
|
337
|
-
|
|
413
|
+
const executionUsage = isAgentProfileImprovementAccountingUnavailable(receipt.usage) ? receipt.usage.facts : receipt.usage;
|
|
414
|
+
if (executionUsage.modelCalls !== null && receipt.trace.modelCallCount !== executionUsage.modelCalls) {
|
|
338
415
|
ctx.addIssue({
|
|
339
416
|
code: "custom",
|
|
340
417
|
path: ["trace", "modelCallCount"],
|
|
@@ -348,10 +425,18 @@ export const agentProfileImprovementRunReceiptSchema = z
|
|
|
348
425
|
message: "profile trace must retain at least one event for every model call",
|
|
349
426
|
});
|
|
350
427
|
}
|
|
428
|
+
// Missing nonnegative counters supply only lower bounds for refusing known limit violations.
|
|
429
|
+
// These values are never persisted as measured usage or admitted to a comparison.
|
|
430
|
+
const lowerBound = (usage) => {
|
|
431
|
+
if (!isAgentProfileImprovementAccountingUnavailable(usage))
|
|
432
|
+
return usage;
|
|
433
|
+
const { facts } = usage;
|
|
434
|
+
return { inputTokens: facts.inputTokens ?? 0, outputTokens: facts.outputTokens ?? 0, cachedInputTokens: facts.cachedInputTokens ?? 0, reasoningTokens: facts.reasoningTokens ?? 0, modelCalls: facts.modelCalls ?? 0, costUsdNanos: facts.costUsdNanos ?? 0, costProvenance: facts.costProvenance ?? "estimated" };
|
|
435
|
+
};
|
|
351
436
|
refineAgentExecutionWithinLimits(receipt.limits, {
|
|
352
437
|
durationMs: receipt.timing.durationMs,
|
|
353
438
|
steps: receipt.steps,
|
|
354
|
-
usage: combinedProfileUsage(receipt.usage, receipt.grading.usage),
|
|
439
|
+
usage: combinedProfileUsage(lowerBound(receipt.usage), lowerBound(receipt.grading.usage)),
|
|
355
440
|
}, ctx);
|
|
356
441
|
const billing = receipt.billing.map(evidenceKey);
|
|
357
442
|
if (new Set(billing).size !== billing.length) {
|
|
@@ -368,7 +453,14 @@ export const agentProfileImprovementRunReceiptSchema = z
|
|
|
368
453
|
message: "profile improvement run receipt digest is invalid",
|
|
369
454
|
});
|
|
370
455
|
}
|
|
371
|
-
}
|
|
456
|
+
}
|
|
457
|
+
export const agentProfileImprovementRunReceiptSchema = z.strictObject(profileRunReceiptShape).superRefine(refineProfileRunReceipt);
|
|
458
|
+
/** Opt-in recording preserves gaps; the publishable comparison still accepts only complete receipts. */
|
|
459
|
+
export const agentProfileImprovementRecordedRunReceiptSchema = z.strictObject({
|
|
460
|
+
...profileRunReceiptShape,
|
|
461
|
+
usage: agentProfileImprovementAccountingSchema,
|
|
462
|
+
grading: z.strictObject({ ...profileGradingShape, usage: agentProfileImprovementAccountingSchema }).superRefine(refineProfileGrading),
|
|
463
|
+
}).superRefine(refineProfileRunReceipt);
|
|
372
464
|
function combinedProfileUsage(execution, grading) {
|
|
373
465
|
return {
|
|
374
466
|
inputTokens: execution.inputTokens + grading.inputTokens,
|
|
@@ -507,6 +599,14 @@ function refineProfileImprovementComparison(comparison, ctx) {
|
|
|
507
599
|
const cell = receipt.runCell;
|
|
508
600
|
const profile = comparison.experiment[arm];
|
|
509
601
|
const armPath = ["measurements", index, arm];
|
|
602
|
+
let expectedModel;
|
|
603
|
+
try {
|
|
604
|
+
expectedModel = agentProfileImprovementExpectedModel(comparison.experiment, task, arm);
|
|
605
|
+
}
|
|
606
|
+
catch (error) {
|
|
607
|
+
ctx.addIssue({ code: "custom", path: ["experiment", "modelBinding"], message: error instanceof Error ? error.message : "Invalid profile model binding" });
|
|
608
|
+
continue;
|
|
609
|
+
}
|
|
510
610
|
const checks = [
|
|
511
611
|
[
|
|
512
612
|
cell.experimentDigest === comparison.experiment.digest,
|
|
@@ -544,7 +644,7 @@ function refineProfileImprovementComparison(comparison, ctx) {
|
|
|
544
644
|
"profile run receipt must bind the signed evaluator",
|
|
545
645
|
],
|
|
546
646
|
[
|
|
547
|
-
|
|
647
|
+
canonicalCandidateDigest(receipt.resolvedModel) === canonicalCandidateDigest(expectedModel),
|
|
548
648
|
[...armPath, "resolvedModel"],
|
|
549
649
|
"profile run receipt must bind the signed model snapshot",
|
|
550
650
|
],
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AgentCandidateBenchmarkDimension, AgentCandidateBenchmarkGraderIdentity, AgentCandidateDigestAlgorithm, AgentCandidateEvaluationPolicy, AgentCandidateExecutionLimits, AgentCandidateFixedSpend, AgentCandidateLineage, AgentCandidateResolvedModel, AgentImprovementMeasuredComparisonBase, Sha256Digest } from "./agent-candidate.js";
|
|
2
2
|
import type { AgentImprovementSource } from "./agent-improvement-source.js";
|
|
3
|
+
import type { AgentProfileModelHints } from "./agent-profile.js";
|
|
3
4
|
import type { AgentProfileDiff } from "./profile-diff.js";
|
|
4
5
|
/** An access-controlled evidence record emitted by a host-owned profile run. */
|
|
5
6
|
export interface AgentProfileImprovementEvidence {
|
|
@@ -57,6 +58,20 @@ export interface AgentProfileImprovementExecutionRef extends AgentProfileImprove
|
|
|
57
58
|
* control and redaction.
|
|
58
59
|
*/
|
|
59
60
|
export type AgentProfileImprovementChange = [AgentProfileDiff, ...AgentProfileDiff[]];
|
|
61
|
+
/** Fixed-task is the historical default. Profile-default explicitly treats model selection. */
|
|
62
|
+
export type AgentProfileImprovementModelBinding = {
|
|
63
|
+
kind: "fixed-task";
|
|
64
|
+
} | {
|
|
65
|
+
kind: "profile-default";
|
|
66
|
+
baseline: {
|
|
67
|
+
authored: AgentProfileModelHints;
|
|
68
|
+
resolved: AgentCandidateResolvedModel;
|
|
69
|
+
};
|
|
70
|
+
candidate: {
|
|
71
|
+
authored: AgentProfileModelHints;
|
|
72
|
+
resolved: AgentCandidateResolvedModel;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
60
75
|
/** A measured comparison of two states of one host-owned agent profile. */
|
|
61
76
|
export interface AgentProfileImprovementExperimentMaterial {
|
|
62
77
|
kind: "agent-profile-improvement-experiment";
|
|
@@ -66,6 +81,7 @@ export interface AgentProfileImprovementExperimentMaterial {
|
|
|
66
81
|
baseline: AgentProfileImprovementArm;
|
|
67
82
|
candidate: AgentProfileImprovementArm;
|
|
68
83
|
change: AgentProfileImprovementChange;
|
|
84
|
+
modelBinding?: AgentProfileImprovementModelBinding;
|
|
69
85
|
candidateLineage: AgentCandidateLineage;
|
|
70
86
|
benchmark: AgentProfileImprovementSuiteInputs;
|
|
71
87
|
policy: AgentCandidateEvaluationPolicy;
|
|
@@ -89,8 +105,17 @@ export interface AgentProfileImprovementRunCellMaterial {
|
|
|
89
105
|
export interface AgentProfileImprovementRunCell extends AgentProfileImprovementRunCellMaterial {
|
|
90
106
|
digest: Sha256Digest;
|
|
91
107
|
}
|
|
108
|
+
/** Missing profile-run facts remain explicit; this branch cannot support promotion. */
|
|
109
|
+
export interface AgentProfileImprovementUnavailableAccounting {
|
|
110
|
+
availability: "unavailable";
|
|
111
|
+
reason: string;
|
|
112
|
+
facts: {
|
|
113
|
+
[K in keyof AgentCandidateFixedSpend]: AgentCandidateFixedSpend[K] | null;
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
export type AgentProfileImprovementAccounting = AgentCandidateFixedSpend | AgentProfileImprovementUnavailableAccounting;
|
|
92
117
|
/** Verifiable output from one profile execution and its frozen evaluator. */
|
|
93
|
-
export interface AgentProfileImprovementRunReceipt {
|
|
118
|
+
export interface AgentProfileImprovementRunReceipt<TAccounting extends AgentProfileImprovementAccounting = AgentCandidateFixedSpend> {
|
|
94
119
|
kind: "agent-profile-improvement-run";
|
|
95
120
|
digestAlgorithm: AgentCandidateDigestAlgorithm;
|
|
96
121
|
executionId: string;
|
|
@@ -106,7 +131,7 @@ export interface AgentProfileImprovementRunReceipt {
|
|
|
106
131
|
steps: number;
|
|
107
132
|
resolvedModel: AgentCandidateResolvedModel;
|
|
108
133
|
limits: AgentCandidateExecutionLimits;
|
|
109
|
-
usage:
|
|
134
|
+
usage: TAccounting;
|
|
110
135
|
trace: {
|
|
111
136
|
evidence: AgentProfileImprovementEvidence;
|
|
112
137
|
eventCount: number;
|
|
@@ -128,7 +153,7 @@ export interface AgentProfileImprovementRunReceipt {
|
|
|
128
153
|
endedAtMs: number;
|
|
129
154
|
durationMs: number;
|
|
130
155
|
};
|
|
131
|
-
usage:
|
|
156
|
+
usage: TAccounting;
|
|
132
157
|
score: number;
|
|
133
158
|
passed: boolean;
|
|
134
159
|
dimensions: AgentCandidateBenchmarkDimension[];
|
|
@@ -136,10 +161,13 @@ export interface AgentProfileImprovementRunReceipt {
|
|
|
136
161
|
digest: Sha256Digest;
|
|
137
162
|
}
|
|
138
163
|
/** One paired result from the exact same task, seed, and evaluator. */
|
|
139
|
-
export interface AgentProfileImprovementMeasurement {
|
|
140
|
-
baseline: AgentProfileImprovementRunReceipt
|
|
141
|
-
candidate: AgentProfileImprovementRunReceipt
|
|
164
|
+
export interface AgentProfileImprovementMeasurement<TAccounting extends AgentProfileImprovementAccounting = AgentCandidateFixedSpend> {
|
|
165
|
+
baseline: AgentProfileImprovementRunReceipt<TAccounting>;
|
|
166
|
+
candidate: AgentProfileImprovementRunReceipt<TAccounting>;
|
|
142
167
|
}
|
|
168
|
+
/** Opt-in retained records can include accounting gaps; complete legacy types stay complete. */
|
|
169
|
+
export type AgentProfileImprovementRecordedRunReceipt = AgentProfileImprovementRunReceipt<AgentProfileImprovementAccounting>;
|
|
170
|
+
export type AgentProfileImprovementRecordedMeasurement = AgentProfileImprovementMeasurement<AgentProfileImprovementAccounting>;
|
|
143
171
|
/** Portable paired comparison from ordinary profile executions. */
|
|
144
172
|
export interface AgentProfileImprovementMeasuredComparison extends AgentImprovementMeasuredComparisonBase<AgentProfileImprovementExperiment, AgentProfileImprovementMeasurement, "agent-profile-improvement-measured-comparison"> {
|
|
145
173
|
kind: "agent-profile-improvement-measured-comparison";
|