Skip to content

Conversation

zubairirfan96
Copy link
Collaborator

@zubairirfan96 zubairirfan96 commented Aug 19, 2025

Summary by CodeRabbit

  • Chores

    • Patch version bumps: Core to 1.5.46 and SDK to 1.0.44. No action required.
  • Behavior changes

    • Model handling updated to better recognize newer model families (o3/o4), affecting how certain generation controls are applied.
    • Temperature and top_p are no longer sent for some response requests, which may alter output characteristics.

Copy link

coderabbitai bot commented Aug 19, 2025

Walkthrough

Reorganized model-gating constants and updated OpenAI connector request composition: introduced O3/O4 model identifiers, changed feature gating to use derived model names, removed temperature/top_p from Responses API requests, added image/document size constants, and bumped core and sdk package versions.

Changes

Cohort / File(s) Summary
Version bumps
packages/core/package.json, packages/sdk/package.json
Incremented versions: core 1.5.45 → 1.5.46; sdk 1.0.43 → 1.0.44. No other modifications.
OpenAI API constants
packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/constants.ts
Replaced absence-based constants with O3_AND_O4_MODELS and O3_AND_O4_MODELS_PATTERN; removed MODELS_WITHOUT_TEMPERATURE_SUPPORT and MODELS_WITHOUT_PRESENCE_PENALTY_SUPPORT.
Chat completions request preparation
packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ChatCompletionsApiInterface.ts
Switched imports to new constants, derive modelName via built-in prefix stripping, gate temperature/top_p/frequency/presence/stop/json-response support by O3_AND_O4_MODELS membership, retained system-message gating via updated constant; added MAX_IMAGE_SIZE and MAX_DOCUMENT_SIZE for attachments. No public signatures changed.
Responses API request composition
packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ResponsesApiInterface.ts
Removed setting temperature and top_p in request body; cleaned up unused imports/types. No public signatures changed.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Client
  participant LLMService as LLM Service
  participant OpenAI as OpenAI Connector

  Client->>LLMService: send request (params, modelEntryName)
  LLMService->>LLMService: derive modelName = stripPrefix(modelEntryName)
  alt modelName in O3_AND_O4_MODELS
    LLMService->>LLMService: skip temperature/top_p/presence/frequency/stop gating
  else
    LLMService->>LLMService: apply temperature/top_p/presence/frequency/stop
  end
  LLMService->>LLMService: determine json & system-message handling (using constants)
  LLMService->>OpenAI: prepare and send request (body without temperature/top_p for Responses API)
  OpenAI-->>LLMService: API response
  LLMService-->>Client: return processed response
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

I nibble constants, tidy the trail,
O3 and O4 hop down the vale.
Temperatures trimmed from one API's bite,
Versions stepped up, all snug and light.
A carrot cheer for code kept bright. 🥕🐇

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ResponsesApiInterface.ts (1)

846-852: Authorization bug: validateFileSize uses a hard-coded AccessCandidate ("temp")

validateFileSize fetches file metadata using AccessCandidate.agent('temp'), which can fail authorization and leaks the intended access model. Pass the actual agentId (as done in ChatCompletions) to consistently authorize reads.

Apply this diff to pass agentId and fix all call sites:

