fix(articles): AI drafts failed — pin a live OpenRouter model + readable errors - #426
Merged
Conversation
…le errors
Live verification caught two bugs in the AI writer:
1. Article drafts 404'd: the long-form path used `openai/gpt-oss-120b:free`,
which OpenRouter returns 404 for (free model IDs rot). Pin the model the
offer-engine already proves works on the box — `meta-llama/llama-4-maverick:free`
— for both short and long-form. Also retry a JSON-mode call once without
`response_format` for models that reject it, and trim long-form max_tokens
to a safer 3000.
2. Errors rendered as "[object Object]": the client threw `new Error(json.error)`
but the standard API shape is `error: { code, message }`. Extract `.message`.
Verified: type-check + lint clean, prod build green. Re-verifying draft live.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Live-verification hotfix for the AI writer (PR #425).
Bug 1 — article drafts 404'd. The long-form path used
openai/gpt-oss-120b:free; OpenRouter returns 404 for it (free model IDs rot — prod logs confirmedplatform-llm: model call failed status 404). Pinned the model the offer-engine already proves works on the box:meta-llama/llama-4-maverick:free, for both short and long-form. Also: retry a JSON-mode call once withoutresponse_format(for models that reject it), and trimmed long-formmax_tokensto a safer 3000.Bug 2 — errors showed "[object Object]". The client threw
new Error(json.error), but the standard API shape iserror: { code, message }. Now extracts.message.Topic suggestions already worked live (grounded in the user's real profile/entities/memories); this fixes the full-article draft path + error display.
Verified: type-check + lint clean, prod build green. Re-verifying the live draft after deploy.
🤖 Generated with Claude Code