Repository navigation
fix(skillforge): model fallback chain + diagnostics for upload_packages - #21
Merged
Merged
Conversation
Users report MCP+OAuth+upload all work, but the SkillForge author pipeline silently fails to normalise content into private drafts. Two root causes were possible and both were invisible: 1. The author flow hard-coded "google/gemini-3-flash-preview" with no fallback. Any structured-output regression on that specific model (it's a preview SKU) kills every upload across the site. 2. Errors were swallowed: processBulkUpload caught the exception per file and put `e.message` into `out.error`, then upload_packages buried that inside `results[]`. MCP clients typically render only the first chunk of a tool response, so users (and the LLM driving the call) saw "failed: 1" with no actionable cause. Changes: * generateDraft now walks an ordered model fallback chain (gemini-3-flash-preview → gemini-2.5-flash → gemini-2.5-pro → gpt-5.1-mini). First success wins. Recovery from a non-primary model is logged with the upstream errors so we can spot a primary regression in the logs instead of from user reports. * Every author attempt logs the model + error to console.error so the real cause (model rejection, schema mismatch, gateway 4xx) is visible in Vercel logs. * processBulkUpload logs per-file failures with user_id + filename for correlation. * upload_packages now emits a top-level `error_summary` field listing the first 3 per-file errors so clients that truncate the response still see the cause. Idempotency cache only stores successful runs so a transient model outage doesn't poison the key for 24h. * next_step copy adapts: success path points at /account/packages, full-failure path tells the user to retry and look at error_summary. https://claude.ai/code/session_019gMoupKKTVydpNwiiACQRd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Users report MCP+OAuth+upload work end-to-end but SkillForge silently fails to normalise uploaded content into private drafts. Two compounding issues were hiding the cause.
Root causes (both invisible to operators)
generateDrafthard-codedgoogle/gemini-3-flash-previewwith no fallback. Any structured-output regression on that specific preview SKU kills every upload across the site (web + MCP).processBulkUploadcaught exceptions per file and pute.messageintoresults[].error.upload_packagesthen buried that inside the results array. MCP clients typically render only the first chunk of a tool response, so users (and the LLM driving the call) saw"failed: 1"with no actionable cause.What's in
src/lib/admin/author.server.tsgemini-3-flash-preview→gemini-2.5-flash→gemini-2.5-pro→gpt-5.1-mini). First success wins.[skillforge.author] <model> failed: …toconsole.error. Recovery from a non-primary logs aconsole.warnso a primary regression shows up in logs instead of from user complaints.Errorsummarising every attempt, so the caller can surface a real message.src/lib/uploads/uploads.server.ts[uploads.processBulkUpload] user=… file=…:for correlation against support reports.src/lib/mcp/tools/skills.ts(upload_packages)error_summaryfield on failures (first 3 errors, joined). Survives MCP response truncation.next_stepadapts: success points at/account/packages; full-failure tells the user to retry and readerror_summary.Test plan
upload_packageswith all model env keys present → success, draft appears in/account/packages.LOVABLE_API_KEYfor one model, or point the gateway at a 404) → fallback kicks in; Vercel logs show[skillforge.author] google/gemini-3-flash-preview failed:followed byrecovered on google/gemini-2.5-flash.failed: 1, error_summary: "<filename>: SkillForge author failed across all fallback models — …"and idempotency key is NOT cached (retry with same key actually retries).idempotency_key→ second call with same key replays cached response.https://claude.ai/code/session_019gMoupKKTVydpNwiiACQRd
Generated by Claude Code