⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.
TypeScript honoissue-managementissue-trackerjira-alternativekanbanlinear-alternativemcpproject-managementreactself-hostedtypescript
fix: fall back when Peekareq's model provider is throttled
Tin145c13a11bd5
diff --git a/scripts/ui-review-bot/README.md b/scripts/ui-review-bot/README.mdindex 9101dc106..f55afdc28 100644--- a/scripts/ui-review-bot/README.md+++ b/scripts/ui-review-bot/README.md@@ -38,7 +38,7 @@ node scripts/ui-review-bot/publish.mjs /absolute/path/to/report.jsonUse `--model provider/model` or `--key-file /path/to/key.env` to override defaults. Local App authentication uses `GH_TOKEN` and `UI_REVIEW_BOT_LOGIN=<app-slug>[bot]`; otherwise `gh` supplies your user identity.-Default model: `qwen/qwen3.8-flash`, verified against OpenRouter's live vision-model catalog. The model receives the PR diff, relevant source, synthetic page text, and screenshots. Each run allows at most five calls, three scenarios, and six interactions per scenario. Reports record provider-reported usage and cost; there is no fixed dollar cap.+Default model: `qwen/qwen3.8-flash`, verified against OpenRouter's live vision-model catalog. If its provider is rate-limited or temporarily unavailable, the run switches to `google/gemini-2.5-flash-lite`; explicitly selected other models keep their selection. Temporary failures retry at most twice and all attempts count toward the five-request budget. The model receives the PR diff, relevant source, synthetic page text, and screenshots. Each run allows at most five calls, three scenarios, and six interactions per scenario. Reports record provider-reported usage and cost; there is no fixed dollar cap.Local reports, before/after PNGs, and pixel differences are saved in `.cache/ui-review-bot/runs/<id>/`. Ctrl+C cancels capture and closes previews.diff --git a/scripts/ui-review-bot/core.mjs b/scripts/ui-review-bot/core.mjsindex 18da18f44..be9fe83f4 100644--- a/scripts/ui-review-bot/core.mjs+++ b/scripts/ui-review-bot/core.mjs@@ -196,6 +196,9 @@ export async function completion({signal,maxTokens = 2500,}) {+ const fallback =+ model === "qwen/qwen3.8-flash" ? "google/gemini-2.5-flash-lite" : null;+ let requestModel = fallback && run.providerFallback ? fallback : model;let response;for (let attempt = 0; attempt < 3; attempt++) {if (run.calls >= 5)@@ -210,11 +213,13 @@ export async function completion({"X-OpenRouter-Title": "Kaneo UI Review - Local",},body: JSON.stringify({- model,+ model: requestModel,messages,max_tokens: maxTokens,temperature: 0.1,- ...(run.reasoning ? { reasoning: run.reasoning } : {}),+ ...(run.reasoning && requestModel === model+ ? { reasoning: run.reasoning }+ : {}),response_format: { type: "json_object" },provider: { require_parameters: true },}),@@ -235,6 +240,7 @@ export async function completion({? seconds * 1000: 2000 * 2 ** attempt;if (wait > 30000) break;+ if (fallback) requestModel = fallback;await response.body?.cancel();await delay(wait, undefined, { signal });}@@ -246,6 +252,8 @@ export async function completion({`OpenRouter request failed (${code}). Check token credits, model access, or choose a different model.`,);}+ if (requestModel === fallback) run.providerFallback = true;+ run.modelsUsed = [...new Set([...(run.modelsUsed || []), requestModel])];run.usage.input += data.usage?.prompt_tokens || 0;run.usage.output += data.usage?.completion_tokens || 0;if (Number.isFinite(data.usage?.cost)) run.usage.cost += data.usage.cost;diff --git a/scripts/ui-review-bot/tests/core.test.mjs b/scripts/ui-review-bot/tests/core.test.mjsindex c2526dbaf..c36fea153 100644--- a/scripts/ui-review-bot/tests/core.test.mjs+++ b/scripts/ui-review-bot/tests/core.test.mjs@@ -252,3 +252,50 @@ test("temporary provider throttling retries within the five-request budget", asyglobalThis.fetch = original;}});++test("default provider outage switches to a vision fallback and keeps it for the run", async () => {+ const original = globalThis.fetch;+ const requests = [];+ const run = {+ calls: 0,+ reasoning: { max_tokens: 512 },+ usage: { input: 0, output: 0, cost: 0, costKnown: true },+ };+ globalThis.fetch = async (_, options) => {+ const body = JSON.parse(options.body);+ requests.push(body);+ return body.model === "qwen/qwen3.8-flash"+ ? new Response('{"error":{"code":429}}', {+ status: 429,+ headers: { "retry-after": "0" },+ })+ : Response.json({+ choices: [{ message: { content: '{"caption":"Captured"}' } }],+ usage: { cost: 0 },+ });+ };+ try {+ const args = {+ token: "test",+ model: "qwen/qwen3.8-flash",+ messages: [],+ run,+ signal: new AbortController().signal,+ };+ await completion(args);+ await completion(args);+ assert.equal(run.calls, 3);+ assert.deepEqual(+ requests.map((x) => x.model),+ [+ "qwen/qwen3.8-flash",+ "google/gemini-2.5-flash-lite",+ "google/gemini-2.5-flash-lite",+ ],+ );+ assert.equal(requests[1].reasoning, undefined);+ assert.deepEqual(run.modelsUsed, ["google/gemini-2.5-flash-lite"]);+ } finally {+ globalThis.fetch = original;+ }+});