Skip to content

fix: honor responses API toggle for native tools - #822

Open
ChyiYaqing wants to merge 1 commit into
mattermost:masterfrom
ChyiYaqing:fix/openai-compatible
Open

fix: honor responses API toggle for native tools#822
ChyiYaqing wants to merge 1 commit into
mattermost:masterfrom
ChyiYaqing:fix/openai-compatible

Conversation

@ChyiYaqing

@ChyiYaqing ChyiYaqing commented Jun 11, 2026

Copy link
Copy Markdown

Summary

Fixes OpenAI Compatible and Azure services with Use Responses API disabled still routing through /v1/responses when an agent had stale native tool configuration.

  • Treat OpenAI-compatible/Azure Use Responses API=false as a hard limit for native-tool-triggered Responses API routing.
  • Filter stale native tools out when constructing the Bifrost LLM config.
  • Prevent native web search request options from re-enabling Responses API for those services.
  • Clear hidden native tool selections in both the Agents UI and legacy System Console bot form when the selected service does not support native tools.

Validation:

  • go test ./bifrost -run 'Test(NativeToolsForService|NewFromServiceConfig(OpenAIForcesResponsesAPI|FiltersNativeTools|FiltersNativeToolsWhenResponsesAPIDisabled)|ShouldUseResponsesAPI)'
  • go test ./bots -run 'TestHasNativeWebSearchEnabled'
  • npm --prefix webapp run check-types
  • npm --prefix webapp run lint -- --no-cache

Note: full go test ./bifrost ./bots leaves existing TestEnvProxyRouting failing in this environment because the request is not tunneled through the configured proxy; ./bots passes.

Ticket Link

NONE

Screenshots

NONE

Release Note

Fixed OpenAI Compatible and Azure services with Responses API disabled still routing through the Responses API when agents had stale native tool configuration.

Summary by CodeRabbit

Release Notes

Bug Fixes

  • Native web search and tools now properly validate LLM service API compatibility before enabling, preventing activation on unsupported services
  • Improved validation logic to automatically clear incompatible tool settings when switching between services

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds unified gating logic across backend and frontend to ensure native tools cannot be automatically enabled for OpenAI-compatible and Azure services unless the Responses API is explicitly configured. The changes enforce this constraint at the service configuration, bot method, and UI levels, with supporting tests.

Changes

Native tools gating on Responses API

Layer / File(s) Summary
Responses API provider capability check
bifrost/bifrost.go
New providerCanAutoUseResponsesAPI helper determines whether a provider can auto-select Responses API, constraining OpenAI/Azure to explicit useResponsesAPI flag. Updates shouldUseResponsesAPI to use this as an early gate before native-tool checks.
Service config native tools filtering
bifrost/config.go, bifrost/config_test.go
New helpers serviceAllowsNativeTools and nativeToolsForService gate native tools on Responses API usage for OpenAI-compatible and Azure services. Updates NewFromServiceConfig to use these helpers. Tests validate filtering across service types with and without Responses API enabled.
Bot HasNativeWebSearchEnabled Responses API enforcement
bots/bot.go, bots/bots_test.go
Guard in HasNativeWebSearchEnabled returns false when OpenAI-compatible or Azure services do not use Responses API. Test verifies this requirement for OpenAI-compatible services.
Frontend config tab native tools support
webapp/src/components/agents/tabs/config_tab.tsx
Helpers determine service native tools support and compute defaults based on service type and useResponsesAPI. Service change handler uses dynamic defaults. Effect clears enabledNativeTools when selected service no longer supports native tools.
Frontend bot component native tools support
webapp/src/components/system_console/bot.tsx
Helper and derived state compute native tools support for selected service. Effect clears bot configuration enabledNativeTools when native tools become unsupported but are currently enabled.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

Setup Cloud Test Server

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: honor responses API toggle for native tools' is concise and directly captures the main objective of the changeset, which is to enforce the Responses API toggle as a constraint for native tool support.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
webapp/src/components/system_console/bot.tsx (1)

151-162: ⚡ Quick win

Extract duplicated serviceSupportsNativeTools helper to shared module.

This helper is duplicated between config_tab.tsx (lines 44-55) and bot.tsx (lines 151-162) with identical logic. Extracting it to a shared utility (e.g., webapp/src/utils/service_helpers.ts) would eliminate duplication and ensure the native tools support rules remain consistent across both components.

♻️ Suggested refactor

Create webapp/src/utils/service_helpers.ts:

export function serviceSupportsNativeTools(service?: { type: string; useResponsesAPI: boolean }): boolean {
    if (!service) {
        return false;
    }
    if (service.type === 'openai' || service.type === 'anthropic' || service.type === 'gemini' || service.type === 'vertex') {
        return true;
    }
    if (service.type === 'openaicompatible' || service.type === 'azure') {
        return service.useResponsesAPI;
    }
    return false;
}

Then import in both files:

+import {serviceSupportsNativeTools} from '`@/utils/service_helpers`';
-
-function serviceSupportsNativeTools(service?: LLMService): boolean {
-    if (!service) {
-        return false;
-    }
-    if (service.type === 'openai' || service.type === 'anthropic' || service.type === 'gemini' || service.type === 'vertex') {
-        return true;
-    }
-    if (service.type === 'openaicompatible' || service.type === 'azure') {
-        return service.useResponsesAPI;
-    }
-    return false;
-}
🤖 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 `@webapp/src/components/system_console/bot.tsx` around lines 151 - 162, The
function serviceSupportsNativeTools is duplicated in the config_tab.tsx and
bot.tsx components; extract it into a single shared utility (e.g., a new module)
and have both components import and call that single exported function. Move the
existing implementation (including the checks for types
'openai','anthropic','gemini','vertex' and the conditional return for
'openaicompatible'/'azure' based on useResponsesAPI) into the new exported
serviceSupportsNativeTools helper, remove the duplicate definitions from both
components, and update their imports to reference the new helper.
🤖 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.

Nitpick comments:
In `@webapp/src/components/system_console/bot.tsx`:
- Around line 151-162: The function serviceSupportsNativeTools is duplicated in
the config_tab.tsx and bot.tsx components; extract it into a single shared
utility (e.g., a new module) and have both components import and call that
single exported function. Move the existing implementation (including the checks
for types 'openai','anthropic','gemini','vertex' and the conditional return for
'openaicompatible'/'azure' based on useResponsesAPI) into the new exported
serviceSupportsNativeTools helper, remove the duplicate definitions from both
components, and update their imports to reference the new helper.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 8ea23f89-f00a-4481-a635-82b8f95e51ca

📥 Commits

Reviewing files that changed from the base of the PR and between 248ac62 and 2e7a93b.

📒 Files selected for processing (8)
  • bifrost/bifrost.go
  • bifrost/bifrost_test.go
  • bifrost/config.go
  • bifrost/config_test.go
  • bots/bot.go
  • bots/bots_test.go
  • webapp/src/components/agents/tabs/config_tab.tsx
  • webapp/src/components/system_console/bot.tsx

@mattermost-build

Copy link
Copy Markdown
Collaborator

This PR has been automatically labelled "stale" because it hasn't had recent activity.
A core team member will check in on the status of the PR to help with questions.
Thank you for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants