diff --git a/src/lib/WebVM.svelte b/src/lib/WebVM.svelte index 27f7832..4526d3a 100644 --- a/src/lib/WebVM.svelte +++ b/src/lib/WebVM.svelte @@ -412,8 +412,8 @@ // Delay at most 3 times if(delayCount < 3) { - // TODO: Defensive check, validate and remove - debugger; + // TODO: Defensive message, validate and remove + console.warn("Identical screenshot, rate limiting"); delayCount++; // Wait some time and retry await new Promise(function(f, r) { setTimeout(f, 5000); }); @@ -557,11 +557,12 @@ break; } } - debugger; + return new Error("Error: Invalid action"); } else { - debugger; + // We can get there due to model hallucinations + return new Error("Error: Invalid tool syntax"); } } diff --git a/src/lib/anthropic.js b/src/lib/anthropic.js index e4baca1..fe06933 100644 --- a/src/lib/anthropic.js +++ b/src/lib/anthropic.js @@ -63,13 +63,24 @@ async function sendMessages(handleTool) var commandResponse = await handleTool(c.input); var responseObj = {type: "tool_result", tool_use_id: c.id }; if(commandResponse != null) - responseObj.content = commandResponse; + { + if(commandResponse instanceof Error) + { + console.warn(`Tool error: ${commandResponse.message}`); + responseObj.content = commandResponse.message; + responseObj.is_error = true; + } + else + { + responseObj.content = commandResponse; + } + } addMessageInternal("user", [responseObj]); sendMessages(handleTool); } else { - debugger; + console.warn(`Invalid response type: ${c.type}`); } } if(response.stop_reason == "end_turn")