Skip to content

fix: retry next provider on unusable model output, log why providers fail - #6

Merged
riteshbonthalakoti merged 2 commits into
mainfrom
claude/fix-ai-response-handling
Nov 3, 2026
Merged

riteshbonthalakoti merged 2 commits into
mainfrom
claude/fix-ai-response-handling

Conversation

@riteshbonthalakoti

@riteshbonthalakoti riteshbonthalakoti commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

What

After #2 was deployed, audits complete again but production still returns junk:

  • groq-1, groq-2 and openrouter-gemma fail on every call, and the log only said "rate-limited or error". withFallback now logs the status and a redacted, truncated message (keys matching gsk_/sk-/fc- are masked) so the cause is visible in Vercel logs.
  • openrouter-nemotron (the provider that finally answers) returns output the parser rejects, and analyzeDimension turned that into a fake score: 50 "unexpected format" result that was shipped as the audit. Now:
    • parsing tolerates <think> blocks, code fences and prose around the JSON, and validates score and findings
    • unusable output throws, so withFallback tries the next provider
    • a dimension that fails on every provider is marked failed and excluded from the overall score
    • if the very first dimension fails everywhere, the audit stops early instead of burning ~15s per remaining dimension
    • max_tokens raised from 1000 to 1800 so reasoning models are less likely to be cut off before the JSON

Why

Verified live after #2 deployed: a free audit of example.com returned three dimensions all scored 50 with "Analysis returned an unexpected format", provider openrouter-nemotron, total 61s.

Type

  • Bug fix

Checklist

The fallback warning said only 'rate-limited or error', hiding why groq-1,
groq-2 and openrouter-gemma fail on every audit.
A reasoning/prose response was turned into a fake 50-point result and shipped.
Parse tolerantly (think blocks, fences, surrounding prose), throw on garbage so
withFallback tries the next provider, mark dimensions that fail everywhere and
leave them out of the overall score, and stop early when the first dimension fails.
@vercel

vercel Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
roastlab Error Error Nov 3, 2026 9:04am UTC

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

Copy link
Copy Markdown
Owner Author

The Vercel preview check is red with Failed to collect page data for /api/stripe: the Stripe client is constructed at module scope in app/api/stripe/route.ts and the preview environment has no STRIPE_SECRET_KEY. This PR only touches lib/ai/analyze.ts and lib/ai/providers.ts, and the same failure appears on #1-#5. Known and left as is (see #1).


Generated by Claude Code

@riteshbonthalakoti
riteshbonthalakoti marked this pull request as ready for review November 3, 2026 09:28
@riteshbonthalakoti
riteshbonthalakoti merged commit dbe656c into main Nov 3, 2026
5 of 6 checks passed

This branch had an error being deployed

1 failed deployment
Preview — 9fb8cdfa Deployed Nov 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants