SimpleChatTC:TCPending: Clear pending in unhappy paths
ie if exception raised during tool call execution and or time out occurs
This commit is contained in:
parent
313b5f6db7
commit
f7cff8232d
|
|
@ -644,6 +644,12 @@ sliding window based drop off or even before they kick in, this can help in many
|
||||||
handlers. Inturn run the calling through a setTimeout0, so that delayed/missing response
|
handlers. Inturn run the calling through a setTimeout0, so that delayed/missing response
|
||||||
situation rescuer timeout logic etal flow doesnt get messed for now.
|
situation rescuer timeout logic etal flow doesnt get messed for now.
|
||||||
|
|
||||||
|
* track tool calling and inturn maintain pending tool calls so that only still valid tool call responses
|
||||||
|
will be accepted when the asynchronous tool call response is recieved. Also take care of clearing
|
||||||
|
pending tool call tracking in unhappy paths like when exception noticied as part of tool call execution,
|
||||||
|
or if there is no response within the configured timeout period.
|
||||||
|
NOTE: Currently the logic supports only 1 pending tool call per chat session.
|
||||||
|
|
||||||
|
|
||||||
#### ToDo
|
#### ToDo
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -753,6 +753,7 @@ class SimpleChat {
|
||||||
try {
|
try {
|
||||||
return await this.me.toolsMgr.tool_call(this.chatId, toolcallid, toolname, toolargs)
|
return await this.me.toolsMgr.tool_call(this.chatId, toolcallid, toolname, toolargs)
|
||||||
} catch (/** @type {any} */error) {
|
} catch (/** @type {any} */error) {
|
||||||
|
this.me.toolsMgr.toolcallpending_found_cleared(this.chatId, toolcallid, 'SC:HandleToolCall:Exc')
|
||||||
return `Tool/Function call raised an exception:${error.name}:${error.message}`
|
return `Tool/Function call raised an exception:${error.name}:${error.message}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1213,6 +1214,7 @@ class MultiChatUI {
|
||||||
this.ui_reset_userinput(false)
|
this.ui_reset_userinput(false)
|
||||||
} else {
|
} else {
|
||||||
this.timers.toolcallResponseTimeout = setTimeout(() => {
|
this.timers.toolcallResponseTimeout = setTimeout(() => {
|
||||||
|
this.me.toolsMgr.toolcallpending_found_cleared(chat.chatId, toolCallId, 'MCUI:HandleToolRun:TimeOut')
|
||||||
chat.add(new ChatMessageEx(Roles.ToolTemp, ChatMessageEx.createToolCallResultAllInOne(toolCallId, toolname, `Tool/Function call ${toolname} taking too much time, aborting...`)))
|
chat.add(new ChatMessageEx(Roles.ToolTemp, ChatMessageEx.createToolCallResultAllInOne(toolCallId, toolname, `Tool/Function call ${toolname} taking too much time, aborting...`)))
|
||||||
this.chat_show(chat.chatId)
|
this.chat_show(chat.chatId)
|
||||||
this.ui_reset_userinput(false)
|
this.ui_reset_userinput(false)
|
||||||
|
|
|
||||||
|
|
@ -134,6 +134,7 @@ export class ToolsManager {
|
||||||
this.tc_switch[fn]["handler"](chatid, toolcallid, fn, JSON.parse(toolargs))
|
this.tc_switch[fn]["handler"](chatid, toolcallid, fn, JSON.parse(toolargs))
|
||||||
return undefined
|
return undefined
|
||||||
} catch (/** @type {any} */error) {
|
} catch (/** @type {any} */error) {
|
||||||
|
this.toolcallpending_found_cleared(chatid, toolcallid, 'ToolsManager:ToolCall:Exc')
|
||||||
return `Tool/Function call raised an exception:${error.name}:${error.message}`
|
return `Tool/Function call raised an exception:${error.name}:${error.message}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue