Skip to content

🀯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

Revert "πŸ› fix(chat): gate Gateway by model tool ability (#16531)"

Arvin Xud39334e913fe
diff --git a/src/features/ChatInput/ActionBar/Plus/index.tsx b/src/features/ChatInput/ActionBar/Plus/index.tsx
index bcfa7dc7db7..857b9fe3a10 100644
--- a/src/features/ChatInput/ActionBar/Plus/index.tsx
+++ b/src/features/ChatInput/ActionBar/Plus/index.tsx
@@ -318,7 +318,7 @@ const PlusAction = memo(() => {
chatConfigByIdSelectors.getUseModelBuiltinSearchById(agentId)(s),
chatConfigByIdSelectors.getChatConfigById(agentId)(s).disableGatewayMode,
]);
- const isGatewayModeConfigured = (disableGatewayMode ?? defaultDisableGatewayMode) !== true;
+ const isGatewayModeEnabled = (disableGatewayMode ?? defaultDisableGatewayMode) !== true;
const isMemoryEnabled = useMemoryEnabled(agentId);
const [showTypoBar, setShowTypoBar] = useChatInputStore((s) => [s.showTypoBar, s.setShowTypoBar]);
@@ -329,7 +329,6 @@ const PlusAction = memo(() => {
agentId,
);
const enableFC = useModelSupportToolUse(model, provider);
- const isGatewayModeEnabled = isGatewayModeConfigured && enableFC;
const handleOpenKnowledge = useCallback(() => {
setDropdownOpen(false);
openAttachKnowledgeModal();
@@ -387,10 +386,9 @@ const PlusAction = memo(() => {
const handleToggleGatewayMode = useCallback(
async (checked: boolean) => {
- if (!enableFC) return;
await updateAgentChatConfig({ disableGatewayMode: checked ? false : true });
},
- [enableFC, updateAgentChatConfig],
+ [updateAgentChatConfig],
);
const handleToggleParams = useCallback(() => {
@@ -459,9 +457,7 @@ const PlusAction = memo(() => {
/>
<div className="body">
<div className="title">{t('gatewayMode.cardTitle')}</div>
- <div className="desc">
- {enableFC ? t('gatewayMode.desc') : t('chatMode.agentUnsupported')}
- </div>
+ <div className="desc">{t('gatewayMode.desc')}</div>
</div>
</div>
);
@@ -612,7 +608,6 @@ const PlusAction = memo(() => {
? [
{
checked: isGatewayModeEnabled,
- disabled: !enableFC,
icon: Cloud,
key: 'gateway-mode',
label: (
diff --git a/src/store/chat/slices/agentRun/actions/__tests__/conversationLifecycle.test.ts b/src/store/chat/slices/agentRun/actions/__tests__/conversationLifecycle.test.ts
index 6c0b1871994..4a764d56a1a 100644
--- a/src/store/chat/slices/agentRun/actions/__tests__/conversationLifecycle.test.ts
+++ b/src/store/chat/slices/agentRun/actions/__tests__/conversationLifecycle.test.ts
@@ -325,39 +325,6 @@ describe('ConversationLifecycle actions', () => {
expect(result.current.executeClientAgent).toHaveBeenCalled();
});
- it('falls back to client runtime when Gateway mode is unavailable for the model', async () => {
- const { result } = renderHook(() => useChatStore());
- const executeGatewayAgentSpy = vi.fn();
- const executeClientAgentSpy = vi.fn();
-
- act(() => {
- useChatStore.setState({
- executeClientAgent: executeClientAgentSpy,
- executeGatewayAgent: executeGatewayAgentSpy,
- isGatewayModeEnabled: () => false,
- });
- });
-
- vi.spyOn(aiChatService, 'sendMessageInServer').mockResolvedValue({
- messages: [
- createMockMessage({ id: TEST_IDS.USER_MESSAGE_ID, role: 'user' }),
- createMockMessage({ id: TEST_IDS.ASSISTANT_MESSAGE_ID, role: 'assistant' }),
- ],
- topics: [],
- assistantMessageId: TEST_IDS.ASSISTANT_MESSAGE_ID,
- } as any);
-
- await act(async () => {
- await result.current.sendMessage({
- context: createTestContext(),
- message: TEST_CONTENT.USER_MESSAGE,
- });
- });
-
- expect(executeGatewayAgentSpy).not.toHaveBeenCalled();
- expect(executeClientAgentSpy).toHaveBeenCalled();
- });
-
it('should persist selected slash skills into user message content before sending', async () => {
const { result } = renderHook(() => useChatStore());
diff --git a/src/store/chat/slices/agentRun/actions/__tests__/gateway.test.ts b/src/store/chat/slices/agentRun/actions/__tests__/gateway.test.ts
index c447dca3435..3bb3a1af451 100644
--- a/src/store/chat/slices/agentRun/actions/__tests__/gateway.test.ts
+++ b/src/store/chat/slices/agentRun/actions/__tests__/gateway.test.ts
@@ -67,7 +67,6 @@ const mockRuntime = vi.hoisted(() => ({ isChatMode: false, isLocal: false }));
const mockAgentStore = vi.hoisted(() => ({
state: { activeAgentId: undefined, agentMap: {} } as any,
}));
-const mockModelAbility = vi.hoisted(() => ({ supportToolUse: true }));
vi.mock('@/const/version', async (importOriginal) => {
const actual = await importOriginal<typeof ConstVersion>();
@@ -86,12 +85,6 @@ vi.mock('@/services/electron/gatewayConnection', () => ({
vi.mock('@/store/agent', () => ({ getAgentStoreState: () => mockAgentStore.state }));
vi.mock('@/store/agent/selectors', () => ({
- agentByIdSelectors: {
- getAgentModelById: (agentId: string) => (state: any) =>
- state.agentMap?.[agentId]?.model ?? 'test-model',
- getAgentModelProviderById: (agentId: string) => (state: any) =>
- state.agentMap?.[agentId]?.provider ?? 'test-provider',
- },
agentSelectors: { currentAgentWorkingDirectory: () => () => undefined },
chatConfigByIdSelectors: {
getChatConfigById: (agentId: string) => (state: any) =>
@@ -101,13 +94,6 @@ vi.mock('@/store/agent/selectors', () => ({
},
}));
-vi.mock('@/store/aiInfra', () => ({
- aiModelSelectors: {
- isModelSupportToolUse: () => () => mockModelAbility.supportToolUse,
- },
- getAiInfraStoreState: () => ({}),
-}));
-
// ─── Mock Client Factory ───
function createMockClient(): GatewayConnection['client'] & {
@@ -163,7 +149,6 @@ function createTestAction() {
describe('GatewayActionImpl', () => {
beforeEach(() => {
mockAgentStore.state = { activeAgentId: undefined, agentMap: {} };
- mockModelAbility.supportToolUse = true;
mockUserDefaultConfig.disableGatewayMode = undefined;
mockToolInterventionConfig.approvalMode = 'manual';
mockToolInterventionConfig.allowList = [];
@@ -218,27 +203,6 @@ describe('GatewayActionImpl', () => {
expect(action.isGatewayModeEnabled('agent-1')).toBe(false);
});
- it('returns false when the model does not support tool calling', () => {
- const { action } = createTestAction();
- setServerConfig({
- agentGatewayUrl: 'https://gateway.test.com',
- enableGatewayMode: true,
- });
- mockAgentStore.state = {
- activeAgentId: 'agent-1',
- agentMap: {
- 'agent-1': {
- chatConfig: {},
- model: 'gemini-3.1-flash-lite-image',
- provider: 'lobehub',
- },
- },
- };
- mockModelAbility.supportToolUse = false;
-
- expect(action.isGatewayModeEnabled('agent-1')).toBe(false);
- });
-
it('returns false when the backend does not enable Gateway mode', () => {
const { action } = createTestAction();
setServerConfig({
diff --git a/src/store/chat/slices/agentRun/actions/transports/gateway/gateway.ts b/src/store/chat/slices/agentRun/actions/transports/gateway/gateway.ts
index fad839c7540..89b97a418db 100644
--- a/src/store/chat/slices/agentRun/actions/transports/gateway/gateway.ts
+++ b/src/store/chat/slices/agentRun/actions/transports/gateway/gateway.ts
@@ -12,8 +12,7 @@ import { gatewayConnectionService } from '@/services/electron/gatewayConnection'
import { messageService } from '@/services/message';
import { topicService } from '@/services/topic';
import { getAgentStoreState } from '@/store/agent';
-import { agentByIdSelectors, chatConfigByIdSelectors } from '@/store/agent/selectors';
-import { aiModelSelectors, getAiInfraStoreState } from '@/store/aiInfra';
+import { chatConfigByIdSelectors } from '@/store/agent/selectors';
import { consumePendingTopicRepos, getPendingTopicRepos } from '@/store/chat/pendingTopicRepos';
import { topicSelectors } from '@/store/chat/selectors';
import type { ChatStore } from '@/store/chat/store';
@@ -336,24 +335,11 @@ export class GatewayActionImpl {
const defaultDisableGatewayMode = settingsSelectors.defaultAgentConfig(useUserStore.getState())
.chatConfig?.disableGatewayMode;
const disableGatewayMode = agentDisableGatewayMode ?? defaultDisableGatewayMode;
- const model = resolvedAgentId
- ? agentByIdSelectors.getAgentModelById(resolvedAgentId)(agentState)
- : undefined;
- const provider = resolvedAgentId
- ? agentByIdSelectors.getAgentModelProviderById(resolvedAgentId)(agentState)
- : undefined;
- // Example: Nano Banana supports image output but not function calling; Gateway would
- // inject agent/tools context and run the wrong runtime instead of normal image output.
- const supportToolUse =
- !!model &&
- !!provider &&
- aiModelSelectors.isModelSupportToolUse(model, provider)(getAiInfraStoreState());
return (
!!serverConfig?.agentGatewayUrl &&
!!serverConfig.enableGatewayMode &&
- disableGatewayMode !== true &&
- supportToolUse
+ disableGatewayMode !== true
);
};