fix(api): pin Wiki Compose LLM to google:gemini-3.5-flash#990
Conversation
Wiki Compose orchestrator, research, draft, and web_search now resolve a single fixed ai_models.id (google:gemini-3.5-flash) instead of provider-specific fallbacks. Ingest planner keeps resolveComposeModelId. Co-authored-by: Akimasa Sugai <otomatty@users.noreply.github.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a fixed Wiki Compose model id and resolver with tier-aware DB lookup, migrates wiki and research nodes to use the wiki resolver, prioritizes the fixed model for web-search selection, and enforces BYOK runtime checks with new tests. ChangesWiki Compose Fixed Model ID Resolution
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
There was a problem hiding this comment.
Code Review
This pull request pins the Wiki Compose model to a fixed Google model (google:gemini-3.5-flash) across various graphs and nodes, including orchestrator, draft, research, and web search tools. The feedback recommends updating the BYOK pre-flight validation to reject non-Google BYOK backends early, preventing runtime crashes due to provider mismatches. Additionally, it is suggested to extract the duplicated database query logic for resolving the active and accessible fixed model ID into a shared helper function to improve maintainability.
| * Wiki Compose uses a fixed Google model at runtime ({@link WIKI_COMPOSE_MODEL_ID}). | ||
| * BYOK sessions still need a stored credential when the graph calls an LLM; provider | ||
| * alignment with the fixed model is the caller's responsibility for now. | ||
| * | ||
| * 静的 env モデル id との provider 照合は行わない。実行時の | ||
| * `resolveComposeModelId` が provider 整合を担保する。本関数は LLM を呼ぶ | ||
| * グラフで credential が存在するかだけを確認する。 | ||
| * Wiki Compose は実行時に Google 固定モデルを使う。BYOK 時は LLM 呼び出し前に | ||
| * credential の有無だけをここで確認する。 |
There was a problem hiding this comment.
Since Wiki Compose is now pinned to google:gemini-3.5-flash (via WIKI_COMPOSE_MODEL_ID), any BYOK backend other than google_byok (e.g., anthropic_byok or openai_byok) will pass this pre-flight check but fail at runtime with a BackendProviderMismatchError when createZediChatModel is called.
To prevent runtime crashes and provide a clear error message, we should update assertComposeBackendReady to reject non-Google BYOK backends when the graph uses WIKI_COMPOSE_MODEL_ID:
export async function assertComposeBackendReady(input: {
backend: ExecutionBackend;
graphId: string;
userId: string;
tier: UserTier;
db: Database;
}): Promise<void> {
if (!isUserByokBackend(input.backend)) return;
const modelIds = getComposeModelIdsForGraph(input.graphId);
if (modelIds.length === 0) return;
const expectedProvider = backendToCredentialProvider(input.backend);
// Reject non-Google BYOK backends early for Wiki Compose
if (modelIds.includes(WIKI_COMPOSE_MODEL_ID) && expectedProvider !== "google") {
throw new HTTPException(400, {
message: `Wiki Compose is currently pinned to Google models. Backend "${input.backend}" is incompatible.`,
});
}
const key = await getUserAiCredentialPlaintext(input.userId, expectedProvider, input.db);
if (!key?.trim()) {
throw new HTTPException(400, {
message: `No API credential configured for backend "${input.backend}"`,
});
}
}| async function fixedModelIdIfAccessible(db: Database, tier: UserTier): Promise<string> { | ||
| const tierClause = tierFilter(tier); | ||
| const [row] = await db | ||
| .select({ id: aiModels.id }) | ||
| .from(aiModels) | ||
| .where( | ||
| and( | ||
| eq(aiModels.id, WIKI_COMPOSE_MODEL_ID), | ||
| eq(aiModels.isActive, true), | ||
| ...(tierClause ? [tierClause] : []), | ||
| ), | ||
| ) | ||
| .limit(1); | ||
| return row?.id ?? WIKI_COMPOSE_MODEL_ID; | ||
| } |
There was a problem hiding this comment.
The database query to resolve the active and accessible fixed model ID is duplicated in resolveWebSearchModel.ts. We can extract this query into a shared helper function resolveActiveWikiComposeModelId to improve maintainability and reuse it across both files.
export async function resolveActiveWikiComposeModelId(
db: Database,
tier: UserTier,
): Promise<string | null> {
const tierClause = tierFilter(tier);
const [row] = await db
.select({ id: aiModels.id })
.from(aiModels)
.where(
and(
eq(aiModels.id, WIKI_COMPOSE_MODEL_ID),
eq(aiModels.isActive, true),
...(tierClause ? [tierClause] : []),
),
)
.limit(1);
return row?.id ?? null;
}
async function fixedModelIdIfAccessible(db: Database, tier: UserTier): Promise<string> {
return (await resolveActiveWikiComposeModelId(db, tier)) ?? WIKI_COMPOSE_MODEL_ID;
}| import { and, asc, eq, inArray } from "drizzle-orm"; | ||
| import { aiModels } from "../../../schema/index.js"; | ||
| import type { Database, UserTier } from "../../../types/index.js"; | ||
| import { WIKI_COMPOSE_MODEL_ID } from "../llm/wikiComposeModelId.js"; |
There was a problem hiding this comment.
| const tierClause = tierFilter(tier); | ||
| const [fixedRow] = await db | ||
| .select({ id: aiModels.id }) | ||
| .from(aiModels) | ||
| .where( | ||
| and( | ||
| eq(aiModels.id, WIKI_COMPOSE_MODEL_ID), | ||
| eq(aiModels.isActive, true), | ||
| ...(tierClause ? [tierClause] : []), | ||
| ), | ||
| ) | ||
| .limit(1); | ||
| if (fixedRow) return fixedRow.id; |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fc279f36b4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| export async function resolveWikiComposeModelId( | ||
| _role: ComposeModelRole, | ||
| _tier: UserTier, | ||
| db: Database, | ||
| ): Promise<string> { | ||
| return fixedModelIdIfAccessible(db, _tier); |
There was a problem hiding this comment.
Reject incompatible BYOK backends before pinning model
resolveWikiComposeModelId now always resolves to google:gemini-3.5-flash regardless of the session backend, so user_openai / user_anthropic sessions can still be created but will fail at runtime when createZediChatModel enforces provider/backend matching (BackendProviderMismatchError). This is a regression from the previous backend-aware resolution path and will break valid BYOK users unless backend compatibility is checked up front or model resolution is backend-aware again.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@server/api/src/__tests__/agents/core/llm/wikiComposeModelId.test.ts`:
- Around line 1-3: The file header comment currently only contains English;
update the top-of-file comment block in wikiComposeModelId.test.ts to include a
concise Japanese equivalent (e.g., translate "Tests for fixed Wiki Compose model
id resolution" into Japanese) so the header is bilingual; ensure the Japanese
text appears alongside the existing English in the same comment block at the
very top of the file.
In `@server/api/src/agents/subgraphs/research/nodes/planQueries.ts`:
- Around line 26-27: The JSDoc deprecation comment for the function referencing
resolveWikiComposeModelId and getComposeModelIdsForGraph is English-only; add a
Japanese translation immediately below the English sentence within the same
JSDoc block so both languages appear (e.g., duplicate the deprecation sentence
in Japanese after “@deprecated Use {`@link` resolveWikiComposeModelId} for Wiki
Compose graphs. Kept for ingest planner BYOK preflight ({`@link`
getComposeModelIdsForGraph}).”), keeping the same tags and formatting and
ensuring the Japanese text clearly conveys the same deprecation and usage
guidance.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 6d5494fa-0989-49c0-acff-d3c121204e97
📒 Files selected for processing (14)
server/api/src/__tests__/agents/core/llm/wikiComposeModelId.test.tsserver/api/src/__tests__/agents/subgraphs/research/nodes/planQueries.test.tsserver/api/src/__tests__/agents/subgraphs/research/researchGraph.modelGuard.test.tsserver/api/src/agents/core/composeBackendValidation.tsserver/api/src/agents/core/composeModelConfig.tsserver/api/src/agents/core/llm/resolveComposeModelId.tsserver/api/src/agents/core/llm/wikiComposeModelId.tsserver/api/src/agents/core/tools/resolveWebSearchModel.tsserver/api/src/agents/graphs/wikiCompose/nodes/briefDialogue.tsserver/api/src/agents/graphs/wikiCompose/nodes/draftSections.tsserver/api/src/agents/graphs/wikiCompose/nodes/structureDialogue.tsserver/api/src/agents/subgraphs/research/nodes/evaluateSufficiency.tsserver/api/src/agents/subgraphs/research/nodes/planQueries.tsserver/api/src/agents/subgraphs/research/nodes/refineQueries.ts
- assertComposeBackendReady: only zedi_managed or user_google for wiki-compose graphs - Export resolveActiveWikiComposeModelId; reuse in web_search resolver - Address review: bilingual JSDoc, BYOK preflight tests Co-authored-by: Akimasa Sugai <otomatty@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@server/api/src/agents/core/llm/wikiComposeModelId.ts`:
- Around line 18-21: The JSDoc for isFixedWikiComposeModelGraph is English-only;
update the exported JSDoc comment above the function to include a concise
Japanese translation alongside the existing English text (matching the file's
bilingual style). Keep the same description and reference to
WIKI_COMPOSE_MODEL_ID, and ensure the Japanese sentence clearly states the same
purpose (that the function checks graph ids pinned to WIKI_COMPOSE_MODEL_ID);
leave the function and constants (WIKI_COMPOSE_GRAPH_ID, RESEARCH_GRAPH_ID)
unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 5afa5656-7cb0-4654-8f97-40e13712a7df
📒 Files selected for processing (6)
server/api/src/__tests__/agents/core/composeBackendValidation.test.tsserver/api/src/__tests__/agents/core/llm/wikiComposeModelId.test.tsserver/api/src/agents/core/composeBackendValidation.tsserver/api/src/agents/core/llm/wikiComposeModelId.tsserver/api/src/agents/core/tools/resolveWebSearchModel.tsserver/api/src/agents/subgraphs/research/nodes/planQueries.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- server/api/src/agents/subgraphs/research/nodes/planQueries.ts
- server/api/src/tests/agents/core/llm/wikiComposeModelId.test.ts
- server/api/src/agents/core/tools/resolveWebSearchModel.ts
| /** Graph ids that pin LLM calls to {@link WIKI_COMPOSE_MODEL_ID}. */ | ||
| export function isFixedWikiComposeModelGraph(graphId: string): boolean { | ||
| return graphId === WIKI_COMPOSE_GRAPH_ID || graphId === RESEARCH_GRAPH_ID; | ||
| } |
There was a problem hiding this comment.
Add Japanese text to this exported JSDoc block for guideline compliance.
Line 18 currently has English-only documentation while this file otherwise follows bilingual EN/JA comments.
Proposed fix
-/** Graph ids that pin LLM calls to {`@link` WIKI_COMPOSE_MODEL_ID}. */
+/**
+ * Graph ids that pin LLM calls to {`@link` WIKI_COMPOSE_MODEL_ID}.
+ * LLM 呼び出しを {`@link` WIKI_COMPOSE_MODEL_ID} に固定する graph id。
+ */
export function isFixedWikiComposeModelGraph(graphId: string): boolean {
return graphId === WIKI_COMPOSE_GRAPH_ID || graphId === RESEARCH_GRAPH_ID;
}As per coding guidelines "Include both Japanese and English comments/documentation in code and documentation files to maintain project tone consistency".
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@server/api/src/agents/core/llm/wikiComposeModelId.ts` around lines 18 - 21,
The JSDoc for isFixedWikiComposeModelGraph is English-only; update the exported
JSDoc comment above the function to include a concise Japanese translation
alongside the existing English text (matching the file's bilingual style). Keep
the same description and reference to WIKI_COMPOSE_MODEL_ID, and ensure the
Japanese sentence clearly states the same purpose (that the function checks
graph ids pinned to WIKI_COMPOSE_MODEL_ID); leave the function and constants
(WIKI_COMPOSE_GRAPH_ID, RESEARCH_GRAPH_ID) unchanged.
Co-authored-by: Akimasa Sugai <otomatty@users.noreply.github.com>
Summary
Wiki Compose のすべての LLM 呼び出し(Brief / 調査 / 構成 / 執筆)と
web_searchツールが、固定のai_models.idgoogle:gemini-3.5-flashを使うように変更しました。ロール(orchestrator / draft)や実行 backend によるモデル切り替えは現時点では行いません。Changes
wikiComposeModelId.ts:WIKI_COMPOSE_MODEL_IDとresolveWikiComposeModelId()resolveWikiComposeModelIdに切り替えweb_searchは固定モデルを最優先で解決composeModelConfigの wiki-compose / wiki-compose-research は単一モデル id のみ返すresolveComposeModelId(変更なし)Ops note
本番・開発 DB の
ai_modelsにgoogle:gemini-3.5-flashがis_active = trueで登録されている必要があります。未登録の場合は従来どおりModel not found or inactiveになります。管理画面のモデル同期、またはGOOGLE_MODEL_IDSにgemini-3.5-flashを含めてsync:ai-modelsを実行してください。Testing
server/api:wikiComposeModelId.test.ts, wiki compose / research 関連 Vitest(42 tests)Summary by CodeRabbit
New Features
Removed
Behavior Changes
Tests
Documentation