Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions apps/gateway/src/api.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -625,9 +625,16 @@ describe("e2e", () => {
// check for reasoning response - only if the provider expects reasoning output
const reasoningProvider = providers?.find(
(p: ProviderModelMapping) => p.reasoning === true,
);
) as ProviderModelMapping;
if (
(reasoningProvider as ProviderModelMapping)?.reasoningOutput !== "omit"
reasoningProvider?.reasoningOutput !== "omit" &&
!(
// only enforce reasoning content checks for openai on the responses API
(
process.env.USE_RESPONSES_API === "true" &&
reasoningProvider?.providerId === "openai"
)
)
) {
expect(json.choices[0].message).toHaveProperty("reasoning_content");
}
Expand Down Expand Up @@ -736,9 +743,16 @@ describe("e2e", () => {
// Verify reasoning content is present in unified reasoning_content field - only if the provider expects reasoning output
const reasoningProvider = providers?.find(
(p: ProviderModelMapping) => p.reasoning === true,
);
) as ProviderModelMapping;
if (
(reasoningProvider as ProviderModelMapping)?.reasoningOutput !== "omit"
reasoningProvider?.reasoningOutput !== "omit" &&
!(
// only enforce reasoning content checks for openai on the responses API
(
process.env.USE_RESPONSES_API === "true" &&
reasoningProvider?.providerId === "openai"
)
)
) {
Comment on lines 744 to 750

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Same inversion in streaming reasoning test; align gating and remove unsafe cast.

Mirror the corrected logic from the non‑streaming test so we only enforce for OpenAI when Responses API is enabled.

-      ) as ProviderModelMapping;
-      if (
-        reasoningProvider?.reasoningOutput !== "omit" &&
-        !(
-          // only enforce reasoning content checks for openai on the responses API
-          (
-            process.env.USE_RESPONSES_API === "true" &&
-            reasoningProvider?.providerId === "openai"
-          )
-        )
-      ) {
+      );
+      const useResponsesApi = process.env.USE_RESPONSES_API === "true";
+      const isOpenAI = reasoningProvider?.providerId === "openai";
+      // When using the Responses API, only enforce reasoning_content checks for OpenAI.
+      if (
+        reasoningProvider?.reasoningOutput !== "omit" &&
+        (!useResponsesApi || isOpenAI)
+      ) {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const reasoningProvider = providers?.find(
(p: ProviderModelMapping) => p.reasoning === true,
);
) as ProviderModelMapping;
if (
(reasoningProvider as ProviderModelMapping)?.reasoningOutput !== "omit"
reasoningProvider?.reasoningOutput !== "omit" &&
!(
// only enforce reasoning content checks for openai on the responses API
(
process.env.USE_RESPONSES_API === "true" &&
reasoningProvider?.providerId === "openai"
)
)
) {
const reasoningProvider = providers?.find(
(p: ProviderModelMapping) => p.reasoning === true,
);
const useResponsesApi = process.env.USE_RESPONSES_API === "true";
const isOpenAI = reasoningProvider?.providerId === "openai";
// When using the Responses API, only enforce reasoning_content checks for OpenAI.
if (
reasoningProvider?.reasoningOutput !== "omit" &&
(!useResponsesApi || isOpenAI)
) {
🤖 Prompt for AI Agents
In apps/gateway/src/api.e2e.ts around lines 744 to 756, the streaming reasoning
test uses an inverted gating condition and an unsafe cast; change the logic to
mirror the non-streaming test so reasoning content checks are enforced only when
process.env.USE_RESPONSES_API === "true" AND the selected providerId ===
"openai", and remove the unsafe "as ProviderModelMapping" cast by properly
typing or narrowing the result of providers?.find (e.g., check for undefined
before accessing properties or use a typed predicate) so the condition becomes:
if (reasoningProvider?.reasoningOutput !== "omit" &&
process.env.USE_RESPONSES_API === "true" && reasoningProvider?.providerId ===
"openai") { ... }.

const reasoningChunks = streamResult.chunks.filter(
(chunk: any) =>
Expand Down