mirror of
http://192.168.0.88:13333/lywsvip/openclaw-zero-token.git
synced 2026-06-30 23:45:14 +08:00
fix(web-providers): reduce system prompt size for zero-token web providers
Web provider sessions were sending ~55k chars because: - buildAgentSystemPrompt() included all 30 sections (Tooling, Skills, Memory, OpenClaw Self-Update, Sandbox, Messaging, etc.) even though zero-token web providers have no tool exec / sandbox / messaging infra - Each web stream then appended a second copy of tool instructions with full JSON Schema serialization via JSON.stringify(tool.parameters) Changes: - Add "web" promptMode to buildAgentSystemPrompt: only Safety + Authorized Senders + Time + Runtime line (~500 chars vs ~20k+ for full mode) - attempt.ts + compact.ts: detect zero-token providers via listWebStreamApiIds() and set promptMode="web" automatically - All 11 web streams: replace verbose tool section with a simple "- tool_name: description" list; remove duplicate browser tool instructions and JSON Schema parameter serialization 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -69,7 +69,10 @@ import {
|
||||
type SkillSnapshot,
|
||||
} from "../skills.js";
|
||||
import { resolveTranscriptPolicy } from "../transcript-policy.js";
|
||||
import { getWebStreamFactory } from "../web-stream-factories.js";
|
||||
import {
|
||||
getWebStreamFactory,
|
||||
listWebStreamApiIds,
|
||||
} from "../web-stream-factories.js";
|
||||
import {
|
||||
compactWithSafetyTimeout,
|
||||
EMBEDDED_COMPACTION_TIMEOUT_MS,
|
||||
@@ -548,10 +551,12 @@ export async function compactEmbeddedPiSessionDirect(
|
||||
config: params.config,
|
||||
});
|
||||
const isDefaultAgent = sessionAgentId === defaultAgentId;
|
||||
const promptMode =
|
||||
isSubagentSessionKey(params.sessionKey) || isCronSessionKey(params.sessionKey)
|
||||
const promptMode = (() => {
|
||||
if (listWebStreamApiIds().includes(model.api as never)) {return "web";}
|
||||
return isSubagentSessionKey(params.sessionKey) || isCronSessionKey(params.sessionKey)
|
||||
? "minimal"
|
||||
: "full";
|
||||
})();
|
||||
const docsPath = await resolveOpenClawDocsPath({
|
||||
workspaceDir: effectiveWorkspace,
|
||||
argv1: process.argv[1],
|
||||
|
||||
@@ -92,7 +92,10 @@ import { sanitizeToolCallIdsForCloudCodeAssist } from "../../tool-call-id.js";
|
||||
import { resolveEffectiveToolFsWorkspaceOnly } from "../../tool-fs-policy.js";
|
||||
import { normalizeToolName } from "../../tool-policy.js";
|
||||
import { resolveTranscriptPolicy } from "../../transcript-policy.js";
|
||||
import { getWebStreamFactory } from "../../web-stream-factories.js";
|
||||
import {
|
||||
getWebStreamFactory,
|
||||
listWebStreamApiIds,
|
||||
} from "../../web-stream-factories.js";
|
||||
import { DEFAULT_BOOTSTRAP_FILENAME } from "../../workspace.js";
|
||||
import { isRunnerAbortError } from "../abort.js";
|
||||
import { appendCacheTtlTimestamp, isCacheTtlEligibleProvider } from "../cache-ttl.js";
|
||||
@@ -994,7 +997,10 @@ export async function runEmbeddedAttempt(
|
||||
},
|
||||
});
|
||||
const isDefaultAgent = sessionAgentId === defaultAgentId;
|
||||
const promptMode = resolvePromptModeForSession(params.sessionKey);
|
||||
const promptMode = (() => {
|
||||
if (listWebStreamApiIds().includes(params.model.api as never)) {return "web";}
|
||||
return resolvePromptModeForSession(params.sessionKey);
|
||||
})();
|
||||
const docsPath = await resolveOpenClawDocsPath({
|
||||
workspaceDir: effectiveWorkspace,
|
||||
argv1: process.argv[1],
|
||||
|
||||
@@ -13,8 +13,9 @@ import { sanitizeForPromptLiteral } from "./sanitize-for-prompt.js";
|
||||
* - "full": All sections (default, for main agent)
|
||||
* - "minimal": Reduced sections (Tooling, Workspace, Runtime) - used for subagents
|
||||
* - "none": Just basic identity line, no sections
|
||||
* - "web": Stripped-down prompt for zero-token web providers (no tool exec guidance)
|
||||
*/
|
||||
export type PromptMode = "full" | "minimal" | "none";
|
||||
export type PromptMode = "full" | "minimal" | "none" | "web";
|
||||
type OwnerIdDisplay = "raw" | "hash";
|
||||
|
||||
function buildSkillsSection(params: { skillsPrompt?: string; readToolName: string }) {
|
||||
@@ -378,6 +379,7 @@ export function buildAgentSystemPrompt(params: {
|
||||
const messageChannelOptions = listDeliverableMessageChannels().join("|");
|
||||
const promptMode = params.promptMode ?? "full";
|
||||
const isMinimal = promptMode === "minimal" || promptMode === "none";
|
||||
const isWeb = promptMode === "web";
|
||||
const sandboxContainerWorkspace = params.sandboxInfo?.containerWorkspaceDir?.trim();
|
||||
const sanitizedWorkspaceDir = sanitizeForPromptLiteral(params.workspaceDir);
|
||||
const sanitizedSandboxContainerWorkspace = sandboxContainerWorkspace
|
||||
@@ -419,6 +421,35 @@ export function buildAgentSystemPrompt(params: {
|
||||
return "You are a personal assistant running inside OpenClaw.";
|
||||
}
|
||||
|
||||
// For "web" mode (zero-token web providers), return a stripped-down prompt
|
||||
if (isWeb) {
|
||||
const lines: string[] = [
|
||||
"You are a personal assistant running inside OpenClaw.",
|
||||
"",
|
||||
"## Safety",
|
||||
"You have no independent goals: do not pursue self-preservation, replication, or power-seeking.",
|
||||
"",
|
||||
...(params.ownerNumbers && params.ownerNumbers.length > 0
|
||||
? [
|
||||
"## Authorized Senders",
|
||||
`Authorized senders: ${params.ownerNumbers.join(", ")}.`,
|
||||
"",
|
||||
]
|
||||
: []),
|
||||
...(params.userTimezone ? ["## Current Date & Time", `Time zone: ${params.userTimezone}`, ""] : []),
|
||||
"## Runtime",
|
||||
buildRuntimeLine(
|
||||
params.runtimeInfo,
|
||||
undefined,
|
||||
[],
|
||||
params.defaultThinkLevel,
|
||||
),
|
||||
`Reasoning: ${params.reasoningLevel ?? "off"} (hidden unless on/stream).`,
|
||||
"",
|
||||
];
|
||||
return lines.filter(Boolean).join("\n");
|
||||
}
|
||||
|
||||
const lines = [
|
||||
"You are a personal assistant running inside OpenClaw.",
|
||||
"",
|
||||
|
||||
@@ -42,27 +42,9 @@ export function createClaudeWebStreamFn(cookieOrJson: string): StreamFn {
|
||||
let toolPrompt = "";
|
||||
|
||||
if (tools.length > 0) {
|
||||
toolPrompt = "\n## Tool Use Instructions\n";
|
||||
toolPrompt +=
|
||||
"You are equipped with specialized tools to perform actions or retrieve information. " +
|
||||
'To use a tool, output a specific XML tag: <tool_call id="unique_id" name="tool_name">{"arg": "value"}</tool_call>. ' +
|
||||
"Rules for tool use:\n" +
|
||||
"1. ALWAYS think before calling a tool. Explain your reasoning inside <think> tags.\n" +
|
||||
"2. The 'id' attribute should be a unique 8-character string for each call.\n" +
|
||||
"3. Wait for the tool result before proceeding with further analysis.\n\n" +
|
||||
"### Special Instructions for Browser Tool\n" +
|
||||
"- **Profile 'openclaw' (Independent/Recommended)**: Opens a SEPARATE independent browser window. Use this for consistent, isolated sessions. Highly recommended for complex automation.\n" +
|
||||
"- Profile 'chrome' (Shared): Uses your existing Chrome tabs (requires extension). Use this if you need to access personal logins or already open tabs.\n" +
|
||||
"- **CONSISTENCY RULE**: Once you have started using a profile (or if you are switched to 'openclaw' due to connection errors), STAY with that profile for the remainder of the session. Do NOT switch back and forth as it will open redundant browser instances.\n\n" +
|
||||
"### Automation Policy\n" +
|
||||
"- DO NOT use the 'exec' tool to install secondary automation libraries like Playwright, Selenium, or Puppeteer if the 'browser' tool fails.\n" +
|
||||
"- Instead, inform the user about the connection issue or try the alternative browser profile ('openclaw').\n" +
|
||||
"- Installing automation tools via 'exec' is slow and redundant; the 'browser' tool is the primary way to interact with web content.\n\n" +
|
||||
"### Available Tools\n";
|
||||
|
||||
toolPrompt = "\n## Available Tools\n";
|
||||
for (const tool of tools) {
|
||||
toolPrompt += `#### ${tool.name}\n${tool.description}\n`;
|
||||
toolPrompt += `Parameters: ${JSON.stringify(tool.parameters)}\n\n`;
|
||||
toolPrompt += `- ${tool.name}: ${tool.description}\n`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,27 +78,9 @@ export function createDeepseekWebStreamFn(cookieOrJson: string): StreamFn {
|
||||
let systemPromptContent = systemPrompt;
|
||||
|
||||
if (tools.length > 0) {
|
||||
let toolPrompt = "\n## Tool Use Instructions\n";
|
||||
toolPrompt +=
|
||||
"You are equipped with specialized tools to perform actions or retrieve information. " +
|
||||
'To use a tool, output a specific XML tag: <tool_call id="unique_id" name="tool_name">{"arg": "value"}</tool_call>. ' +
|
||||
"Rules for tool use:\n" +
|
||||
"1. ALWAYS think before calling a tool. Explain your reasoning inside <think> tags.\n" +
|
||||
"2. The 'id' attribute should be a unique 8-character string for each call.\n" +
|
||||
"3. Output the tool call tag ONLY inside a <final> section if you are in reasoning mode.\n" +
|
||||
"4. Wait for the tool result before proceeding with further analysis.\n\n" +
|
||||
"### Special Instructions for Browser Tool\n" +
|
||||
"- **Profile 'openclaw' (Independent/Recommended)**: Opens a SEPARATE independent browser window. Use this for consistent, isolated sessions. Highly recommended for complex automation.\n" +
|
||||
"- Profile 'chrome' (Shared): Uses your existing Chrome tabs (requires extension). Use this if you need to access personal logins or already open tabs.\n" +
|
||||
"- **CONSISTENCY RULE**: Once you have started using a profile (or if you are switched to 'openclaw' due to connection errors), STAY with that profile for the remainder of the session. Do NOT switch back and forth as it will open redundant browser instances.\n\n" +
|
||||
"### Automation Policy\n" +
|
||||
"- DO NOT use the 'exec' tool to install secondary automation libraries like Playwright, Selenium, or Puppeteer if the 'browser' tool fails.\n" +
|
||||
"- Instead, inform the user about the connection issue or try the alternative browser profile ('openclaw').\n" +
|
||||
"- Installing automation tools via 'exec' is slow and redundant; the 'browser' tool is the primary way to interact with web content.\n\n" +
|
||||
"### Available Tools\n";
|
||||
let toolPrompt = "\n## Available Tools\n";
|
||||
for (const tool of tools) {
|
||||
toolPrompt += `#### ${tool.name}\n${tool.description}\n`;
|
||||
toolPrompt += `Parameters: ${JSON.stringify(tool.parameters)}\n\n`;
|
||||
toolPrompt += `- ${tool.name}: ${tool.description}\n`;
|
||||
}
|
||||
systemPromptContent += toolPrompt;
|
||||
}
|
||||
|
||||
@@ -41,27 +41,9 @@ export function createDoubaoWebStreamFn(cookieOrJson: string): StreamFn {
|
||||
let toolPrompt = "";
|
||||
|
||||
if (tools.length > 0) {
|
||||
toolPrompt = "\n## Tool Use Instructions\n";
|
||||
toolPrompt +=
|
||||
"You are equipped with specialized tools to perform actions or retrieve information. " +
|
||||
'To use a tool, output a specific XML tag: <tool_call id="unique_id" name="tool_name">{"arg": "value"}</tool_call>. ' +
|
||||
"Rules for tool use:\n" +
|
||||
"1. ALWAYS think before calling a tool. Explain your reasoning inside <think> tags.\n" +
|
||||
"2. The 'id' attribute should be a unique 8-character string for each call.\n" +
|
||||
"3. Wait for the tool result before proceeding with further analysis.\n\n" +
|
||||
"### Special Instructions for Browser Tool\n" +
|
||||
"- **Profile 'openclaw' (Independent/Recommended)**: Opens a SEPARATE independent browser window. Use this for consistent, isolated sessions. Highly recommended for complex automation.\n" +
|
||||
"- Profile 'chrome' (Shared): Uses your existing Chrome tabs (requires extension). Use this if you need to access personal logins or already open tabs.\n" +
|
||||
"- **CONSISTENCY RULE**: Once you have started using a profile (or if you are switched to 'openclaw' due to connection errors), STAY with that profile for the remainder of the session. Do NOT switch back and forth as it will open redundant browser instances.\n\n" +
|
||||
"### Automation Policy\n" +
|
||||
"- DO NOT use the 'exec' tool to install secondary automation libraries like Playwright, Selenium, or Puppeteer if the 'browser' tool fails.\n" +
|
||||
"- Instead, inform the user about the connection issue or try the alternative browser profile ('openclaw').\n" +
|
||||
"- Installing automation tools via 'exec' is slow and redundant; the 'browser' tool is the primary way to interact with web content.\n\n" +
|
||||
"### Available Tools\n";
|
||||
|
||||
toolPrompt = "\n## Available Tools\n";
|
||||
for (const tool of tools) {
|
||||
toolPrompt += `#### ${tool.name}\n${tool.description}\n`;
|
||||
toolPrompt += `Parameters: ${JSON.stringify(tool.parameters)}\n\n`;
|
||||
toolPrompt += `- ${tool.name}: ${tool.description}\n`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -67,22 +67,9 @@ function buildXmlToolPromptSection(tools: unknown[]): string {
|
||||
if (!tools || tools.length === 0) {
|
||||
return "";
|
||||
}
|
||||
let section = "\n## Tool Use Instructions\n";
|
||||
section +=
|
||||
"You are equipped with specialized tools to perform actions or retrieve information. " +
|
||||
'To use a tool, output a specific XML tag: <tool_call id="unique_id" name="tool_name">{"arg": "value"}</tool_call>. ' +
|
||||
"Rules for tool use:\n" +
|
||||
"1. ALWAYS think before calling a tool. Explain your reasoning inside <think> tags.\n" +
|
||||
"2. The 'id' attribute should be a unique 8-character string for each call.\n" +
|
||||
"3. Wait for the tool result before proceeding with further analysis.\n\n" +
|
||||
"### Automation Policy\n" +
|
||||
"- DO NOT use the 'exec' tool to install secondary automation libraries like Playwright, Selenium, or Puppeteer if the 'browser' tool fails.\n" +
|
||||
"- Instead, inform the user about the connection issue or try the alternative browser profile.\n\n" +
|
||||
"### Available Tools\n";
|
||||
|
||||
for (const tool of tools as Array<{ name?: string; description?: string; parameters?: unknown }>) {
|
||||
section += `#### ${tool.name ?? "unknown"}\n${tool.description ?? ""}\n`;
|
||||
section += `Parameters: ${JSON.stringify(tool.parameters ?? {})}\n\n`;
|
||||
let section = "\n## Available Tools\n";
|
||||
for (const tool of tools as Array<{ name?: string; description?: string }>) {
|
||||
section += `- ${tool.name ?? "unknown"}: ${tool.description ?? ""}\n`;
|
||||
}
|
||||
return section;
|
||||
}
|
||||
|
||||
@@ -42,27 +42,9 @@ export function createGlmIntlWebStreamFn(cookieOrJson: string): StreamFn {
|
||||
let toolPrompt = "";
|
||||
|
||||
if (tools.length > 0) {
|
||||
toolPrompt = "\n## Tool Use Instructions\n";
|
||||
toolPrompt +=
|
||||
"You are equipped with specialized tools to perform actions or retrieve information. " +
|
||||
'To use a tool, output a specific XML tag: <tool_call id="unique_id" name="tool_name">{"arg": "value"}</tool_call>. ' +
|
||||
"Rules for tool use:\n" +
|
||||
"1. ALWAYS think before calling a tool. Explain your reasoning inside <think> tags.\n" +
|
||||
"2. The 'id' attribute should be a unique 8-character string for each call.\n" +
|
||||
"3. Wait for the tool result before proceeding with further analysis.\n\n" +
|
||||
"### Special Instructions for Browser Tool\n" +
|
||||
"- **Profile 'openclaw' (Independent/Recommended)**: Opens a SEPARATE independent browser window. Use this for consistent, isolated sessions. Highly recommended for complex automation.\n" +
|
||||
"- Profile 'chrome' (Shared): Uses your existing Chrome tabs (requires extension). Use this if you need to access personal logins or already open tabs.\n" +
|
||||
"- **CONSISTENCY RULE**: Once you have started using a profile (or if you are switched to 'openclaw' due to connection errors), STAY with that profile for the remainder of the session. Do NOT switch back and forth as it will open redundant browser instances.\n\n" +
|
||||
"### Automation Policy\n" +
|
||||
"- DO NOT use the 'exec' tool to install secondary automation libraries like Playwright, Selenium, or Puppeteer if the 'browser' tool fails.\n" +
|
||||
"- Instead, inform the user about the connection issue or try the alternative browser profile ('openclaw').\n" +
|
||||
"- Installing automation tools via 'exec' is slow and redundant; the 'browser' tool is the primary way to interact with web content.\n\n" +
|
||||
"### Available Tools\n";
|
||||
|
||||
toolPrompt = "\n## Available Tools\n";
|
||||
for (const tool of tools) {
|
||||
toolPrompt += `#### ${tool.name}\n${tool.description}\n`;
|
||||
toolPrompt += `Parameters: ${JSON.stringify(tool.parameters)}\n\n`;
|
||||
toolPrompt += `- ${tool.name}: ${tool.description}\n`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,27 +44,9 @@ export function createZWebStreamFn(cookieOrJson: string): StreamFn {
|
||||
let toolPrompt = "";
|
||||
|
||||
if (tools.length > 0) {
|
||||
toolPrompt = "\n## Tool Use Instructions\n";
|
||||
toolPrompt +=
|
||||
"You are equipped with specialized tools to perform actions or retrieve information. " +
|
||||
'To use a tool, output a specific XML tag: <tool_call id="unique_id" name="tool_name">{"arg": "value"}</tool_call>. ' +
|
||||
"Rules for tool use:\n" +
|
||||
"1. ALWAYS think before calling a tool. Explain your reasoning inside <think> tags.\n" +
|
||||
"2. The 'id' attribute should be a unique 8-character string for each call.\n" +
|
||||
"3. Wait for the tool result before proceeding with further analysis.\n\n" +
|
||||
"### Special Instructions for Browser Tool\n" +
|
||||
"- **Profile 'openclaw' (Independent/Recommended)**: Opens a SEPARATE independent browser window. Use this for consistent, isolated sessions. Highly recommended for complex automation.\n" +
|
||||
"- Profile 'chrome' (Shared): Uses your existing Chrome tabs (requires extension). Use this if you need to access personal logins or already open tabs.\n" +
|
||||
"- **CONSISTENCY RULE**: Once you have started using a profile (or if you are switched to 'openclaw' due to connection errors), STAY with that profile for the remainder of the session. Do NOT switch back and forth as it will open redundant browser instances.\n\n" +
|
||||
"### Automation Policy\n" +
|
||||
"- DO NOT use the 'exec' tool to install secondary automation libraries like Playwright, Selenium, or Puppeteer if the 'browser' tool fails.\n" +
|
||||
"- Instead, inform the user about the connection issue or try the alternative browser profile ('openclaw').\n" +
|
||||
"- Installing automation tools via 'exec' is slow and redundant; the 'browser' tool is the primary way to interact with web content.\n\n" +
|
||||
"### Available Tools\n";
|
||||
|
||||
toolPrompt = "\n## Available Tools\n";
|
||||
for (const tool of tools) {
|
||||
toolPrompt += `#### ${tool.name}\n${tool.description}\n`;
|
||||
toolPrompt += `Parameters: ${JSON.stringify(tool.parameters)}\n\n`;
|
||||
toolPrompt += `- ${tool.name}: ${tool.description}\n`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,27 +42,9 @@ export function createGrokWebStreamFn(cookieOrJson: string): StreamFn {
|
||||
let toolPrompt = "";
|
||||
|
||||
if (tools.length > 0) {
|
||||
toolPrompt = "\n## Tool Use Instructions\n";
|
||||
toolPrompt +=
|
||||
"You are equipped with specialized tools to perform actions or retrieve information. " +
|
||||
'To use a tool, output a specific XML tag: <tool_call id="unique_id" name="tool_name">{"arg": "value"}</tool_call>. ' +
|
||||
"Rules for tool use:\n" +
|
||||
"1. ALWAYS think before calling a tool. Explain your reasoning inside <think> tags.\n" +
|
||||
"2. The 'id' attribute should be a unique 8-character string for each call.\n" +
|
||||
"3. Wait for the tool result before proceeding with further analysis.\n\n" +
|
||||
"### Special Instructions for Browser Tool\n" +
|
||||
"- **Profile 'openclaw' (Independent/Recommended)**: Opens a SEPARATE independent browser window. Use this for consistent, isolated sessions. Highly recommended for complex automation.\n" +
|
||||
"- Profile 'chrome' (Shared): Uses your existing Chrome tabs (requires extension). Use this if you need to access personal logins or already open tabs.\n" +
|
||||
"- **CONSISTENCY RULE**: Once you have started using a profile (or if you are switched to 'openclaw' due to connection errors), STAY with that profile for the remainder of the session. Do NOT switch back and forth as it will open redundant browser instances.\n\n" +
|
||||
"### Automation Policy\n" +
|
||||
"- DO NOT use the 'exec' tool to install secondary automation libraries like Playwright, Selenium, or Puppeteer if the 'browser' tool fails.\n" +
|
||||
"- Instead, inform the user about the connection issue or try the alternative browser profile ('openclaw').\n" +
|
||||
"- Installing automation tools via 'exec' is slow and redundant; the 'browser' tool is the primary way to interact with web content.\n\n" +
|
||||
"### Available Tools\n";
|
||||
|
||||
toolPrompt = "\n## Available Tools\n";
|
||||
for (const tool of tools) {
|
||||
toolPrompt += `#### ${tool.name}\n${tool.description}\n`;
|
||||
toolPrompt += `Parameters: ${JSON.stringify(tool.parameters)}\n\n`;
|
||||
toolPrompt += `- ${tool.name}: ${tool.description}\n`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,27 +42,9 @@ export function createKimiWebStreamFn(cookieOrJson: string): StreamFn {
|
||||
let toolPrompt = "";
|
||||
|
||||
if (tools.length > 0) {
|
||||
toolPrompt = "\n## Tool Use Instructions\n";
|
||||
toolPrompt +=
|
||||
"You are equipped with specialized tools to perform actions or retrieve information. " +
|
||||
'To use a tool, output a specific XML tag: <tool_call id="unique_id" name="tool_name">{"arg": "value"}</tool_call>. ' +
|
||||
"Rules for tool use:\n" +
|
||||
"1. ALWAYS think before calling a tool. Explain your reasoning inside <think> tags.\n" +
|
||||
"2. The 'id' attribute should be a unique 8-character string for each call.\n" +
|
||||
"3. Wait for the tool result before proceeding with further analysis.\n\n" +
|
||||
"### Special Instructions for Browser Tool\n" +
|
||||
"- **Profile 'openclaw' (Independent/Recommended)**: Opens a SEPARATE independent browser window. Use this for consistent, isolated sessions. Highly recommended for complex automation.\n" +
|
||||
"- Profile 'chrome' (Shared): Uses your existing Chrome tabs (requires extension). Use this if you need to access personal logins or already open tabs.\n" +
|
||||
"- **CONSISTENCY RULE**: Once you have started using a profile (or if you are switched to 'openclaw' due to connection errors), STAY with that profile for the remainder of the session. Do NOT switch back and forth as it will open redundant browser instances.\n\n" +
|
||||
"### Automation Policy\n" +
|
||||
"- DO NOT use the 'exec' tool to install secondary automation libraries like Playwright, Selenium, or Puppeteer if the 'browser' tool fails.\n" +
|
||||
"- Instead, inform the user about the connection issue or try the alternative browser profile ('openclaw').\n" +
|
||||
"- Installing automation tools via 'exec' is slow and redundant; the 'browser' tool is the primary way to interact with web content.\n\n" +
|
||||
"### Available Tools\n";
|
||||
|
||||
toolPrompt = "\n## Available Tools\n";
|
||||
for (const tool of tools) {
|
||||
toolPrompt += `#### ${tool.name}\n${tool.description}\n`;
|
||||
toolPrompt += `Parameters: ${JSON.stringify(tool.parameters)}\n\n`;
|
||||
toolPrompt += `- ${tool.name}: ${tool.description}\n`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,27 +42,9 @@ export function createQwenCNWebStreamFn(cookieOrJson: string): StreamFn {
|
||||
let toolPrompt = "";
|
||||
|
||||
if (tools.length > 0) {
|
||||
toolPrompt = "\n## Tool Use Instructions\n";
|
||||
toolPrompt +=
|
||||
"You are equipped with specialized tools to perform actions or retrieve information. " +
|
||||
'To use a tool, output a specific XML tag: <tool_call id="unique_id" name="tool_name">{"arg": "value"}</tool_call>. ' +
|
||||
"Rules for tool use:\n" +
|
||||
"1. ALWAYS think before calling a tool. Explain your reasoning inside <think> tags.\n" +
|
||||
"2. The 'id' attribute should be a unique 8-character string for each call.\n" +
|
||||
"3. Wait for the tool result before proceeding with further analysis.\n\n" +
|
||||
"### Special Instructions for Browser Tool\n" +
|
||||
"- **Profile 'openclaw' (Independent/Recommended)**: Opens a SEPARATE independent browser window. Use this for consistent, isolated sessions. Highly recommended for complex automation.\n" +
|
||||
"- Profile 'chrome' (Shared): Uses your existing Chrome tabs (requires extension). Use this if you need to access personal logins or already open tabs.\n" +
|
||||
"- **CONSISTENCY RULE**: Once you have started using a profile (or if you are switched to 'openclaw' due to connection errors), STAY with that profile for the remainder of the session. Do NOT switch back and forth as it will open redundant browser instances.\n\n" +
|
||||
"### Automation Policy\n" +
|
||||
"- DO NOT use the 'exec' tool to install secondary automation libraries like Playwright, Selenium, or Puppeteer if the 'browser' tool fails.\n" +
|
||||
"- Instead, inform the user about the connection issue or try the alternative browser profile ('openclaw').\n" +
|
||||
"- Installing automation tools via 'exec' is slow and redundant; the 'browser' tool is the primary way to interact with web content.\n\n" +
|
||||
"### Available Tools\n";
|
||||
|
||||
toolPrompt = "\n## Available Tools\n";
|
||||
for (const tool of tools) {
|
||||
toolPrompt += `#### ${tool.name}\n${tool.description}\n`;
|
||||
toolPrompt += `Parameters: ${JSON.stringify(tool.parameters)}\n\n`;
|
||||
toolPrompt += `- ${tool.name}: ${tool.description}\n`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,27 +52,9 @@ export function createQwenWebStreamFn(cookieOrJson: string): StreamFn {
|
||||
let toolPrompt = "";
|
||||
|
||||
if (tools.length > 0) {
|
||||
toolPrompt = "\n## Tool Use Instructions\n";
|
||||
toolPrompt +=
|
||||
"You are equipped with specialized tools to perform actions or retrieve information. " +
|
||||
'To use a tool, output a specific XML tag: <tool_call id="unique_id" name="tool_name">{"arg": "value"}</tool_call>. ' +
|
||||
"Rules for tool use:\n" +
|
||||
"1. ALWAYS think before calling a tool. Explain your reasoning inside <think> tags.\n" +
|
||||
"2. The 'id' attribute should be a unique 8-character string for each call.\n" +
|
||||
"3. Wait for the tool result before proceeding with further analysis.\n\n" +
|
||||
"### Special Instructions for Browser Tool\n" +
|
||||
"- **Profile 'openclaw' (Independent/Recommended)**: Opens a SEPARATE independent browser window. Use this for consistent, isolated sessions. Highly recommended for complex automation.\n" +
|
||||
"- Profile 'chrome' (Shared): Uses your existing Chrome tabs (requires extension). Use this if you need to access personal logins or already open tabs.\n" +
|
||||
"- **CONSISTENCY RULE**: Once you have started using a profile (or if you are switched to 'openclaw' due to connection errors), STAY with that profile for the remainder of the session. Do NOT switch back and forth as it will open redundant browser instances.\n\n" +
|
||||
"### Automation Policy\n" +
|
||||
"- DO NOT use the 'exec' tool to install secondary automation libraries like Playwright, Selenium, or Puppeteer if the 'browser' tool fails.\n" +
|
||||
"- Instead, inform the user about the connection issue or try the alternative browser profile ('openclaw').\n" +
|
||||
"- Installing automation tools via 'exec' is slow and redundant; the 'browser' tool is the primary way to interact with web content.\n\n" +
|
||||
"### Available Tools\n";
|
||||
|
||||
toolPrompt = "\n## Available Tools\n";
|
||||
for (const tool of tools) {
|
||||
toolPrompt += `#### ${tool.name}\n${tool.description}\n`;
|
||||
toolPrompt += `Parameters: ${JSON.stringify(tool.parameters)}\n\n`;
|
||||
toolPrompt += `- ${tool.name}: ${tool.description}\n`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,13 +37,9 @@ export function createXiaomiMimoWebStreamFn(cookieOrJson: string): StreamFn {
|
||||
|
||||
let toolPrompt = "";
|
||||
if (tools.length > 0) {
|
||||
toolPrompt = `
|
||||
|
||||
### Available Tools
|
||||
`;
|
||||
toolPrompt = "\n## Available Tools\n";
|
||||
for (const tool of tools) {
|
||||
toolPrompt += `#### ${tool.name}\n${tool.description}\n`;
|
||||
toolPrompt += `Parameters: ${JSON.stringify(tool.parameters)}\n\n`;
|
||||
toolPrompt += `- ${tool.name}: ${tool.description}\n`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user