runbios-sdk 0.2.17 → 0.2.18-dev.271

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.
@@ -1,39 +1,52 @@
1
1
  /**
2
- * The Conscious Loop -- capture what your model was asked and answered, record
3
- * whether it was right, and turn those judgements into training data.
2
+ * The Conscious Loop -- pipelines that keep improving a model from the
3
+ * conversations you send them.
4
4
  *
5
- * Nothing is captured until you turn it on for a source, and you can turn it
6
- * off again at any time. Anything that looks like a credential or a personal
7
- * detail is removed before the record is written, never afterwards.
5
+ * A pipeline is one use case: a model, the tags whose samples train it, when
6
+ * to train, and how a new version is promoted. Every time it trains it makes
7
+ * an attempt; an attempt that beats the live model becomes the next version.
8
+ *
9
+ * Nothing is captured until a source is switched on, and you can switch it
10
+ * off again at any time. Creating a pipeline switches on the source named by
11
+ * its own tag (`own_tag`), stamping that tag, and deleting it switches that
12
+ * source off again. Anything that looks like a credential or a personal detail
13
+ * is removed before the record is written, never afterwards.
8
14
  *
9
15
  * Requires an API key carrying `loop:read` and/or `loop:write`. Those scopes are
10
16
  * deliberately absent from the Read Only preset, because what they return is
11
17
  * your raw prompts and completions rather than catalog metadata.
12
18
  *
19
+ * Offered on the development environment only for now. Anywhere else every
20
+ * method here, reads included, rejects with a `ComingSoonError` whose
21
+ * `code` is `LOOP_COMING_SOON` (HTTP 403): a deliberate product state, not an
22
+ * outage, so retrying cannot succeed there.
23
+ *
13
24
  * @example
14
25
  * ```ts
15
- * // 1. Decide that this source is recorded.
16
- * await client.loop.setConfig('my-agent', { enabled: true, retention_days: 30 });
26
+ * // 1. A pipeline: a model it can train, and its own tag.
27
+ * const { models } = await client.loop.listModels();
28
+ * const { pipeline } = await client.loop.createPipeline({
29
+ * name: 'Support replies',
30
+ * model: { id: models[0].id },
31
+ * });
17
32
  *
18
- * // 2. Send what your model was asked and what it answered. Works whoever
19
- * // served it -- us, another provider, or your own servers.
20
- * const { trace_id } = await client.loop.capture({
21
- * deployment_id: 'my-agent',
33
+ * // 2. Send samples from your app to the pipeline's own source: its create
34
+ * // switched that source on, and it tags everything it records.
35
+ * const sent = await client.loop.capture({
36
+ * deployment_id: pipeline.own_tag!,
22
37
  * model: 'gpt-4o',
23
38
  * messages: [{ role: 'user', content: 'what is our refund window' }],
24
39
  * completion: 'thirty days',
25
40
  * });
26
41
  *
27
- * // 3. Say whether it was right. A rewrite is the most valuable answer here:
28
- * // the model learns your version AND learns to avoid its own.
29
- * await client.loop.signal(trace_id, {
30
- * verdict: 'edited',
31
- * correction: 'Thirty days from delivery, no questions asked.',
32
- * });
42
+ * // 3. Say whether it was right, on the trace_id the capture answered with.
43
+ * // A correction is the most valuable answer.
44
+ * if (sent.trace_id) {
45
+ * await client.loop.correct(sent.trace_id, 'Thirty days from delivery, no questions asked.');
46
+ * }
33
47
  *
34
- * // 4. Turn the judgements into a training set and take the file.
35
- * const ds = await client.loop.createDataset({ name: 'support', method: 'sft' });
36
- * const jsonl = await client.loop.downloadDataset(ds.id);
48
+ * // 4. Once it has its minimum, it trains; versions appear on the pipeline.
49
+ * const p = await client.loop.getPipeline(pipeline.rule_id);
37
50
  * ```
38
51
  */
