Skip to content

Commit 844e781

Browse files
committed
fix: preserve code mode network errors (#128054)
1 parent c3ec166 commit 844e781

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

‎src/agents/code-mode-execution.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export async function runCodeModeExec(params: {
7979
throw new ToolInputError("code mode is disabled.");
8080
}
8181
const runtime = new ToolSearchRuntime(params.ctx, toToolSearchConfig(config), {
82-
validateInput: true,
82+
prepareInput: true,
8383
});
8484
params.onRuntime?.(runtime);
8585
const bridgeDispatch = createCodeModeBridgeDispatchState();

‎src/agents/code-mode-headless.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ export async function runCodeModeScriptHeadless(params: {
219219
const swarmEnabled = false;
220220
const codeModeRunId = `cm_headless_${randomUUID()}`;
221221
const runtime = new ToolSearchRuntime(params.ctx, toToolSearchConfig(config), {
222-
validateInput: true,
222+
prepareInput: true,
223223
});
224224
const bridgeDispatch = createCodeModeBridgeDispatchState();
225225
const namespaceCatalog = runtime.namespaceEntries();

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ export class ToolSearchRuntime {
462462
constructor(
463463
private readonly ctx: ToolSearchToolContext,
464464
private readonly config: ToolSearchConfig,
465-
private readonly options: { validateInput?: boolean } = {},
465+
private readonly options: { prepareInput?: boolean; validateInput?: boolean } = {},
466466
) {}
467467

468468
search = async (query: string, options?: { limit?: number } & CatalogVisibilityOptions) => {
@@ -644,8 +644,13 @@ export class ToolSearchRuntime {
644644
return snapshot;
645645
};
646646
const validateInput = this.options.validateInput && entry.source === "openclaw";
647+
const prepareInput =
648+
this.options.prepareInput &&
649+
entry.source === "openclaw" &&
650+
"prepareBeforeToolCallParams" in entry.tool &&
651+
typeof entry.tool.prepareBeforeToolCallParams === "function";
647652
const executionTool =
648-
validateInput && !isToolWrappedWithBeforeToolCallHook(entry.tool as never)
653+
(prepareInput || validateInput) && !isToolWrappedWithBeforeToolCallHook(entry.tool as never)
649654
? wrapToolWithBeforeToolCallHook(entry.tool as never)
650655
: entry.tool;
651656
const runExecution = async () => {

0 commit comments

Comments
 (0)