fix: Handle invalid tool names better (#43)

* fix: Handle invalid tool names better

* cr
This commit is contained in:
Brace Sproul 2025-05-28 16:13:03 -07:00 • committed by GitHub
parent 0fbcaa3131
commit 81fa410f03
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 2 deletions

View file

@ -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.",

View file

@ -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 = "";