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(agent): steer weak models to agent-browser and stop redundant device activation (#16817)

YuTengjing530e973f7fee
diff --git a/apps/server/src/services/aiAgent/index.ts b/apps/server/src/services/aiAgent/index.ts
index 2768cf69aaf..4b1bb243255 100644
--- a/apps/server/src/services/aiAgent/index.ts
+++ b/apps/server/src/services/aiAgent/index.ts
@@ -2826,7 +2826,7 @@ export class AiAgentService {
if (canUseDevice && toolManifestMap[RemoteDeviceManifest.identifier]) {
toolManifestMap[RemoteDeviceManifest.identifier] = {
...toolManifestMap[RemoteDeviceManifest.identifier],
- systemRole: generateSystemPrompt(onlineDevices),
+ systemRole: generateSystemPrompt(onlineDevices, activeDeviceId),
};
}
diff --git a/packages/builtin-skills/src/agent-browser/index.ts b/packages/builtin-skills/src/agent-browser/index.ts
index fd91a123450..712f8cdbcd8 100644
--- a/packages/builtin-skills/src/agent-browser/index.ts
+++ b/packages/builtin-skills/src/agent-browser/index.ts
@@ -8,7 +8,10 @@ export const AgentBrowserSkill: BuiltinSkill = {
avatar: `data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMiIgaGVpZ2h0PSIzMiIgdmlld0JveD0iMCAwIDQ4IDQ4Ij48ZyBmaWxsPSJub25lIj48cGF0aCBmaWxsPSIjOGZiZmZhIiBkPSJNMjQgNDYuNWMtNy40MDEgMC0xMi41OTMtLjI3OC0xNS44NjQtLjU0NGMtMy4yODgtLjI2Ny01LjgyNS0yLjgwNC02LjA5Mi02LjA5MkMxLjc3OCAzNi41OTMgMS41IDMxLjQwMSAxLjUgMjRzLjI3OC0xMi41OTMuNTQ0LTE1Ljg2NGMuMjY3LTMuMjg4IDIuODA0LTUuODI1IDYuMDkyLTYuMDkyQzExLjQwNyAxLjc3OCAxNi41OTkgMS41IDI0IDEuNXMxMi41OTMuMjc4IDE1Ljg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jUwNSAwIDAgMCAxLjExNSAzLjM1MmwuMjQ4LjEyN2MyLjA1NCAxLjA0NSA0LjIxOCAyLjE0NyA1Ljg3NiAzLjY0Yy0xLjY1OCAxLjQ5Mi0zLjgyMSAyLjU5My01Ljg3NSAzLjYzOWwtLjI1LjEyN2EyLjUwNSAyLjUwNSAwIDAgMC0xLjExNCAzLjM1MWEyLjQ5NiAyLjQ5NiAwIDAgMCAzLjM1NyAxLjExN00yNiAzMy41YTIuNSAyLjUgMCAwIDAgMCA1aDEwYTIuNSAyLjUgMCAwIDAgMC01eiIvPjwvZz48L3N2Zz4=`,
content: systemPrompt,
description:
- 'Browser automation CLI for AI agents (agent-browser v0.31.1). Use when tasks involve website or Electron interaction such as navigation, form filling, clicking, screenshot capture, scraping data, login flows, and end-to-end app testing.',
+ 'Browser automation CLI for AI agents (agent-browser v0.31.1). Use when tasks involve website or ' +
+ 'Electron interaction such as navigation, form filling, clicking, screenshot capture, scraping data, ' +
+ 'login flows, and end-to-end app testing. For JS-rendered or anti-bot pages (crawl returns ' +
+ 'empty body / verification page), prefer this skill over driving Chrome by hand or scripting a bypass.',
identifier: AgentBrowserIdentifier,
name: 'agent-browser',
source: 'builtin',
diff --git a/packages/builtin-tool-remote-device/src/systemRole.ts b/packages/builtin-tool-remote-device/src/systemRole.ts
index dc8dda85e64..0ef8ef02366 100644
--- a/packages/builtin-tool-remote-device/src/systemRole.ts
+++ b/packages/builtin-tool-remote-device/src/systemRole.ts
@@ -2,11 +2,15 @@ import { onlineDevicesPrompt } from '@lobechat/prompts';
import { type DeviceAttachment } from './ExecutionRuntime/types';
-export const generateSystemPrompt = (devices?: DeviceAttachment[]): string => {
+export const generateSystemPrompt = (
+ devices?: DeviceAttachment[],
+ activeDeviceId?: string,
+): string => {
const onlineDevices = devices?.filter((d) => d.online) ?? [];
const deviceSection = onlineDevicesPrompt(
onlineDevices.map((d) => ({
+ active: d.deviceId === activeDeviceId,
hostname: d.hostname,
id: d.deviceId,
lastSeen: d.lastSeen,
@@ -28,6 +32,7 @@ ${deviceSection}
</capabilities>
<guidelines>
+- A device marked \`active="true"\` is already activated for this session β€” the Local System tool already runs on it. Never call **activateDevice** for it.
- If a device is already listed above, you can activate it directly with **activateDevice** without calling **listOnlineDevices** first.
- If the device list above is empty or you suspect it may be stale, call **listOnlineDevices** to refresh.
- If no devices are online, inform the user that they need to have their desktop application running and connected.
diff --git a/packages/prompts/src/prompts/remoteDevice/index.ts b/packages/prompts/src/prompts/remoteDevice/index.ts
index 4cc41f0ad5c..29af95a8783 100644
--- a/packages/prompts/src/prompts/remoteDevice/index.ts
+++ b/packages/prompts/src/prompts/remoteDevice/index.ts
@@ -1,4 +1,6 @@
export interface DeviceItem {
+ /** Already activated for this session β€” Local System runs on it; no activation needed. */
+ active?: boolean;
/** Raw machine hostname; rendered alongside `name` when an alias differs. */
hostname?: string;
id: string;
@@ -17,6 +19,7 @@ export const devicePrompt = (device: DeviceItem) => {
attrs.push(`hostname="${device.hostname}"`);
}
attrs.push(`os="${device.os}"`);
+ if (device.active) attrs.push(`active="true"`);
if (device.scope) attrs.push(`scope="${device.scope}"`);
if (device.lastSeen) attrs.push(`last-seen="${device.lastSeen}"`);
return ` <device ${attrs.join(' ')} />`;