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.

πŸ› fix: remote device disabled in bot converation (#14096)

Rdmclin205b2aca92bbe
diff --git a/src/server/modules/Mecha/AgentToolsEngine/__tests__/index.test.ts b/src/server/modules/Mecha/AgentToolsEngine/__tests__/index.test.ts
index a99c3e45a15..27e4fc11399 100644
--- a/src/server/modules/Mecha/AgentToolsEngine/__tests__/index.test.ts
+++ b/src/server/modules/Mecha/AgentToolsEngine/__tests__/index.test.ts
@@ -475,6 +475,51 @@ describe('createServerAgentToolsEngine', () => {
expect(result.enabledToolIds).not.toContain(RemoteDeviceManifest.identifier);
});
+
+ it('should disable RemoteDevice in bot conversations when no device auto-activated', () => {
+ // Bot callers (Telegram/Discord/Slack) have no client-executor, so the
+ // legacy rule would auto-enable RemoteDevice, and its systemRole would
+ // hijack the Activator and tell the model to ask the user to open the
+ // desktop app β€” blocking cloud-tool discovery (e.g. Klavis Gmail).
+ const context = createMockContext();
+ const engine = createServerAgentToolsEngine(context, {
+ agentConfig: { plugins: [RemoteDeviceManifest.identifier] },
+ deviceContext: { gatewayConfigured: true },
+ isBotConversation: true,
+ model: 'gpt-4',
+ provider: 'openai',
+ });
+
+ const result = engine.generateToolsDetailed({
+ toolIds: [RemoteDeviceManifest.identifier],
+ model: 'gpt-4',
+ provider: 'openai',
+ });
+
+ expect(result.enabledToolIds).not.toContain(RemoteDeviceManifest.identifier);
+ });
+
+ it('should still enable RemoteDevice in bot conversations when a device is auto-activated', () => {
+ // When a device is bound / auto-activated for the bot topic, LocalSystem
+ // takes over the remote proxy anyway β€” so RemoteDevice stays disabled
+ // (its usual rule), not due to isBotConversation.
+ const context = createMockContext();
+ const engine = createServerAgentToolsEngine(context, {
+ agentConfig: { plugins: [RemoteDeviceManifest.identifier] },
+ deviceContext: { gatewayConfigured: true, deviceOnline: true, autoActivated: true },
+ isBotConversation: true,
+ model: 'gpt-4',
+ provider: 'openai',
+ });
+
+ const result = engine.generateToolsDetailed({
+ toolIds: [RemoteDeviceManifest.identifier],
+ model: 'gpt-4',
+ provider: 'openai',
+ });
+
+ expect(result.enabledToolIds).not.toContain(RemoteDeviceManifest.identifier);
+ });
});
describe('LocalSystem + RemoteDevice interaction', () => {
diff --git a/src/server/modules/Mecha/AgentToolsEngine/index.ts b/src/server/modules/Mecha/AgentToolsEngine/index.ts
index 4663c885348..d2c407e504b 100644
--- a/src/server/modules/Mecha/AgentToolsEngine/index.ts
+++ b/src/server/modules/Mecha/AgentToolsEngine/index.ts
@@ -183,8 +183,20 @@ export const createServerAgentToolsEngine = (
// no specific device is auto-activated yet (user must pick). When
// the caller itself can execute `executor: 'client'` tools, the
// proxy is redundant β€” local-system goes directly to the caller.
+ //
+ // Bot conversations (Telegram/Discord/Slack/…) never have a
+ // client-executor by definition, which would otherwise make
+ // RemoteDevice permanently auto-enabled there. Its systemRole
+ // tells the model to "inform the user to open their desktop
+ // application" when no device is online, overriding the
+ // Activator's own guidance and blocking discovery of cloud tools
+ // (e.g. Klavis Gmail). Keep RemoteDevice discoverable via the
+ // Activator in bot flows, but don't inject it by default.
[RemoteDeviceManifest.identifier]:
- hasDeviceProxy && !deviceContext?.autoActivated && !hasClientExecutor,
+ hasDeviceProxy &&
+ !deviceContext?.autoActivated &&
+ !hasClientExecutor &&
+ !isBotConversation,
[AgentDocumentsManifest.identifier]: hasAgentDocuments,
[WebBrowsingManifest.identifier]: isSearchEnabled,
},