Repository navigation
Replace ?? with || in model fallback - #1210
Conversation
WalkthroughUpdated default model selection in two agent modules by replacing nullish coalescing (??) with logical OR (||), causing defaults to apply for any falsy model value. No changes to function signatures or other parameters. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (4)
llm_agents/anthropic_agent/src/anthropic_agent.ts (3)
64-73: Guard against accidental JSON parse failures when response_format is enabledIf the model returns non-JSON text while
maybeResponseFormatis true,JSON.parsewill throw and fail the call. Safer to try/catch and fall back to null.Apply:
- const responseFormat = (() => { - if (maybeResponseFormat && text) { - const parsed = JSON.parse(text); - if (typeof parsed === "object" && parsed !== null) { - return parsed; - } - } - return null; - })(); + const responseFormat = (() => { + if (maybeResponseFormat && text) { + try { + const parsed = JSON.parse(text); + if (typeof parsed === "object" && parsed !== null) { + return parsed; + } + } catch { + // non-JSON content; ignore and fall back + } + } + return null; + })();
236-238: Typo in error message: “Anthoropic” → “Anthropic”Minor polish for error clarity.
- throw new Error("Anthoropic no response"); + throw new Error("Anthropic no response");
243-245: Harden JSON parsing for tool_use input assemblyA malformed or truncated stream could cause
JSON.parse(partial)to throw, terminating the stream handling. A try/catch avoids taking down the whole request.- if (streamResponse.content[index].type === "tool_use") { - streamResponse.content[index].input = JSON.parse(partial); - } + if (streamResponse.content[index].type === "tool_use") { + try { + streamResponse.content[index].input = JSON.parse(partial); + } catch { + streamResponse.content[index].input = {}; + } + }llm_agents/gemini_agent/src/gemini_agent.ts (1)
239-242: Incorrect npm package listed for Gemini agent metadata
npmspoints to@anthropic-ai/sdk. This likely should be@google/generative-ai.license: "MIT", stream: true, - npms: ["@anthropic-ai/sdk"], + npms: ["@google/generative-ai"], environmentVariables: ["GOOGLE_GENAI_API_KEY"],
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
llm_agents/anthropic_agent/src/anthropic_agent.ts(1 hunks)llm_agents/gemini_agent/src/gemini_agent.ts(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: build (24.x)
- GitHub Check: build (22.x)
🔇 Additional comments (2)
llm_agents/anthropic_agent/src/anthropic_agent.ts (1)
161-168: Confirmed consistent||usage for model defaults across all agentsAll TypeScript agents now use
||for model defaulting, and no??patterns remain. This change aligns with the PR’s intent and ensures uniform defaulting semantics.llm_agents/gemini_agent/src/gemini_agent.ts (1)
120-123: Consistent defaulting across all agents confirmed—LGTM• Verified that every agent implementation uses
||for model defaulting:
- llm_agents/anthropic_agent/src/anthropic_agent.ts:161
- llm_agents/openai_fetch_agent/src/openai_fetch_agent.ts:113
- llm_agents/openai_agent/src/openai_image_agent.ts:36
- llm_agents/openai_agent/src/openai_agent.ts:174
- llm_agents/gemini_agent/src/gemini_agent.ts:121
No further changes needed—approving.
Summary by CodeRabbit