39
52
  export class Loop {
@@ -53,11 +66,17 @@ export class Loop {
53
66
  *
54
67
  * The returned `trace_id` is OURS. If you pass your own `request_id` it is
55
68
  * kept as an idempotency handle: sending the same one again returns the same
56
- * trace rather than storing a second copy, so a retry is safe.
69
+ * trace rather than storing a second copy, so a retry is safe. Send feedback
70
+ * on that `trace_id`.
57
71
  *
58
- * When the source is not enabled this resolves with `captured: false` and a
59
- * reason instead of throwing -- capture must never be the thing that breaks
60
- * your application.
72
+ * `deployment_id` is the source. A pipeline's `own_tag` is a source its
73
+ * create switched on, and it stamps that tag on everything it records;
74
+ * `labels` add tags of your own, so the same conversation can feed other
75
+ * pipelines too.
76
+ *
77
+ * When the source is not switched on this resolves with `captured: false`
78
+ * and a reason instead of throwing -- capture must never be the thing that
79
+ * breaks your application.
61
80
  */
62
81
  async capture(params) {
63
82
  return this._http.fetchPost('/api/loop/traces', params);
@@ -65,9 +84,9 @@ export class Loop {
65
84
  /**
66
85
  * Bring data you already have into the loop.
67
86
  *
68
- * This does NOT create a training set. It creates conversations, in the same
69
- * place captured ones live and subject to the same review, rules, judges and
70
- * labels. A row becomes trainable when something says it is good, never
87
+ * This does NOT create a training set. It creates conversations (samples),
88
+ * in the same place captured ones live and subject to the same feedback and
89
+ * tags. A row becomes trainable when something says it is good, never
71
90
  * because it arrived in a file -- which is the one guarantee that separates
72
91
  * a corpus from a pile.
73
92
  *
@@ -150,6 +169,12 @@ export class Loop {
150
169
  q.set('origin', params.origin);
151
170
  if (params.unlabelled)
152
171
  q.set('unlabelled', 'true');
172
+ if (params.pipeline)
173
+ q.set('pipeline', params.pipeline);
174
+ if (params.signal)
175
+ q.set('signal', params.signal);
176
+ if (params.unsignalled)
177
+ q.set('unsignalled', 'true');
153
178
  if (params.limit != null)
154
179
  q.set('limit', String(params.limit));
155
180
  if (params.offset != null)
@@ -239,43 +264,17 @@ export class Loop {
239
264
  const res = await this._http.fetchGet(`/api/loop/traces/${encodeURIComponent(traceId)}/signals`);
240
265
  return res.signals;
241
266
  }
242
- // ── alternative answers ───────────────────────────────────────────────
243
267
  /**
244
- * Submit an alternative answer to a prompt already captured.
245
- *
246
- * This is what makes preference learning scale. A human rewrite is the best
247
- * signal there is and the least available -- somebody has to sit down and
248
- * write it. Sample the model several times for the same prompt, score the
249
- * samples, and a DPO pair falls out automatically: best becomes chosen,
250
- * worst becomes rejected. Point a stronger model at the prompt instead and
251
- * the same machinery does distillation.
252
- *
253
- * Score them, or they cannot pair: an unscored alternative says nothing about
254
- * which answer anybody prefers. `score_source` is required alongside a score,
255
- * because precedence between a verifier, a judge and a person is the whole
256
- * reason we record who judged.
257
- *
258
- * A human correction always outranks any score.
268
+ * The pipelines one conversation feeds: every live pipeline whose tags
269
+ * select it, and whether each is switched on.
259
270
  *
260
- * @example
261
- * ```ts
262
- * for (const sample of await sampleMyModel(prompt, 4)) {
263
- * await client.loop.addCandidate(traceId, {
264
- * completion: sample.text,
265
- * score: await myVerifier(sample.text),
266
- * score_source: 'verifier',
267
- * });
268
- * }
269
- * ```
271
+ * Being listed means the pipeline would select it, not that it will be
272
+ * trained on -- a set still drops answers it cannot use and duplicates, and
273
+ * holds some back to judge by; `note` says so. An empty list is a real
274
+ * answer: the conversation trains nothing until it carries a pipeline's tag.
270
275
  */
271
- async addCandidate(traceId, params) {
272
- const res = await this._http.fetchPost(`/api/loop/traces/${encodeURIComponent(traceId)}/candidates`, params);
273
- return res.candidate;
274
- }
275
- /** Every alternative answer recorded for one prompt, oldest first. */
276
- async listCandidates(traceId) {
277
- const res = await this._http.fetchGet(`/api/loop/traces/${encodeURIComponent(traceId)}/candidates`);
278
- return res.candidates;
276
+ async getTracePipelines(traceId) {
277
+ return this._http.fetchGet(`/api/loop/traces/${encodeURIComponent(traceId)}/pipelines`);
279
278
  }
280
279
  // ── labels ────────────────────────────────────────────────────────────
281
280
  /**
@@ -339,180 +338,6 @@ export class Loop {
339
338
  const res = await this._http.fetchGet('/api/loop/labels');
340
339
  return res.labels;
341
340
  }
342
- // ── training sets ─────────────────────────────────────────────────────
343
- /**
344
- * Build a training set from the feedback recorded so far.
345
- *
346
- * The three methods need genuinely different things, so one set cannot be
347
- * reshaped into another afterwards:
348
- *
349
- * - `sft` -- answers you marked right, and answers you rewrote.
350
- * - `dpo` -- answers you REWROTE, so a better and a worse version of the same
351
- * reply exist. Nothing else produces a pair.
352
- * - `grpo` -- answers with a value or fact they can be checked against, or
353
- * a judge rubric, which scores answers the run has not written yet.
354
- * - `kto` -- anything carrying a yes or a no, INCLUDING a thumbs-down with
355
- * nothing written. That row trains nothing under the other three methods,
356
- * which is why this one exists: it is the feedback people actually give.
357
- *
358
- * `holdout_percent` holds back your most recent work rather than a random
359
- * slice, so the evaluation measures whether the model generalised instead of
360
- * memorised the same week.
361
- *
362
- * The result always reports `rejected_counts`: why rows were left out. A
363
- * small set with a reason is useful; a small set without one is just alarming.
364
- */
365
- async createDataset(params) {
366
- const res = await this._http.fetchPost('/api/loop/datasets', params);
367
- return res.dataset;
368
- }
369
- /** List training sets, newest first. */
370
- // ── build rules ───────────────────────────────────────────────────────
371
- /**
372
- * Stand up a rule that builds a set whenever enough new work exists.
373
- *
374
- * The manual path asks somebody to notice that enough conversations have
375
- * been reviewed, remember which filters describe the slice they want, and
376
- * press build — every time. A rule is that instruction, stored.
377
- *
378
- * `spec` is the same selection `createDataset` takes and is replayed
379
- * verbatim, so an automatic set is identical to a hand-made one.
380
- *
381
- * `min_new_rows` counts only work reviewed SINCE THE LAST BUILD. Counting
382
- * the whole corpus would fire the rule every interval forever, because a
383
- * total that has crossed a threshold stays across it. It is at least 100,
384
- * and 100 when absent: a set built from fewer is too small to learn from.
385
- */
386
- async createBuildRule(params) {
387
- const res = await this._http.fetchPost('/api/loop/build-rules', params);
388
- return res.rule;
389
- }
390
- /**
391
- * Every build rule, with what each one last did and why.
392
- *
393
- * `last_reason` is the field worth reading: a rule quiet because it is
394
- * waiting looks exactly like one quiet because it is broken.
395
- */
396
- async listBuildRules() {
397
- const res = await this._http.fetchGet('/api/loop/build-rules');
398
- return res.rules ?? [];
399
- }
400
- /** Stop a standing build rule. Sets it already produced are untouched. */
401
- async deleteBuildRule(id) {
402
- return this._http.fetchDelete(`/api/loop/build-rules/${encodeURIComponent(id)}`);
403
- }
404
- async listDatasets(params = {}) {
405
- const q = new URLSearchParams();
406
- if (params.method)
407
- q.set('method', params.method);
408
- if (params.limit != null)
409
- q.set('limit', String(params.limit));
410
- if (params.offset != null)
411
- q.set('offset', String(params.offset));
412
- const qs = q.toString();
413
- const res = await this._http.fetchGet(`/api/loop/datasets${qs ? `?${qs}` : ''}`);
414
- return res.datasets;
415
- }
416
- /** Read one training set and its curation report. */
417
- async getDataset(id) {
418
- const res = await this._http.fetchGet(`/api/loop/datasets/${encodeURIComponent(id)}`);
419
- return res.dataset;
420
- }
421
- /**
422
- * Page through the rows a training set actually contains.
423
- *
424
- * Worth reading before you spend money on a run: each row carries the address
425
- * of the conversation it was built from.
426
- */
427
- async listDatasetItems(id, params = {}) {
428
- const q = new URLSearchParams();
429
- if (params.limit != null)
430
- q.set('limit', String(params.limit));
431
- if (params.offset != null)
432
- q.set('offset', String(params.offset));
433
- const qs = q.toString();
434
- const res = await this._http.fetchGet(`/api/loop/datasets/${encodeURIComponent(id)}/items${qs ? `?${qs}` : ''}`);
435
- return res.items;
436
- }
437
- /**
438
- * Download a training set as JSONL -- one training row per line, the format
439
- * every trainer in this space reads.
440
- *
441
- * `split` defaults to the training rows; pass `holdout` for the slice held
442
- * back, or `all` for both.
443
- */
444
- async downloadDataset(id, split) {
445
- const qs = split ? `?split=${split}` : '';
446
- return this._http.fetchGet(`/api/loop/datasets/${encodeURIComponent(id)}/download${qs}`);
447
- }
448
- /**
449
- * Delete a training set.
450
- *
451
- * The conversations it was built from are untouched -- a set is a selection,
452
- * and discarding the selection must not discard the evidence. A set a
453
- * training run was trained on is refused `409 DATASET_IN_USE` and kept, as
454
- * the record of what that run learned from. See
455
- * `LoopDatasetDeleteRefusalCode`.
456
- */
457
- async deleteDataset(id) {
458
- return this._http.fetchDelete(`/api/loop/datasets/${encodeURIComponent(id)}`);
459
- }
460
- // ── graders ───────────────────────────────────────────────────────────
461
- /**
462
- * Write a rule that scores answers without a person.
463
- *
464
- * Human review is the most trustworthy feedback and the least available. A
465
- * grader is written once and applied to every answer afterwards: did it
466
- * contain the required phrase, did it parse as the schema you asked for, is
467
- * the number within tolerance of the known answer, did it call the function
468
- * it should have.
469
- *
470
- * Every kind here is DETERMINISTIC -- no model call, no network. That is why
471
- * a verifier outranks a judge when they disagree: it cannot be flattered and
472
- * it cannot drift between runs.
473
- *
474
- * `weight` is the multiplier: a criterion that matters twice as much gets
475
- * twice the weight, and the combined score is the weighted mean over the
476
- * rules that actually applied.
477
- *
478
- * `matches_gold` needs no `expected`: it compares each answer to the gold
479
- * answer recorded on that same conversation, or the human correction when
480
- * there is no gold, and scores sampled alternatives against the same gold.
481
- * A conversation with neither is skipped, not failed, so one rule checks
482
- * every labelled question without punishing the unlabelled ones. An
483
- * optional `tolerance` widens the match when both sides are bare numbers.
484
- *
485
- * A caution worth knowing before you write a set: a rule made only of
486
- * `forbidden` phrases is satisfied VACUOUSLY by an answer that says nothing.
487
- * Pair it with a `required` phrase, or you are rewarding silence.
488
- */
489
- async createGrader(params) {
490
- const res = await this._http.fetchPost('/api/loop/graders', params);
491
- return res.grader;
492
- }
493
- /** Every rule this workspace has written. */
494
- async listGraders() {
495
- const res = await this._http.fetchGet('/api/loop/graders');
496
- return res.graders;
497
- }
498
- async deleteGrader(id) {
499
- return this._http.fetchDelete(`/api/loop/graders/${encodeURIComponent(id)}`);
500
- }
501
- /**
502
- * Apply this workspace's rules to one captured answer AND to every
503
- * alternative sampled for it.
504
- *
505
- * Grading both in one pass is the point: scoring only the original gives a
506
- * verdict, while scoring the samples as well gives the preference pair. Sample
507
- * your model, call this, and you have DPO data with nobody reading anything.
508
- *
509
- * A run where no rule could apply writes NOTHING -- no verdict, no scores.
510
- * Recording a zero that no rule produced would poison curation with a
511
- * judgement nobody reached, so `applied: 0` is reported instead.
512
- */
513
- async grade(traceId) {
514
- return this._http.fetchPost(`/api/loop/traces/${encodeURIComponent(traceId)}/grade`);
515
- }
516
341
  // ── capture settings ──────────────────────────────────────────────────
517
342
  /** Every source this workspace has configured. */
518
343
  async listConfigs() {
@@ -542,425 +367,40 @@ export class Loop {
542
367
  return res.config;
543
368
  }
544
369
  /**
545
- * How much there is, and how much of it each method could actually use.
370
+ * How much there is, and how many samples a pipeline could train on now
371
+ * (`ready.sft`: the ones marked good or corrected).
546
372
  *
547
- * The `ready` numbers are upper bounds: duplicate questions are folded into
548
- * one row while a set is built, so the finished count can be lower.
373
+ * `ready.sft` is an upper bound: duplicates, the held-back set and
374
+ * conversations too long to train on come out of it when an attempt trains.
549
375
  */
550
376
  async stats() {
551
377
  const res = await this._http.fetchGet('/api/loop/stats');
552
378
  return res.stats;
553
379
  }
554
- // ── judges ────────────────────────────────────────────────────────────
555
- //
556
- // A grader is a rule: deterministic, cheap, and blind to anything it was not
557
- // told to look for. A judge is a rubric handed to a model, which is the only
558
- // thing that can answer "was this answer actually helpful".
559
- //
560
- // YOU run the model. This service stores raw prompts and completions and
561
- // holds them with no outbound credentials at all, which is most of the reason
562
- // it is safe to store them there -- so it hands the work out instead. Open a
563
- // run, take the batch, send each `prompt` to whatever model you like, and
564
- // post the scores back.
565
- /** Write a rubric: what makes an answer good here, and what to score. */
566
- async createJudge(params) {
567
- const res = await this._http.fetchPost('/api/loop/judges', params);
568
- return res.judge;
569
- }
570
- async listJudges() {
571
- const res = await this._http.fetchGet('/api/loop/judges');
572
- return res.judges;
573
- }
574
380
  /**
575
- * Rewrite a rubric. Runs already recorded keep the instructions they used:
576
- * a verdict has to keep meaning what it meant when it was given.
381
+ * How the loop moved over time: every attempt as a point, oldest first --
382
+ * its attempt number, the version it became (null when it did not), its
383
+ * base model, its win rate, what it cost -- and each day's feedback counted
384
+ * by verdict. `rule_id` narrows the attempts to one pipeline; the feedback
385
+ * counts are the workspace's. `truncated` says older attempts exist beyond
386
+ * `limit`.
577
387
  */
578
- async updateJudge(judgeId, params) {
579
- const res = await this._http.fetchPut(`/api/loop/judges/${encodeURIComponent(judgeId)}`, params);
580
- return res.judge;
581
- }
582
- /**
583
- * Retire a rubric. Its runs go with it; the verdicts they wrote stay. A score
584
- * is evidence about an answer, and it does not stop being true because the
585
- * rubric was retired.
586
- */
587
- async deleteJudge(judgeId) {
588
- await this._http.fetchDelete(`/api/loop/judges/${encodeURIComponent(judgeId)}`);
589
- }
590
- /**
591
- * Open a run: select the conversations now, and freeze the rubric onto them.
592
- *
593
- * The selection is fixed at this moment on purpose. A run whose selection is
594
- * a live query silently grows as conversations arrive, so "we scored the
595
- * refunds slice" becomes a claim about a set that no longer exists.
596
- */
597
- async startRun(judgeId, limit) {
598
- const res = await this._http.fetchPost(`/api/loop/judges/${encodeURIComponent(judgeId)}/runs`, limit ? { limit } : {});
599
- return res.run;
600
- }
601
- async listRuns(judgeId) {
602
- const path = judgeId
603
- ? `/api/loop/judges/${encodeURIComponent(judgeId)}/runs`
604
- : '/api/loop/runs';
605
- const res = await this._http.fetchGet(path);
606
- return res.runs;
607
- }
608
- async getRun(runId) {
609
- const res = await this._http.fetchGet(`/api/loop/runs/${encodeURIComponent(runId)}`);
610
- return res.run;
611
- }
612
- /**
613
- * Take the next conversations to score, each rendered into a ready-to-send
614
- * prompt. Nothing is marked taken, so a caller that dies half way loses
615
- * nothing: ask again and the same items come back.
616
- */
617
- async takeWork(runId, limit = 20) {
618
- return this._http.fetchGet(`/api/loop/runs/${encodeURIComponent(runId)}/work?limit=${limit}`);
619
- }
620
- /**
621
- * What happened to each conversation in a run, and why.
622
- *
623
- * `takeWork` hands out what is still PENDING, so a finished run answers it
624
- * with an empty list. This answers with every item and the outcome on it:
625
- * `status`, `scored_at`, and `error` — the reason the caller gave for an
626
- * item it could not score, which is where a wrong model slug or a refused
627
- * key actually shows up. A run that ends "scored 0, failed 3" is otherwise a
628
- * number with no detail behind it.
629
- *
630
- * Pass `status: 'failed'` for the usual question. At most 500 items come
631
- * back at a time; when `has_more` is true, call again with the `next_offset`
632
- * from the reply.
633
- */
634
- async listRunItems(runId, opts = {}) {
635
- const qs = new URLSearchParams();
636
- if (opts.status)
637
- qs.set('status', opts.status);
638
- if (opts.limit != null)
639
- qs.set('limit', String(opts.limit));
640
- if (opts.offset)
641
- qs.set('offset', String(opts.offset));
642
- const suffix = qs.toString() ? `?${qs.toString()}` : '';
643
- return this._http.fetchGet(`/api/loop/runs/${encodeURIComponent(runId)}/items${suffix}`);
644
- }
645
- /**
646
- * Hand the scores back. A verdict for a conversation outside this run, or
647
- * scoring something the rubric never asked for, is refused and reported in
648
- * `rejected` rather than silently dropped.
649
- *
650
- * Pass `finish` to close the run in the same call once you have nothing left
651
- * to send. To close a run WITHOUT scores, call `stopRun`: an empty verdict
652
- * list with `finish` does the same thing and reads like a mistake.
653
- */
654
- async postVerdicts(runId, verdicts, finish = false) {
655
- return this._http.fetchPost(`/api/loop/runs/${encodeURIComponent(runId)}/verdicts`, { verdicts, finish });
656
- }
657
- /**
658
- * Close a run that has not finished.
659
- *
660
- * A judge may have one open run of its own at a time, so an open run BLOCKS
661
- * the next one, and the runs that most need closing are the ones nobody can
662
- * wait out: a run the agent has parked on an empty balance or a refused key
663
- * stays open until the reason is fixed or somebody stops it.
664
- *
665
- * Nothing is deleted. Every verdict already recorded stays recorded, the
666
- * counters keep saying how much of the selection was covered, and the
667
- * conversations the run was holding are free for the next one. The run ends
668
- * as `stopped` rather than `done`, so an interrupted pass and a completed
669
- * one do not read alike.
670
- *
671
- * A run that finished on its own is not rewritten: stopping one answers 409.
672
- *
673
- * Returns the stopped run itself, like `startRun` and `getRun`, not the
674
- * `{run}` envelope the service sends. Every other single-run method in this
675
- * class unwraps, and `Loop.stop_run` in the Python SDK does too, so a
676
- * caller who wrote `(await loop.stopRun(id)).status` against one of its
677
- * siblings is right here as well.
678
- */
679
- async stopRun(runId) {
680
- const res = await this._http.fetchPost(`/api/loop/runs/${encodeURIComponent(runId)}/stop`, {});
681
- return res.run;
682
- }
683
- // ── the agent ─────────────────────────────────────────────────────────
684
- //
685
- // The worker that calls a model on the workspace's behalf: it applies
686
- // automatic judges and writes sample answers. It spends through a managed
687
- // serverless key OF THIS WORKSPACE, so every call is billed exactly like
688
- // one of your own, and turning it off revokes that key.
689
- /**
690
- * Can an agent run here, is one running, and is it on for this workspace.
691
- * `available` is about the environment; `online` about the worker;
692
- * `credential` about this workspace.
693
- */
694
- async agentStatus() {
695
- return this._http.fetchGet('/api/loop/agent');
696
- }
697
- /**
698
- * Turn the agent on: mints the workspace's managed serverless key and
699
- * resumes the automatic judges a previous turn-off paused. After this,
700
- * automatic judges and sample runs make model calls billed to the
701
- * workspace. Idempotent.
702
- *
703
- * A judge whose model the serving gateway will not route is NOT resumed:
704
- * making it automatic would buy a run that fails every conversation. It
705
- * stays paused, `judges_still_paused` counts those, and each one carries
706
- * `auto_pause_reason` saying so. Point it at a model that is served and
707
- * turn the agent on again.
708
- *
709
- * `monthly_spend_cap_cents` caps what that key may spend on model calls in
710
- * a calendar month. Omitted = no cap on a fresh key, and an existing cap is
711
- * left as it is; sent while the agent is already on, it moves the cap on
712
- * the existing key without minting a new one. When the cap is reached the
713
- * agent's model calls are refused until next month and its runs pause with
714
- * that reason.
715
- */
716
- async enableAgent(opts = {}) {
717
- const body = {};
718
- if (opts.monthly_spend_cap_cents != null)
719
- body.monthly_spend_cap_cents = opts.monthly_spend_cap_cents;
720
- const res = await this._http.fetchPost('/api/loop/agent', body);
721
- return res.credential;
722
- }
723
- /**
724
- * Turn the agent off: revokes its key and pauses every automatic judge in
725
- * the workspace (`judges_paused`; each judge shows `auto_paused`). Turning
726
- * it back on resumes exactly those judges. Open runs stop where they are
727
- * and continue if it is turned back on. Nothing already scored or written
728
- * is removed.
729
- */
730
- async disableAgent() {
731
- return this._http.fetchDelete('/api/loop/agent');
732
- }
733
- /**
734
- * Ask the agent to write `n` alternative answers to each conversation in a
735
- * slice with `model`, score each with `judge_id`, and store them as
736
- * candidates. This is how preference pairs are made without a person
737
- * writing each one: the curation pass pairs the best sample against the
738
- * worst wherever the gap is real.
739
- *
740
- * Cost: up to `n` calls to write plus `n` to judge, per conversation, at the
741
- * workspace's serverless rate; `selection.sample` caps the conversations
742
- * (max 200) and `n` is capped at 8. Opening a run turns the agent on if it
743
- * is off.
744
- */
745
- async createSampleRun(params) {
746
- const res = await this._http.fetchPost('/api/loop/sample-runs', params);
747
- return res.run;
748
- }
749
- async listSampleRuns() {
750
- const res = await this._http.fetchGet('/api/loop/sample-runs');
751
- return res.runs;
752
- }
753
- async getSampleRun(runId) {
754
- const res = await this._http.fetchGet(`/api/loop/sample-runs/${encodeURIComponent(runId)}`);
755
- return res.run;
756
- }
757
- // ── automatic training ────────────────────────────────────────────────
758
- //
759
- // A training rule is a STANDING INSTRUCTION, not a job. Once it is accepted
760
- // the platform builds a set, trains a model, books a candidate, compares it
761
- // against what serves your traffic today and -- if you asked for that --
762
- // re-points the alias at the winner, on its own schedule, with nobody
763
- // watching. Every one of those steps spends money from the authorising
764
- // member's wallet.
765
- //
766
- // So the order is always the same: preflight for the estimate and the exact
767
- // words of the terms, show them to the person whose wallet pays, and only
768
- // then create with `accept_terms` carrying the `terms_version` they read.
769
- // Money-bearing edits bump `revision`, clear the consent and stop the rule
770
- // firing until someone accepts the new amounts.
771
- //
772
- // Requires `loop:write` for every mutation, including `preflightTrainingRule`:
773
- // it is the estimate step of a create, and a key that may not create a rule
774
- // has no reason to price one.
775
- /**
776
- * Price a training rule before anyone agrees to it. Writes nothing.
777
- *
778
- * Takes the create body without `accept_terms` and answers with the estimate
779
- * a member has to see first: the pinned model revision, the worst hourly
780
- * price each GPU ladder can reach, how many hours each ceiling buys, any
781
- * refusals that would stop a create, the API keys that cannot follow a
782
- * cutover because they lack `deployments:read`, and `terms_text` -- the
783
- * exact sentence to show, with real figures in it.
784
- *
785
- * Send the `terms_version` it returns back in `createTrainingRule`. Read the
786
- * figures out of this response rather than inventing ceilings of your own.
787
- *
788
- * `valid: false` with an EMPTY `refusals` list is not nothing: check
789
- * `unreachable`, which names every peer the platform could not reach. The
790
- * rule is savable in that state and would be paused, but the estimate around
791
- * it is not trustworthy -- both `worst_hourly_*` are `0`, and so are both
792
- * `max_*_hours` beside them -- so do not quote those figures to anyone.
793
- * `model_revision` is empty unless training-service actually pinned a
794
- * commit; test `unreachable.length > 0` to tell a degraded pass from a
795
- * refusal.
796
- *
797
- * A `TRAINING_NOT_ENABLED` refusal is neither: training is in beta and this
798
- * organisation does not hold the grant. It is in `refusals`, never in
799
- * `unreachable`, and nothing in the request can lift it.
800
- */
801
- async preflightTrainingRule(params) {
802
- return this._http.fetchPost('/api/loop/training-rules/preflight', params);
803
- }
804
- /**
805
- * Create a training rule and record the consent that pays for it.
806
- *
807
- * ACCEPTING THE TERMS AUTHORISES SPENDING FROM YOUR WALLET WHILE YOU ARE NOT
808
- * PRESENT. From here on the platform may, on its own schedule and without
809
- * asking again, build a training set, run a training job on rented GPUs,
810
- * book a second deployment to compare against the one serving your traffic,
811
- * and pay for the model calls that judge the two. Those charges come out of
812
- * the wallet of the member whose credentials make this call, up to the
813
- * ceilings in `money`, and they keep recurring for as long as the rule is
814
- * enabled. If `promotion.auto_promote` is set, the platform will also
815
- * re-point your public handle at the new model with nobody reviewing it.
816
- *
817
- * `accept_terms` is therefore required, and this method refuses to send the
818
- * request without it rather than letting the server decide. Call
819
- * {@link preflightTrainingRule} first, show the person whose wallet pays the
820
- * `terms_text` and the figures it returns, get an explicit yes, and send the
821
- * `terms_version` they were shown. Do not invent ceilings or price caps on
822
- * their behalf.
823
- *
824
- * Refused `409 TRAINING_NOT_ENABLED`, with nothing saved, while training is
825
- * in beta and this organisation does not hold the grant: do not retry, ask
826
- * the platform team to enable it. See `TrainingRuleSaveRefusalCode`.
827
- *
828
- * @example
829
- * ```ts
830
- * const estimate = await client.loop.preflightTrainingRule(draft);
831
- * // show estimate.terms_text and the ceilings to the member, get a yes
832
- * const rule = await client.loop.createTrainingRule({
833
- * ...draft,
834
- * accept_terms: { terms_version: estimate.terms_version },
835
- * });
836
- * ```
837
- */
838
- async createTrainingRule(params) {
839
- // Refused here rather than on the wire: a create without a recorded
840
- // acceptance is a request to spend somebody's money with no record that
841
- // they agreed, and the SDK should never be the thing that sends it.
842
- if (!params.accept_terms || !params.accept_terms.terms_version) {
843
- throw new Error('RunBiOS: createTrainingRule requires accept_terms.terms_version. '
844
- + 'Call preflightTrainingRule, show the member terms_text and the ceilings, '
845
- + 'and send back the terms_version they accepted -- this rule spends from their wallet.');
846
- }
847
- const res = await this._http.fetchPost('/api/loop/training-rules', params);
848
- return res.rule;
849
- }
850
- /**
851
- * Every training rule in the workspace, with what each one last did and why.
852
- *
853
- * `last_reason` and `paused_reason` are the fields worth reading: a rule
854
- * quiet because it is waiting looks exactly like one quiet because its
855
- * consent went stale.
856
- */
857
- async listTrainingRules(params = {}) {
388
+ async getMetricsHistory(params = {}) {
858
389
  const q = new URLSearchParams();
859
- if (params.enabled != null)
860
- q.set('enabled', String(params.enabled));
390
+ if (params.rule_id)
391
+ q.set('rule_id', params.rule_id);
861
392
  if (params.limit != null)
862
393
  q.set('limit', String(params.limit));
863
- if (params.offset != null)
864
- q.set('offset', String(params.offset));
394
+ if (params.days != null)
395
+ q.set('days', String(params.days));
865
396
  const qs = q.toString();
866
- return this._http.fetchGet(`/api/loop/training-rules${qs ? `?${qs}` : ''}`);
867
- }
868
- /**
869
- * Read one rule with its recent runs, what its runs this month have cost at
870
- * most, and how far its judge agrees with your own reviewers.
871
- *
872
- * Returned whole rather than unwrapped to the rule: `month_spent_cents` is
873
- * the number that says whether the monthly ceiling is about to stop it. It
874
- * is an upper bound, not an exact spend: see `Pipeline.month_spent_cents`.
875
- */
876
- async getTrainingRule(id) {
877
- return this._http.fetchGet(`/api/loop/training-rules/${encodeURIComponent(id)}`);
878
- }
879
- /**
880
- * Edit or pause a rule. Absent means unchanged; a null clears the fields
881
- * that can be cleared.
882
- *
883
- * A money-bearing change -- a ceiling, a model, a GPU ladder, the promotion
884
- * policy, or changing `explore_recipes` in EITHER direction -- bumps
885
- * `revision`, clears the recorded consent and STOPS the rule firing until
886
- * someone accepts the new amounts. Turning recipe variants OFF does this
887
- * too: the pipeline then makes no version at all, variant or not, until the
888
- * terms are accepted again. The reply says so in
889
- * `consent_required`, and carries a fresh `preflight` with the new figures.
890
- * Pass `expected_revision` to be refused with `REVISION_MISMATCH` rather
891
- * than overwrite an edit somebody else made in the meantime.
892
- *
893
- * Switching a rule on, switching it into preference training or carrying
894
- * `accept_terms` re-runs the preflight, and can be refused
895
- * `409 TRAINING_NOT_ENABLED` like a create. A rule paused
896
- * `training_not_enabled` is started again by a save of it once the
897
- * organisation has been enabled.
898
- */
899
- async updateTrainingRule(id, params) {
900
- return this._http.fetchPut(`/api/loop/training-rules/${encodeURIComponent(id)}`, params);
901
- }
902
- /**
903
- * Accept the rule's current terms, so it may fire again.
904
- *
905
- * ACCEPTING THE TERMS AUTHORISES SPENDING FROM YOUR WALLET WHILE YOU ARE NOT
906
- * PRESENT, on the amounts as they stand right now. This is the same
907
- * authorisation {@link createTrainingRule} records, given again because a
908
- * money-bearing edit cleared the old one: training, a candidate deployment
909
- * and the judge's model calls are charged to the wallet of the member making
910
- * this call, up to the rule's ceilings, every time it fires.
911
- *
912
- * Show the member the current `terms_text` from a fresh
913
- * {@link preflightTrainingRule} or from the `preflight` on the update reply,
914
- * and send the `revision` those figures belong to. A stale revision is
915
- * refused with `409`, which is the point: it means the amounts moved again
916
- * after they were read. `409 TRAINING_NOT_ENABLED` means training is in beta
917
- * and this organisation does not hold the grant.
918
- */
919
- async consentTrainingRule(id, params) {
920
- const res = await this._http.fetchPost(`/api/loop/training-rules/${encodeURIComponent(id)}/consent`, params);
921
- return res.rule;
922
- }
923
- /**
924
- * Fire a rule now, without waiting for its cadence.
925
- *
926
- * Bypasses the schedule and `min_new_rows` only. The row floors, the money
927
- * ceilings, the consent, the version limit and the monthly limit all still
928
- * apply, so this can answer `409 CONSENT_REQUIRED`, `409 RULE_PAUSED`,
929
- * `409 RUN_ACTIVE`, `409 VERSION_LIMIT_REACHED` (the pipeline has made
930
- * `max_versions` versions), `409 MONTHLY_LIMIT_REACHED` (the most this
931
- * month's runs can have cost plus the most one run may cost would pass the
932
- * monthly limit; the error
933
- * body carries `month_spent_cents`, `monthly_ceiling_cents`, `run_max_cents`
934
- * and `resumes_at`), `409 AGENT_OFF` (the workspace's Conscious Loop agent
935
- * is not turned on, so a trained model could not be compared) or
936
- * `422 NOT_ENOUGH_ROWS` with the counts it needed. See
937
- * `TrainingRuleRunRefusalCode`.
938
- */
939
- async runTrainingRule(id) {
940
- const res = await this._http.fetchPost(`/api/loop/training-rules/${encodeURIComponent(id)}/run`, {});
941
- return res.run;
942
- }
943
- /**
944
- * Delete a rule. An active run is cancelled; runs that already finished, and
945
- * anything already promoted, are kept.
946
- */
947
- async deleteTrainingRule(id) {
948
- return this._http.fetchDelete(`/api/loop/training-rules/${encodeURIComponent(id)}`);
397
+ return this._http.fetchGet(`/api/loop/metrics/history${qs ? `?${qs}` : ''}`);
949
398
  }
950
- /**
951
- * Edit or pause a build rule -- the standing instruction that assembles the
952
- * training set a training rule then trains on.
953
- *
954
- * Changing `spec.deployment_id` while an enabled training rule owns this
955
- * build rule is refused with `409`: it would silently retrain the next model
956
- * on a different source's conversations.
957
- */
958
- async updateBuildRule(id, params) {
959
- const res = await this._http.fetchPut(`/api/loop/build-rules/${encodeURIComponent(id)}`, params);
960
- return res.rule;
961
- }
962
- // ── training runs ─────────────────────────────────────────────────────
963
- /** Firings, newest first. Filter by rule or by the state they are sitting in. */
399
+ // ── attempts ──────────────────────────────────────────────────────────
400
+ //
401
+ // Every time a pipeline trains it makes an attempt (a training run). The
402
+ // attempts that beat the live model became its versions.
403
+ /** Attempts, newest first. Filter by pipeline (`rule_id`) or by the state they are sitting in. */
964
404
  async listTrainingRuns(params = {}) {
965
405
  const q = new URLSearchParams();
966
406
  if (params.rule_id)
@@ -1022,23 +462,22 @@ export class Loop {
1022
462
  }
1023
463
  // ── pipelines ─────────────────────────────────────────────────────────
1024
464
  /**
1025
- * Every training rule in the workspace, seen as the series of versions it
1026
- * produced: which exist, which one serves (`champion_version`), how each did
1027
- * against the champion of its day and on the standing benchmark, the run in
1028
- * flight and which version it will be, and what the pipeline is waiting for.
1029
- *
1030
- * Read-only. Every decision stays on the route that owns it -- promote,
1031
- * reject and roll back on the run, the version limit and `explore_recipes`
1032
- * on the rule.
465
+ * Every pipeline in the workspace: its versions (the attempts that became
466
+ * the live model), every attempt, which version is live, the attempt in
467
+ * flight, and what the pipeline is waiting for.
1033
468
  *
1034
469
  * RETURNED WITH ITS ENVELOPE, because the list is not always all of them:
1035
- * the service returns the newest 100, `total` is every pipeline in the
1036
- * workspace and `truncated` is true when more exist than were returned. A
1037
- * caller that shows `pipelines` alone presents a short list as the whole of
1038
- * it. The rest are reached through `listTrainingRules`, which pages.
470
+ * the service returns a page of 100, newest first, `total` is every
471
+ * pipeline in the workspace and `truncated` is true when more exist after
472
+ * this page. A caller that shows `pipelines` alone presents a short list as
473
+ * the whole of it; the next page is `{ offset: offset + pipelines.length }`.
1039
474
  */
1040
- async listPipelines() {
1041
- const res = await this._http.fetchGet('/api/loop/pipelines');
475
+ async listPipelines(params = {}) {
476
+ const q = new URLSearchParams();
477
+ if (params.offset)
478
+ q.set('offset', String(params.offset));
479
+ const qs = q.toString();
480
+ const res = await this._http.fetchGet(`/api/loop/pipelines${qs ? `?${qs}` : ''}`);
1042
481
  const pipelines = res.pipelines || [];
1043
482
  return {
1044
483
  pipelines,
@@ -1048,7 +487,7 @@ export class Loop {
1048
487
  };
1049
488
  }
1050
489
  /**
1051
- * One pipeline, by its training rule's id.
490
+ * One pipeline, by its id.
1052
491
  *
1053
492
  * `status` says whether it is the platform working (`running`), the member
1054
493
  * who has to act (`needs_review`, `needs_funds`), or nothing at all until
@@ -1061,10 +500,108 @@ export class Loop {
1061
500
  const res = await this._http.fetchGet(`/api/loop/pipelines/${encodeURIComponent(id)}`);
1062
501
  return res.pipeline;
1063
502
  }
503
+ // ── creating and changing pipelines ───────────────────────────────────
504
+ //
505
+ // One body -- a name, a model, tags, when to train, how to promote -- and
506
+ // the platform decides the rest: the machines and the limits on each
507
+ // attempt. Saving a pipeline IS the authorization to spend; you pay the GPU
508
+ // time its attempts actually use.
509
+ /**
510
+ * The base models a pipeline can train: only those the engine trains with
511
+ * LoRA SFT and the platform can serve for the comparison, recommended first.
512
+ * The one list {@link createPipeline} accepts a `model.id` from, with the
513
+ * `floors` a new pipeline is held to: the samples its first attempt needs and
514
+ * the smallest `train_when.min_samples`.
515
+ */
516
+ async listModels() {
517
+ const res = await this._http.fetchGet('/api/loop/models');
518
+ return { ...res, models: res.models || [] };
519
+ }
520
+ /**
521
+ * Create a pipeline -- one use case.
522
+ *
523
+ * SAVING IT AUTHORISES SPENDING FROM YOUR WALLET WHILE YOU ARE NOT PRESENT:
524
+ * whenever its data has grown enough (and at its schedule, when it has one),
525
+ * the platform trains a new version on GPUs it chooses, compares it with what
526
+ * serves your traffic, and promotes it by the pipeline's promotion policy.
527
+ * What is charged is the GPU time the runs actually use; the platform's own
528
+ * per-run and monthly limits stop a run that goes wrong.
529
+ */
530
+ async createPipeline(params) {
531
+ return this._http.fetchPost('/api/loop/pipelines', params);
532
+ }
533
+ /**
534
+ * Edit a pipeline. Only the fields sent change; `max_versions: null` removes
535
+ * the limit and `challenger_model: null` removes the challenger. `promotion`
536
+ * is how the promotion policy is set. Saving is the authorization, as on a
537
+ * create.
538
+ */
539
+ async updatePipeline(id, params) {
540
+ return this._http.fetchPut(`/api/loop/pipelines/${encodeURIComponent(id)}`, params);
541
+ }
542
+ /**
543
+ * Delete a pipeline: an attempt still running is cancelled; the versions it
544
+ * made, what serves your app, and its samples and tags are kept. Recording
545
+ * to its own tag stops.
546
+ */
547
+ async deletePipeline(id) {
548
+ return this._http.fetchDelete(`/api/loop/pipelines/${encodeURIComponent(id)}`);
549
+ }
550
+ /**
551
+ * Train now: skips the schedule, never the minimum. A pipeline short of its
552
+ * samples is refused 422 `NOT_ENOUGH_SAMPLES` with `have` and `need` -- the
553
+ * numbers `minimums` shows. 503 `AGENT_COULD_NOT_START` means the key the
554
+ * attempt would be scored with could not be renewed just then: nothing was
555
+ * started, so press train now again in a minute. Every refusal is a
556
+ * `TrainingRuleRunRefusalCode`.
557
+ */
558
+ async runPipeline(id) {
559
+ return this._http.fetchPost(`/api/loop/pipelines/${encodeURIComponent(id)}/run`, {});
560
+ }
561
+ /**
562
+ * {@link importRows}, with every row given the pipeline's own tag. `source`
563
+ * defaults to that tag; the rows, the answer and the retry rules are the
564
+ * import door's own. `default_feedback: 'good'` records every answered row
565
+ * that brought no verdict of its own as a good example to learn from.
566
+ */
567
+ async importIntoPipeline(id, params) {
568
+ return this._http.fetchPost(`/api/loop/pipelines/${encodeURIComponent(id)}/import`, params);
569
+ }
570
+ // ── a pipeline's benchmarks, and its versions side by side ─────────────
571
+ /** The pipeline's benchmarks in priority order (1 is the primary), the ones it stopped using, and its promotion policy. */
572
+ async listPipelineBenchmarks(id) {
573
+ return this._http.fetchGet(`/api/loop/pipelines/${encodeURIComponent(id)}/benchmarks`);
574
+ }
575
+ /** Add a benchmark to a pipeline, last unless `priority` says where. Every version from now on is replayed on it. */
576
+ async attachPipelineBenchmark(id, params) {
577
+ return this._http.fetchPost(`/api/loop/pipelines/${encodeURIComponent(id)}/benchmarks`, params);
578
+ }
579
+ /** Move a benchmark on a pipeline's list; priority 1 makes it the primary. */
580
+ async movePipelineBenchmark(id, benchmarkId, params) {
581
+ return this._http.fetchPut(`/api/loop/pipelines/${encodeURIComponent(id)}/benchmarks/${encodeURIComponent(benchmarkId)}`, params);
582
+ }
583
+ /** Stop using a benchmark. Every score it produced is kept. */
584
+ async removePipelineBenchmark(id, benchmarkId) {
585
+ return this._http.fetchDelete(`/api/loop/pipelines/${encodeURIComponent(id)}/benchmarks/${encodeURIComponent(benchmarkId)}`);
586
+ }
587
+ /**
588
+ * Every version's scores side by side: its head-to-head and every benchmark,
589
+ * `not_measured` where a benchmark was added after it. `a` and `b` are
590
+ * VERSION numbers; with both, `differences` says b minus a per benchmark.
591
+ */
592
+ async compareVersions(id, params = {}) {
593
+ const q = new URLSearchParams();
594
+ if (params.a != null)
595
+ q.set('a', String(params.a));
596
+ if (params.b != null)
597
+ q.set('b', String(params.b));
598
+ const qs = q.toString();
599
+ return this._http.fetchGet(`/api/loop/pipelines/${encodeURIComponent(id)}/versions/compare${qs ? `?${qs}` : ''}`);
600
+ }
1064
601
  // ── the comparison report ─────────────────────────────────────────────
1065
602
  /**
1066
603
  * The comparison behind a verdict: both models on the same held-out rows,
1067
- * with identical decoding, judge and grader names resolved.
604
+ * with identical decoding, scored by the same judge.
1068
605
  *
1069
606
  * Read `warnings` before you read `win_rate`. A win rate over a holdout too
1070
607
  * small to mean anything, or one measured by a judge that disagrees with
@@ -1080,8 +617,10 @@ export class Loop {
1080
617
  * The paired conversations behind the numbers: one prompt, both answers, the
1081
618
  * scores each earned, and which won.
1082
619
  *
1083
- * Filter by `winner` to read the losses first, which is where a verdict is
1084
- * actually checked. `limit` is capped at 100 by the service.
620
+ * Filter by `winner` -- `candidate` (the attempt won), `serving` (the version
621
+ * serving today won; the item itself says `incumbent`) or `tie` -- and read
622
+ * `serving` first: the pairs the attempt lost are where a verdict is actually
623
+ * checked. `limit` is 50 when absent and at most 200.
1085
624
  */
1086
625
  async listEvaluationItems(id, params = {}) {
1087
626
  const q = new URLSearchParams();
@@ -1094,24 +633,6 @@ export class Loop {
1094
633
  const qs = q.toString();
1095
634
  return this._http.fetchGet(`/api/loop/evaluations/${encodeURIComponent(id)}/items${qs ? `?${qs}` : ''}`);
1096
635
  }
1097
- /**
1098
- * How far a judge agrees with your own reviewers, over the conversations
1099
- * both have scored.
1100
- *
1101
- * This is a gate, not a badge: a rule's `min_judge_agreement` refuses to
1102
- * promote on the word of a judge that does not agree with the people whose
1103
- * product it is. `enough_pairs` is the field to read first -- "not enough
1104
- * reviewer overlap yet" is an answer, and 100% of two pairs is not.
1105
- */
1106
- async getJudgeAgreement(judgeId, params = {}) {
1107
- const q = new URLSearchParams();
1108
- if (params.from)
1109
- q.set('from', params.from);
1110
- if (params.to)
1111
- q.set('to', params.to);
1112
- const qs = q.toString();
1113
- return this._http.fetchGet(`/api/loop/judges/${encodeURIComponent(judgeId)}/agreement${qs ? `?${qs}` : ''}`);
1114
- }
1115
636
  // ── the standing benchmark ────────────────────────────────────────────
1116
637
  /**
1117
638
  * Pin a fixed set of conversations, with a judge frozen beside them, and
@@ -1128,9 +649,10 @@ export class Loop {
1128
649
  * is refused rather than skipped, because pinning 47 of the 50 you chose is
1129
650
  * the set being wrong from the first day and you would never find out.
1130
651
  *
1131
- * It raises no amount you have already agreed to. The replay's calls come
1132
- * out of the rule's existing `eval_ceiling_cents`, and
1133
- * `per_run_ceiling_cents` can only lower what is spent inside that.
652
+ * The platform freezes the judge and the model it scores on (the ones every
653
+ * pipeline comparison uses), gives both models the comparison's own answer
654
+ * length, and sets what one replay may spend, inside the attempt's own
655
+ * scoring limit; none of that is sent.
1134
656
  */
1135
657
  async createBenchmark(params) {
1136
658
  const res = await this._http.fetchPost('/api/loop/benchmarks', params);
@@ -1161,7 +683,7 @@ export class Loop {
1161
683
  return res.benchmark;
1162
684
  }
1163
685
  /**
1164
- * The pinned conversations, paged. `limit` is capped at 100 by the service.
686
+ * The pinned conversations, paged. `limit` is 50 when absent and at most 200.
1165
687
  *
1166
688
  * `source_trace_id` and `source_trace_url` come back null once the
1167
689
  * conversation a row was copied from has been deleted. The row itself stays
@@ -1196,7 +718,7 @@ export class Loop {
1196
718
  return this._http.fetchGet(`/api/loop/benchmarks/${encodeURIComponent(id)}/history${qs ? `?${qs}` : ''}`);
1197
719
  }
1198
720
  /**
1199
- * Stop replaying a benchmark, and detach it from every rule that names it.
721
+ * Stop replaying a benchmark, and detach it from every pipeline using it.
1200
722
  *
1201
723
  * Nothing measured is removed. There is no delete and no update on purpose:
1202
724
  * the series of numbers measured against a set is what a benchmark is for,
@@ -1226,45 +748,4 @@ export class Loop {
1226
748
  const res = await this._http.fetchGet(`/api/loop/benchmark-runs/${encodeURIComponent(id)}`);
1227
749
  return res.benchmark_run;
1228
750
  }
1229
- /**
1230
- * Attach a benchmark to a rule, or send `{ benchmark_id: null }` to detach
1231
- * it.
1232
- *
1233
- * Its own route rather than a field on the rule body, because it is a
1234
- * decision to replay a fixed set on every future run of this rule for as
1235
- * long as it stands, and its refusals -- retired, or belonging to another
1236
- * workspace -- are about the benchmark rather than about the rule.
1237
- *
1238
- * It does not invalidate consent and the reply says so: attaching raises
1239
- * neither the amount set aside for judge calls nor the amount set aside for
1240
- * keeping the new model available, so nobody is asked to read the same
1241
- * sentence again. A retired benchmark is refused with `BENCHMARK_RETIRED`,
1242
- * because a rule pointed at one would report no number on every run and say
1243
- * nothing about why.
1244
- */
1245
- async setTrainingRuleBenchmark(id, params) {
1246
- return this._http.fetchPut(`/api/loop/training-rules/${encodeURIComponent(id)}/benchmark`, params);
1247
- }
1248
- // ── agent settings ────────────────────────────────────────────────────
1249
- /**
1250
- * The workspace's agent options: which model it defaults to, the system
1251
- * prompts it judges and samples with, and the monthly cap on what its model
1252
- * calls may spend.
1253
- */
1254
- async getAgentSettings() {
1255
- const res = await this._http.fetchGet('/api/loop/agent/settings');
1256
- return res.settings;
1257
- }
1258
- /**
1259
- * Change them. An absent key leaves that setting exactly where it is; a
1260
- * present null returns it to the platform default. Those are three
1261
- * instructions, not two, so `{}` changes nothing.
1262
- *
1263
- * `eval_monthly_cap_cents` is pushed to the workspace's managed key, so it
1264
- * caps what the agent can spend even if a rule's own ceilings are higher.
1265
- */
1266
- async updateAgentSettings(params) {
1267
- const res = await this._http.fetchPut('/api/loop/agent/settings', params);
1268
- return res.settings;
1269
- }
1270
751
  }