mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-25 20:05:46 -06:00
fix(agents): fall back from tool search code under Electron (#122037)
Punchcard-Session: ember-cedar-willow-tp
This commit is contained in:
@@ -37,7 +37,12 @@ export function isToolSearchCodeModeSupported(): boolean {
|
||||
if (toolSearchCodeModeSupportedForTest !== undefined) {
|
||||
return toolSearchCodeModeSupportedForTest;
|
||||
}
|
||||
return process.allowedNodeEnvironmentFlags.has("--permission");
|
||||
// Electron advertises Node flags but process.execPath remains the host binary,
|
||||
// so the isolated code child cannot be launched as a plain Node process.
|
||||
return (
|
||||
typeof process.versions.electron !== "string" &&
|
||||
process.allowedNodeEnvironmentFlags.has("--permission")
|
||||
);
|
||||
}
|
||||
|
||||
function resolveMinCodeTimeoutMs(): number {
|
||||
|
||||
@@ -1127,6 +1127,25 @@ describe("Tool Search", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("falls back to structured controls under Electron without changing Node mode", () => {
|
||||
const electronDescriptor = Object.getOwnPropertyDescriptor(process.versions, "electron");
|
||||
Object.defineProperty(process.versions, "electron", {
|
||||
configurable: true,
|
||||
value: "99.0.0",
|
||||
});
|
||||
try {
|
||||
expect(resolveToolSearchConfig({ tools: { toolSearch: true } } as never).mode).toBe("tools");
|
||||
} finally {
|
||||
if (electronDescriptor) {
|
||||
Object.defineProperty(process.versions, "electron", electronDescriptor);
|
||||
} else {
|
||||
delete (process.versions as NodeJS.ProcessVersions & { electron?: string }).electron;
|
||||
}
|
||||
}
|
||||
|
||||
expect(resolveToolSearchConfig({ tools: { toolSearch: true } } as never).mode).toBe("code");
|
||||
});
|
||||
|
||||
it("guides structured control tools toward compact catalog calls", () => {
|
||||
const tools = createToolSearchTools({ config: {} as never });
|
||||
const byName = new Map(tools.map((tool) => [tool.name, tool]));
|
||||
|
||||
Reference in New Issue
Block a user