Skip to content

Commit 5a6a535

Browse files
Alix-007vincentkoc
authored andcommitted
fix(agents): fall back from tool search code under Electron
Punchcard-Session: ember-cedar-willow-tp
1 parent 980b07f commit 5a6a535

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

‎src/agents/tool-search-config.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ export function isToolSearchCodeModeSupported(): boolean {
3737
if (toolSearchCodeModeSupportedForTest !== undefined) {
3838
return toolSearchCodeModeSupportedForTest;
3939
}
40-
return process.allowedNodeEnvironmentFlags.has("--permission");
40+
// Electron advertises Node flags but process.execPath remains the host binary,
41+
// so the isolated code child cannot be launched as a plain Node process.
42+
return (
43+
typeof process.versions.electron !== "string" &&
44+
process.allowedNodeEnvironmentFlags.has("--permission")
45+
);
4146
}
4247

4348
function resolveMinCodeTimeoutMs(): number {

‎src/agents/tool-search.test.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,6 +1127,25 @@ describe("Tool Search", () => {
11271127
}
11281128
});
11291129

1130+
it("falls back to structured controls under Electron without changing Node mode", () => {
1131+
const electronDescriptor = Object.getOwnPropertyDescriptor(process.versions, "electron");
1132+
Object.defineProperty(process.versions, "electron", {
1133+
configurable: true,
1134+
value: "99.0.0",
1135+
});
1136+
try {
1137+
expect(resolveToolSearchConfig({ tools: { toolSearch: true } } as never).mode).toBe("tools");
1138+
} finally {
1139+
if (electronDescriptor) {
1140+
Object.defineProperty(process.versions, "electron", electronDescriptor);
1141+
} else {
1142+
delete (process.versions as NodeJS.ProcessVersions & { electron?: string }).electron;
1143+
}
1144+
}
1145+
1146+
expect(resolveToolSearchConfig({ tools: { toolSearch: true } } as never).mode).toBe("code");
1147+
});
1148+
11301149
it("guides structured control tools toward compact catalog calls", () => {
11311150
const tools = createToolSearchTools({ config: {} as never });
11321151
const byName = new Map(tools.map((tool) => [tool.name, tool]));

0 commit comments

Comments
 (0)