You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Essay and translation grading now support automatic fallback across free AI models when the preferred model is unavailable. A configured model is tried first, and duplicate model options are avoided.
Shared model resolution app/lib/shared/openrouter.ts, app/lib/shared/openrouter.test.ts, .env.example
The shared module defines the OpenRouter URL, three default models, and a resolver that trims overrides, removes duplicates, and limits the list to three. Tests cover defaults and overrides. The environment example documents the fallback.
Both grading functions send the resolved model list. Each returns the model reported by OpenRouter, or the first candidate when the response omits it.
Suggested reviewers:tknkaa
Change: Bug fix
Merge Risk: Minimal · up to d1555
Essay and translation grading now use a shared model list with automatic fallback, which should fix failures caused by the removed free model. No concrete merge-blocking risk was found. Live grading requests were not exercised, so a quick manual check after deploy is advisable.
Security architecture risk: Moderate · up to d1555
The change makes grading more resilient, but it also lets the external service choose from a broader set of processors for learner submissions. The record used to investigate grading issues can also name the wrong processor if a fallback succeeds without identifying itself.
Retained concerns
Minor · security · inferred: Compared with requesting one model, the default route now permits OpenRouter to choose another downstream model for the same learner text, including through a dynamic router. The three-entry cap does not bound that router to three downstream processors, and neither grading request expresses provider or data-handling restrictions. The effective processor set depends on account policy that was not available for review.
Trivial · security · inferred: If a fallback model returns feedback without a model identifier, both flows persist the first candidate rather than marking the responder as unknown. Unlike the prior single-model request, the requested first candidate is no longer the only possible responder. This can mislead processor attribution during an audit or incident investigation.
inferred — The wider route applies to learner text and accompanying grading context in both features when fallback is used. The changed requests do not add bulk reads of stored submissions, a new client-selected destination, or a new credential.
Trust Boundaries and Controls
observed — Learners control submitted text, while server configuration supplies the endpoint, bearer credential, and candidate list. The external response supplies the reported model identifier; the application uses a TypeScript assertion rather than runtime validation before passing it to persistence.
Hardening Proposals
proposed — Constrain fallback to processors that meet the deployment's data-handling requirements, and provide an operator setting that can disable fallback without reverting the application.
proposed — Validate the reported identifier and record unknown attribution explicitly rather than using the first requested candidate as evidence of who answered.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
The reason will be displayed to describe this comment to others. Learn more.
Architecture findings (2)
Advisory architecture findings (2)
Minor — Compared with requesting one model, the default route now permits OpenRouter to choose another downstream model for the same learner text, including through a dynamic router. The three-entry cap does not bound that router to three downstream processors, and neither grading request expresses provider or data-handling restrictions. The effective processor set depends on account policy that was not available for review.
Trivial — If a fallback model returns feedback without a model identifier, both flows persist the first candidate rather than marking the responder as unknown. Unlike the prior single-model request, the requested first candidate is no longer the only possible responder. This can mislead processor attribution during an audit or incident investigation.
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: defaults
Review profile: CHILL
Plan: Advanced
Run ID: af54be2c-7986-436c-be91-b1f038fc5ae2
Commits
Reviewing files that changed from the base of the PR and between 35cfa60 and d15553a.
Files selected for processing: 5
.env.example
app/lib/shared/essay/grading.ts
app/lib/shared/openrouter.test.ts
app/lib/shared/openrouter.ts
app/lib/shared/translation/grading.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
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
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.
背景
作文・翻訳セクションのAI添削で使っていた
nvidia/nemotron-3-super-120b-a12b:freeが、OpenRouterの無料モデル一覧から削除されていました。そのため添削リクエストが失敗していました。変更内容
app/lib/shared/openrouter.tsを新規作成し、作文・翻訳で別々に持っていたモデル設定を1か所にまとめたmodelsフォールバックを使い、先頭のモデルが使えないときは次のモデルに自動で切り替えるnvidia/nemotron-3.5-super-vl:free(今までのモデルの後継)google/gemma-4-31b-it:freeopenrouter/free(その時に使える無料モデルをOpenRouterが自動で選ぶ)OPENROUTER_MODEL環境変数を指定した場合は、そのモデルを最優先にするmodel)をDBに保存するresolveModelsの単体テストを追加確認
npm run lint/npm run typecheck/npm test(557件すべて通過).envのキーが正しくなかったため、まだ確認していない)🤖 Generated with Claude Code
Summary by CodeRabbit