|
|
@@ -13,6 +13,7 @@ import {
|
|
|
type ModelMessage,
|
|
|
stepCountIs,
|
|
|
type StreamTextResult,
|
|
|
+ InvalidToolInputError,
|
|
|
} from "ai"
|
|
|
|
|
|
import PROMPT_INITIALIZE from "../session/prompt/initialize.txt"
|
|
|
@@ -869,7 +870,21 @@ export namespace Session {
|
|
|
messages,
|
|
|
}
|
|
|
},
|
|
|
+ async experimental_repairToolCall(input) {
|
|
|
+ if (InvalidToolInputError.isInstance(input.error)) {
|
|
|
+ return {
|
|
|
+ ...input.toolCall,
|
|
|
+ input: JSON.stringify({
|
|
|
+ tool: input.toolCall.toolName,
|
|
|
+ error: input.error.message,
|
|
|
+ }),
|
|
|
+ toolName: "invalid",
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null
|
|
|
+ },
|
|
|
maxRetries: 3,
|
|
|
+ activeTools: Object.keys(tools).filter((x) => x !== "invalid"),
|
|
|
maxOutputTokens: outputLimit,
|
|
|
abortSignal: abort.signal,
|
|
|
stopWhen: stepCountIs(1000),
|
|
|
@@ -962,6 +977,7 @@ export namespace Session {
|
|
|
if (match) {
|
|
|
const part = await updatePart({
|
|
|
...match,
|
|
|
+ tool: value.toolName,
|
|
|
state: {
|
|
|
status: "running",
|
|
|
input: value.input,
|