diff --git a/apps/open-swe/src/nodes/take-action.ts b/apps/open-swe/src/nodes/take-action.ts index 7e6e1b3a..bb86de5c 100644 --- a/apps/open-swe/src/nodes/take-action.ts +++ b/apps/open-swe/src/nodes/take-action.ts @@ -66,8 +66,22 @@ export async function takeAction( const tool = toolsMap[toolCall.name]; if (!tool) { - throw new Error(`Unknown tool: ${toolCall.name}`); + logger.error(`Unknown tool: ${toolCall.name}`); + return new Command({ + goto: "progress-plan-step", + update: { + messages: [ + new ToolMessage({ + tool_call_id: toolCall.id ?? "", + content: `Unknown tool: ${toolCall.name}`, + name: toolCall.name, + status: "error", + }), + ], + }, + }); } + if (!state.sandboxSessionId) { throw new Error( "Failed to take action: No sandbox session ID found in state.", diff --git a/apps/open-swe/src/subgraphs/planner/nodes/take-action.ts b/apps/open-swe/src/subgraphs/planner/nodes/take-action.ts index 0c0b8f5d..2789a7e6 100644 --- a/apps/open-swe/src/subgraphs/planner/nodes/take-action.ts +++ b/apps/open-swe/src/subgraphs/planner/nodes/take-action.ts @@ -33,7 +33,17 @@ export async function takeAction( const tool = toolsMap[toolCall.name]; if (!tool) { - throw new Error(`Unknown tool: ${toolCall.name}`); + logger.error(`Unknown tool: ${toolCall.name}`); + return { + plannerMessages: [ + new ToolMessage({ + tool_call_id: toolCall.id ?? "", + content: `Unknown tool: ${toolCall.name}`, + name: toolCall.name, + status: "error", + }), + ], + }; } let result = "";