mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-16 16:30:15 +01:00
🧰 fix: Unprocessed Tool Calls Edge Case (#10440)
* chore: temp. remove @librechat/agents
* 🔧 chore: update @langchain/core to version 0.3.79
* chore: update dependencies for @langchain/core and add back latest @librechat/agents
* chore: update @librechat/agents to version 3.0.11
* fix: enhance error handling for uncaught exceptions due to abort errors
* fix: standardize warning message for uncatchable abort errors
* fix: improve tool call handling in ModelEndHandler for unprocessed edge case
* fix: prevent content type mismatch in message updates and preserve args in final updates
* chore: add debug logging for client disposal in disposeClient function
This commit is contained in:
parent
09c309bc78
commit
06c060b983
7 changed files with 910 additions and 197 deletions
|
|
@ -99,6 +99,12 @@ export default function useStepHandler({
|
|||
if (!updatedContent[index]) {
|
||||
updatedContent[index] = { type: contentPart.type as AllContentTypes };
|
||||
}
|
||||
/** Prevent overwriting an existing content part with a different type */
|
||||
const existingType = (updatedContent[index]?.type as string | undefined) ?? '';
|
||||
if (existingType && !contentType.startsWith(existingType)) {
|
||||
console.warn('Content type mismatch');
|
||||
return message;
|
||||
}
|
||||
|
||||
if (
|
||||
contentType.startsWith(ContentTypes.TEXT) &&
|
||||
|
|
@ -151,12 +157,16 @@ export default function useStepHandler({
|
|||
const existingToolCall = existingContent?.tool_call;
|
||||
const toolCallArgs = (contentPart.tool_call as Agents.ToolCall).args;
|
||||
/** When args are a valid object, they are likely already invoked */
|
||||
const args =
|
||||
let args =
|
||||
finalUpdate ||
|
||||
typeof existingToolCall?.args === 'object' ||
|
||||
typeof toolCallArgs === 'object'
|
||||
? contentPart.tool_call.args
|
||||
: (existingToolCall?.args ?? '') + (toolCallArgs ?? '');
|
||||
/** Preserve previously streamed args when final update omits them */
|
||||
if (finalUpdate && args == null && existingToolCall?.args != null) {
|
||||
args = existingToolCall.args;
|
||||
}
|
||||
|
||||
const id = getNonEmptyValue([contentPart.tool_call.id, existingToolCall?.id]) ?? '';
|
||||
const name = getNonEmptyValue([contentPart.tool_call.name, existingToolCall?.name]) ?? '';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue