Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(forge): lead the quality gate's vision chain with Workers AI so render checks stop failing open

nirholas0120d1835ed1
diff --git a/api/_lib/forge-quality-gate.js b/api/_lib/forge-quality-gate.js
index 336188cc3..2b7cb2ecf 100644
--- a/api/_lib/forge-quality-gate.js
+++ b/api/_lib/forge-quality-gate.js
@@ -318,10 +318,23 @@ async function scoreViaVertex({ imageBase64, mimeType, prompt, subject, timeoutM
return { json: parseJsonLoose(text), provider: 'vertex', model: `vertex-ai/${model}` };
}
-// Score one render via the free platform vision chain (NVIDIA NIM VLMs). Reuses
-// describeImageJson so the free-first doctrine and spend ledger are inherited.
+// The rung the gate asks first. Measured 2026-09-30 with this rubric on real
+// turntable renders from production (a TRELLIS avatar and a catalog armchair):
+// Workers AI's Llama 4 Scout returned the JSON verdict 8 times in 8, in 2.4 to
+// 6.9 s, while the NIM 11B lane returned it 4 times in 8, in 8 to 20 s, and
+// described the avatar in prose on all four tries. Asked first, that lane spent
+// most of the gate's 29 s deadline and then failed, and the rungs behind it
+// (free OpenRouter routes at 429, Vertex on a billing hold, OpenAI with billing
+// inactive) could not answer either, so the gate failed open on 8 of 10
+// production checks. Leading with the measured-reliable rung keeps the rest of
+// the chain as its fallback, cooldowns included.
+export const QUALITY_GATE_VISION_LEAD = Object.freeze(['cloudflare']);
+
+// Score one render via the platform vision chain. Reuses describeImageJson so
+// the JSON acceptance test and the spend ledger are inherited.
async function scoreViaPlatformVision({ imageBase64, mimeType, prompt, subject, timeoutMs, track }) {
const out = await describeImageJson({
+ lead: QUALITY_GATE_VISION_LEAD,
prompt: rubricPrompt(subject, prompt),
imageBase64,
mimeType,
diff --git a/api/_lib/vision.js b/api/_lib/vision.js
index 5e6b6e252..465f99b39 100644
--- a/api/_lib/vision.js
+++ b/api/_lib/vision.js
@@ -502,10 +502,21 @@ function normalizeStatus(status) {
// successful call records a kind:'vision' usage event with provider/model/tokens/cost
// (free NIM prices to 0 in llm-pricing.js).
//
+// `lead` (provider names) moves those rungs to the front for one caller that has
+// measured them as its reliable answerers; cooldowns still apply on top, so a
+// cooling lead rung drops to the back like any other.
+//
// Returns { text, provider, model, usage:{input,output}, raw }.
// Throws VisionUnavailableError when nothing is configured, or the last upstream
// error (with .status = 502/504, .code = normalized) when every provider failed
// or the deadline elapsed.
+/** Stable reorder: rungs whose provider name is in `lead` first, in chain order. */
+export function leadWith(chain, lead) {
+ if (!Array.isArray(lead) || !lead.length) return chain;
+ const names = new Set(lead);
+ return [...chain.filter((p) => names.has(p.name)), ...chain.filter((p) => !names.has(p.name))];
+}
+
export async function describeImage({
prompt,
imageUrl = null,
@@ -517,8 +528,9 @@ export async function describeImage({
deadlineMs = null,
track = null,
accept = null,
+ lead = null,
}) {
- const chain = visionChain();
+ const chain = leadWith(visionChain(), lead);
if (!chain.length) throw new VisionUnavailableError();
const deadlineAt = deadlineMs != null ? Date.now() + deadlineMs : Infinity;