Files
Kaname/src/app/api/v1/sweeps/route.ts
T
Pascal LinxweilerandClaude Opus 5.5 716bd8f2f0
Release / release (push) Successful in 3m0s
Release 0.13.0: agent API for deployments and benchmarks
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>
2026-10-21 15:11:06 +02:00

30 lines
1.1 KiB
TypeScript

import { act } from "@/lib/agent-activity";
import { AgentSweepBody, requestSweep } from "@/lib/agent-runs";
import { withToken } from "@/lib/api-tokens";
import { v1Catch, v1Json } from "@/lib/api-v1";
export const dynamic = "force-dynamic";
/**
* Queue a sweep: one or two settings varied from the token's own base deployment. Each variant is
* deployed, benchmarked and removed again, one after another.
*/
export const POST = withToken("benchmarks:run", async (req, { token }) => {
try {
const body = AgentSweepBody.parse(await req.json());
const r = await act(token, "sweep.create", { type: "sweep" }, () => requestSweep(token, body));
return v1Json(
{
...r,
message:
r.state === "pending_approval"
? "Requested; it waits for the user's approval in Kaname. Don't retry or poll; tell the user and stop."
: `Queued (${r.variants} variants, stopped after ${r.timeLimitMinutes} min); GET /api/v1/sweeps/${r.id}?wait=900 for progress.`,
},
201,
);
} catch (err) {
return v1Catch(err);
}
});