@@
-    private async validateFileSize(file: BinaryInput, maxSize: number, fileType: string): Promise<void> {
-        await file.ready();
-        const fileInfo = await file.getJsonData(AccessCandidate.agent('temp'));
+    private async validateFileSize(
+        file: BinaryInput,
+        maxSize: number,
+        fileType: string,
+        agentId: string
+    ): Promise<void> {
+        await file.ready();
+        const fileInfo = await file.getJsonData(AccessCandidate.agent(agentId));
         if (fileInfo.size > maxSize) {
             throw new Error(`${fileType} file size (${fileInfo.size} bytes) exceeds maximum allowed size of ${maxSize} bytes`);
         }
     }
@@
-            await this.validateFileSize(file, MAX_IMAGE_SIZE, 'Image');
+            await this.validateFileSize(file, MAX_IMAGE_SIZE, 'Image', agentId);
@@
-            await this.validateFileSize(file, MAX_DOCUMENT_SIZE, 'Document');
+            await this.validateFileSize(file, MAX_DOCUMENT_SIZE, 'Document', agentId);

Also applies to: 796-813, 819-841

packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ChatCompletionsApiInterface.ts (1)

87-116: Bug: system-message gating uses modelEntryName instead of derived modelName

Checks against MODELS_WITHOUT_SYSTEM_MESSAGE_SUPPORT should use the derived modelName (without prefix). Using modelEntryName can miss matches (e.g., 'smythos/o1-mini'), causing invalid system messages to be sent.

Apply this refactor to define modelName once and use it consistently:

@@
-    public async prepareRequestBody(params: TLLMPreparedParams): Promise<OpenAI.ChatCompletionCreateParams> {
-        let messages = await this.prepareMessages(params);
+    public async prepareRequestBody(params: TLLMPreparedParams): Promise<OpenAI.ChatCompletionCreateParams> {
+        let messages = await this.prepareMessages(params);
+        const modelName = params.modelEntryName?.replace(BUILT_IN_MODEL_PREFIX, '');
@@
-        if (MODELS_WITHOUT_SYSTEM_MESSAGE_SUPPORT.includes(params.modelEntryName)) {
+        if (MODELS_WITHOUT_SYSTEM_MESSAGE_SUPPORT.includes(modelName)) {
             messages = this.convertSystemMessagesToUserMessages(messages);
         }
@@
-            const supportsSystemMessages = !MODELS_WITHOUT_SYSTEM_MESSAGE_SUPPORT.includes(params.modelEntryName);
+            const supportsSystemMessages = !MODELS_WITHOUT_SYSTEM_MESSAGE_SUPPORT.includes(modelName);
@@
-        const modelName = params.modelEntryName?.replace(BUILT_IN_MODEL_PREFIX, '');
+        // modelName defined above

Also applies to: 131-135

♻️ Duplicate comments (1)
packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ChatCompletionsApiInterface.ts (1)

453-459: Nice: file size validation uses the caller’s agent for authorization

This mirrors the correct access control pattern. Please align ResponsesApiInterface the same way.

🧹 Nitpick comments (3)
packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ResponsesApiInterface.ts (1)

285-287: Model name normalization should use BUILT_IN_MODEL_PREFIX (avoid hard-coded "smythos/")

Using a literal 'smythos/' risks drift if the prefix changes. Prefer the shared BUILT_IN_MODEL_PREFIX constant for consistency with ChatCompletions.

@@
-import { SEARCH_TOOL_COSTS } from './constants';
+import { SEARCH_TOOL_COSTS } from './constants';
+import { BUILT_IN_MODEL_PREFIX } from '@sre/constants';
@@
-        const modelName = context.modelEntryName?.replace('smythos/', '');
+        const modelName = context.modelEntryName?.replace(BUILT_IN_MODEL_PREFIX, '');

Also applies to: 5-16

packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/constants.ts (1)

1-2: Centralizing O3/O4 gating is good; consider resilient detection at call sites

The explicit list is fine for now, but it risks drift as new O3/O4 variants appear. Prefer using O3_AND_O4_MODELS_PATTERN at call sites (or combining list + pattern) to future-proof gating logic.

packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ChatCompletionsApiInterface.ts (1)

132-160: Optional: Make O3/O4 gating robust with the pattern to avoid drift

Current checks rely solely on O3_AND_O4_MODELS membership. Consider augmenting with O3_AND_O4_MODELS_PATTERN to catch new variants (e.g., o3-mini, o4 family).

Example patch:

-        const modelName = params.modelEntryName?.replace(BUILT_IN_MODEL_PREFIX, '');
-        if (params?.temperature !== undefined && !O3_AND_O4_MODELS.includes(modelName)) {
+        const isO3OrO4 = O3_AND_O4_MODELS.includes(modelName) || O3_AND_O4_MODELS_PATTERN.test(modelName);
+        if (params?.temperature !== undefined && !isO3OrO4) {
             body.temperature = params.temperature;
         }
@@
-        if (params?.topP !== undefined && !O3_AND_O4_MODELS.includes(modelName)) {
+        if (params?.topP !== undefined && !isO3OrO4) {
             body.top_p = params.topP;
         }
@@
-        if (params?.frequencyPenalty !== undefined && !O3_AND_O4_MODELS.includes(modelName)) {
+        if (params?.frequencyPenalty !== undefined && !isO3OrO4) {
             body.frequency_penalty = params.frequencyPenalty;
         }
@@
-        if (params?.presencePenalty !== undefined && !O3_AND_O4_MODELS.includes(modelName)) {
+        if (params?.presencePenalty !== undefined && !isO3OrO4) {
             body.presence_penalty = params.presencePenalty;
         }
@@
-        if (params?.stopSequences?.length && !O3_AND_O4_MODELS.includes(modelName)) {
+        if (params?.stopSequences?.length && !isO3OrO4) {
             body.stop = params.stopSequences;
         }

Note: This requires importing O3_AND_O4_MODELS_PATTERN from './constants'.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

💡 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.

📥 Commits

Reviewing files that changed from the base of the PR and between a4c865a and 756b873.

📒 Files selected for processing (3)
  • packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ChatCompletionsApiInterface.ts (2 hunks)
  • packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ResponsesApiInterface.ts (1 hunks)
  • packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/constants.ts (1 hunks)
🔇 Additional comments (5)
packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ResponsesApiInterface.ts (2)

7-11: Imports cleanup and constants usage look good

Trimming LLM.types imports and centralizing SEARCH_TOOL_COSTS import improves cohesion and reduces coupling. No issues.


545-554: Confirm sampling controls (temperature/top_p) in ResponsesApiInterface

The recent change removes any setting of temperature/top_p when building the request body for openai.responses.create. If the Responses endpoint still supports these sampling parameters for non-O3/O4 models, we should re-introduce gated handling (as done in ChatCompletions).

Please:

  • Verify in the OpenAI Responses API docs whether temperature and top_p are accepted.
  • If they are supported, update prepareRequestBody in
    packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ResponsesApiInterface.ts
    (around lines 543–554) to only set those fields for models outside the O3/O4 families.

Example diff for reference:

+ import { O3_AND_O4_MODELS } from './constants';
+ import { BUILT_IN_MODEL_PREFIX } from '@sre/constants';
@@ prepareRequestBody(params) {
         const body: OpenAI.Responses.ResponseCreateParams = {
             model: params.model as string,
             input,
         };
+        // Sampling controls for models that support it (exclude O3/O4)
+        const modelName = params.modelEntryName?.replace(BUILT_IN_MODEL_PREFIX, '');
+        if (params.temperature !== undefined && !O3_AND_O4_MODELS.includes(modelName)) {
+            (body as any).temperature = params.temperature;
+        }
+        if (params.topP !== undefined && !O3_AND_O4_MODELS.includes(modelName)) {
+            (body as any).top_p = params.topP;
+        }
packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/constants.ts (1)

10-13: SEARCH_TOOL_COSTS: Simple, readable config

The prefix match strategy downstream will handle sub-variants like gpt-4o. Looks good.

packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ChatCompletionsApiInterface.ts (2)

8-10: Good import reorg and prefix normalization source

Using BUILT_IN_MODEL_PREFIX from shared constants will keep derived model name logic consistent across interfaces.


83-120: Verified: only ChatCompletionsApiInterface.ts uses MODELS_WITHOUT_SYSTEM_MESSAGE_SUPPORT.includes(params.modelEntryName)
A repository-wide search returned only the two instances already in
packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ChatCompletionsApiInterface.ts (lines 87 and 93). No other files use this gating, so no further changes are needed.

@zubairirfan96 zubairirfan96 merged commit a1bd8b8 into main Aug 20, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants