free-agent: --probe, OpenRouter free-lane rotation, Groq TPM reality

- OpenRouter free slugs rotate: minimax-m3.1-flash and north-mini-code are gone,
  nemotron-3.5-lightning and nemotron-3-ultra respond, so the pool is updated.
- --probe pings every lane with a tiny prompt and prints alive/dead with the
  provider's own error, which is how the rotation gets noticed.
- Groq free is TPM-bound (~8K/min): one agent turn nearly fills it, so those
  lanes now sit last and are marked small-prompt only.
- qwen3.8-27b on Groq fails its chat template and is dropped.
This commit is contained in:
Ziad Arafat committed 2026-11-28 21:18:26 -07:00
1 parent 499a109fd8
commit deb83c1a73
2 files changed
+56 -45

No files matched your search

+33 -4
View File
@@ -21,11 +21,12 @@ const BUDGET = join(STATE, "budget.json");
const RUNS = join(STATE, "runs");
// ---------- args ----------
const opts = { brief: "", dir: "", role: "code", id: "", model: "", timeout: 1800, attempts: 3, dryRun: false, list: false, quiet: false };
const opts = { probe: false, brief: "", dir: "", role: "code", id: "", model: "", timeout: 1800, attempts: 3, dryRun: false, list: false, quiet: false };
const argv = process.argv.slice(2);
for (let i = 0; i < argv.length; i++) {
const a = argv[i];
if (a === "--list") opts.list = true;
else if (a === "--probe") opts.probe = true;
else if (a === "--dry-run") opts.dryRun = true;
else if (a === "--quiet") opts.quiet = true;
else if (a === "-h" || a === "--help") {
@@ -39,7 +40,7 @@ for (let i = 0; i < argv.length; i++) {
--timeout <secs> per attempt (default 1800)
--attempts <n> how many pool models to try (default 3)
--dry-run print the chosen model and exit
--list print pool and today's usage`);
--list print pool and today's usage\n --probe ping every pool model once and report which are alive`);
process.exit(0);
} else if (a.startsWith("--")) {
const v = argv[++i];
@@ -100,6 +101,30 @@ function pick(role, skip) {
return null;
}
// ---------- probe: which pool lanes are alive right now ----------
if (opts.probe) {
const res = await Promise.all(
pool.map(async (m) => {
const t0 = Date.now();
const proc = Bun.spawn({
cmd: ["pi", "-p", "--model", m.id, "--no-session", "--no-mcp", "--no-skills", "Reply with exactly: OK"],
stdout: "pipe", stderr: "pipe", env: { ...process.env },
});
const timer = setTimeout(() => { try { proc.kill(); } catch {} }, 90_000);
const [o, e] = await Promise.all([new Response(proc.stdout).text(), new Response(proc.stderr).text()]);
const code = await proc.exited;
clearTimeout(timer);
const out = o + e;
const ok = code === 0 && /\bOK\b/.test(o);
const why = ok ? "" : (out.match(/"message"\s*:\s*"([^"]{0,80})/)?.[1] || out.replace(/\s+/g, " ").slice(0, 80));
return { id: m.id, ok, ms: Date.now() - t0, why };
})
);
for (const r of res) console.log(`${r.ok ? "OK " : "DEAD"} ${r.id.padEnd(50)} ${String(r.ms).padStart(6)}ms ${r.why}`);
process.exit(res.some((r) => r.ok) ? 0 : 1);
}
if (opts.list) {
const b = loadBudget();
const c = loadBudget();
@@ -159,6 +184,8 @@ for (let n = 0; n < Math.max(1, opts.attempts); n++) {
const started = Date.now();
const modelAttempts = [];
let lastOut = "";
let lastCode = null;
for (let r = 1; r <= 3; r++) {
if (!opts.quiet) console.log(`[free-agent] ${runId}: trying ${model.id} (attempt ${n + 1}.${r})`);
appendFileSync(logPath, `\n=== ${new Date().toISOString()} ${model.id} ===\n`);
@@ -191,6 +218,8 @@ for (let n = 0; n < Math.max(1, opts.attempts); n++) {
await Promise.all([pump(proc.stdout), pump(proc.stderr)]);
const code = await proc.exited;
clearTimeout(timer);
lastOut = out;
lastCode = code;
const secs = ((Date.now() - started) / 1000).toFixed(0);
const rateLimited = /429|rate.?limit|quota|RESOURCE_EXHAUSTED|insufficient|overloaded|no capacity|too many requests/i.test(out);
@@ -225,7 +254,7 @@ for (let n = 0; n < Math.max(1, opts.attempts); n++) {
if (rateLimited) {
// Only a daily/credit wall parks a lane for the rest of the day. A per-minute
// 429 was already retried above; failing over is enough for that one.
const daily = /per day|daily|RPD|requests? per day|insufficient balance|no resource package|billing/i.test(out);
const daily = /per day|daily limit|RPD|insufficient balance|no resource package/i.test(lastOut);
if (daily) {
const bb = loadBudget();
markExhausted(bb, model.id);
@@ -240,7 +269,7 @@ for (let n = 0; n < Math.max(1, opts.attempts); n++) {
console.log(runDir);
process.exit(0);
}
if (!opts.quiet) console.log(`\n[free-agent] ${model.id}: exit ${code}, no HANDOFF-DONE — next model`);
if (!opts.quiet) console.log(`\n[free-agent] ${model.id}: exit ${lastCode}, no HANDOFF-DONE — next model`);
}
const state = attempts.length === 0 ? "no-capacity" : "failed";
+23 -41
View File
@@ -23,18 +23,7 @@
"note": "Permanent $0 Flash model on Z.ai; fastest of the four in practice."
},
{
"id": "groq/openai/gpt-oss-120b",
"roles": [
"code",
"review",
"infra"
],
"rpm": 28,
"rpd": 900,
"note": "Groq LPU, very fast, 131K context. Free tier is token-per-minute tight (~6-8K TPM), so keep briefs short."
},
{
"id": "openrouter/minimax/minimax-m3.1-flash:free",
"id": "openrouter/nvidia/nemotron-3.5-lightning:free",
"roles": [
"code",
"review",
@@ -42,7 +31,17 @@
],
"rpm": 18,
"rpd": 45,
"note": "OpenRouter :free, 1M context, vision. 50 req/day cap (45 here for headroom)."
"note": "OpenRouter :free, 1M context, verified reachable 2026-11-29."
},
{
"id": "openrouter/nvidia/nemotron-3-ultra-550b-a55b:free",
"roles": [
"code",
"review"
],
"rpm": 18,
"rpd": 45,
"note": "OpenRouter :free, 1M context, larger sibling of the lightning lane."
},
{
"id": "google/gemini-3.1-flash-lite",
@@ -54,34 +53,6 @@
"rpd": 800,
"note": "Cheap second Gemini lane for small edits and reviews."
},
{
"id": "openrouter/nvidia/nemotron-3-super-120b-a12b:free",
"roles": [
"code",
"review"
],
"rpm": 18,
"rpd": 45,
"note": "OpenRouter :free alternative when minimax is busy."
},
{
"id": "openrouter/cohere/north-mini-code:free",
"roles": [
"code"
],
"rpm": 18,
"rpd": 45,
"note": "Code-tuned free lane through OpenRouter."
},
{
"id": "groq/qwen/qwen3.8-27b",
"roles": [
"code"
],
"rpm": 28,
"rpd": 900,
"note": "Groq fallback, small max output (16K)."
},
{
"id": "cohere/north-mini-code-1.0",
"roles": [
@@ -91,6 +62,17 @@
"rpm": 18,
"rpd": 30,
"note": "Existing Cohere trial key: 1000 calls/month, so ~30/day."
},
{
"id": "groq/openai/gpt-oss-120b",
"roles": [
"code",
"review",
"infra"
],
"rpm": 6,
"rpd": 150,
"note": "Groq free is TPM-bound (~8K tokens/min on gpt-oss-120b): one agent turn with the system prompt and tool schemas nearly fills it, so this lane is last resort for small prompts only."
}
]
}