Release 0.13.0: agent API for deployments and benchmarks
Release / release (push) Successful in 3m0s
Release / release (push) Successful in 3m0s
Scopes deployments:read/write and benchmarks:read/run; /api/v1 endpoints for runtimes, deployments (create with dry run, edit, start, stop, delete own ones), benchmark runs, A/B, sweeps and comparisons; ?wait= on all status endpoints. Guardrails: approval, agent deployments at once, one GPU job at a time, time limits, sweep variants, runtime and argument allowlists, host port range, memory/CPU caps, protected deployments with a VRAM check. Requested-by filters, approval bars, per-token activity log, scope editing, docs/agent/SKILL-tuning.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e007a35143
commit
716bd8f2f0
62 files changed
+6091
-219
No files matched your search
+38
-4
@@ -50,7 +50,10 @@ async function snapshotOf(deploymentId: string, role: string) {
|
||||
* Queue a run against a running deployment, or a paired A/B between two running deployments of the
|
||||
* same model (BetterBench sends one model name to both). The worker runs one benchmark at a time.
|
||||
*/
|
||||
export async function createBenchmark(input: BenchmarkInput) {
|
||||
/** Requested through the API: who asked, whether it waits for approval, and its time limit. */
|
||||
export type AgentRequest = { requestedBy: { tokenId: string; name: string }; pendingApproval: boolean; timeLimitS: number };
|
||||
|
||||
export async function createBenchmark(input: BenchmarkInput, agent?: AgentRequest) {
|
||||
const ab = !!input.deploymentBId;
|
||||
const a = await snapshotOf(input.deploymentId, ab ? "Deployment A" : "The deployment");
|
||||
const b = ab ? await snapshotOf(input.deploymentBId!, "Deployment B") : null;
|
||||
@@ -79,6 +82,14 @@ export async function createBenchmark(input: BenchmarkInput) {
|
||||
snapshot: a.snapshot,
|
||||
snapshotB: b?.snapshot ?? null,
|
||||
sweepId: input.sweepId ?? null,
|
||||
...(agent
|
||||
? {
|
||||
requestedByTokenId: agent.requestedBy.tokenId,
|
||||
requestedBy: agent.requestedBy.name,
|
||||
timeLimitS: agent.timeLimitS,
|
||||
state: agent.pendingApproval ? ("pending_approval" as const) : ("queued" as const),
|
||||
}
|
||||
: {}),
|
||||
})
|
||||
.returning({ id: benchmarkRuns.id });
|
||||
return row;
|
||||
@@ -106,6 +117,9 @@ const listColumns = {
|
||||
ab: benchmarkRuns.ab,
|
||||
resources: benchmarkRuns.resources,
|
||||
sweepId: benchmarkRuns.sweepId,
|
||||
requestedBy: benchmarkRuns.requestedBy,
|
||||
requestedByTokenId: benchmarkRuns.requestedByTokenId,
|
||||
timeLimitS: benchmarkRuns.timeLimitS,
|
||||
meta: benchmarkRuns.meta,
|
||||
metaB: benchmarkRuns.metaB,
|
||||
system: benchmarkRuns.system,
|
||||
@@ -139,17 +153,37 @@ export async function getBenchmarks(ids: string[]) {
|
||||
return ids.map((id) => rows.find((r) => r.id === id)).filter((r) => r != null);
|
||||
}
|
||||
|
||||
/** Queued runs are cancelled right away; a running one is stopped by the worker. */
|
||||
/** Queued (or still unapproved) runs are cancelled right away; a running one is stopped by the worker. */
|
||||
export async function cancelBenchmark(id: string) {
|
||||
const run = await getBenchmark(id);
|
||||
if (!run) throw new BenchmarkError("not_found", "Benchmark not found.", 404);
|
||||
if (run.state === "queued") {
|
||||
await db().update(benchmarkRuns).set({ state: "cancelled", finishedAt: new Date() }).where(and(eq(benchmarkRuns.id, id), eq(benchmarkRuns.state, "queued")));
|
||||
if (run.state === "queued" || run.state === "pending_approval") {
|
||||
await db().update(benchmarkRuns).set({ state: "cancelled", finishedAt: new Date() }).where(and(eq(benchmarkRuns.id, id), eq(benchmarkRuns.state, run.state)));
|
||||
} else if (run.state === "running") {
|
||||
await db().update(benchmarkRuns).set({ cancelRequestedAt: new Date() }).where(eq(benchmarkRuns.id, id));
|
||||
}
|
||||
}
|
||||
|
||||
/** Let a run an agent asked for start (it joins the queue). */
|
||||
export async function approveBenchmark(id: string) {
|
||||
const res = await db()
|
||||
.update(benchmarkRuns)
|
||||
.set({ state: "queued" })
|
||||
.where(and(eq(benchmarkRuns.id, id), eq(benchmarkRuns.state, "pending_approval")))
|
||||
.returning({ id: benchmarkRuns.id });
|
||||
if (res.length === 0) throw new BenchmarkError("invalid", "This run doesn't wait for approval.", 409);
|
||||
}
|
||||
|
||||
/** Turn down a run an agent asked for. */
|
||||
export async function rejectBenchmark(id: string) {
|
||||
const res = await db()
|
||||
.update(benchmarkRuns)
|
||||
.set({ state: "cancelled", finishedAt: new Date(), error: "Rejected by the user." })
|
||||
.where(and(eq(benchmarkRuns.id, id), eq(benchmarkRuns.state, "pending_approval")))
|
||||
.returning({ id: benchmarkRuns.id });
|
||||
if (res.length === 0) throw new BenchmarkError("invalid", "This run doesn't wait for approval.", 409);
|
||||
}
|
||||
|
||||
/** Rename a run (label) and/or change its description; fields left out stay as they are. */
|
||||
export async function updateBenchmark(id: string, patch: { label?: string | null; description?: string | null }) {
|
||||
const set: Partial<typeof benchmarkRuns.$inferInsert> = {};
|
||||
|
||||
Reference in new issue
Block a user