feat: adapt duplicate toolCallId (#7733)
This commit is contained in:
parent
99fed48494
commit
9ddd30341e
3 changed files with 7 additions and 4 deletions
|
|
@ -50,7 +50,9 @@ export const selectApplyStateByToolCallId = createSelector(
|
|||
(_store: RootState, toolCallId: string) => toolCallId,
|
||||
],
|
||||
(applyStates, toolCallId) => {
|
||||
return applyStates.states.find((state) => state.toolCallId === toolCallId);
|
||||
return applyStates.states.findLast(
|
||||
(state) => state.toolCallId === toolCallId,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ export const streamResponseAfterToolCall = createAsyncThunk<
|
|||
|
||||
// Check if we should continue streaming based on tool call completion
|
||||
const history = getState().session.history;
|
||||
const assistantMessage = history.find(
|
||||
const assistantMessage = history.findLast(
|
||||
(item) =>
|
||||
item.message.role === "assistant" &&
|
||||
item.toolCallStates?.some((tc) => tc.toolCallId === toolCallId),
|
||||
|
|
|
|||
|
|
@ -66,7 +66,8 @@ export function findToolCallById(
|
|||
chatHistory: RootState["session"]["history"],
|
||||
toolCallId: string,
|
||||
): ToolCallState | undefined {
|
||||
for (const item of chatHistory) {
|
||||
for (let i = chatHistory.length - 1; i >= 0; i--) {
|
||||
const item = chatHistory[i];
|
||||
if (item.toolCallStates) {
|
||||
const toolCallState = item.toolCallStates.find(
|
||||
(state) => state.toolCallId === toolCallId,
|
||||
|
|
@ -84,7 +85,7 @@ export function findChatHistoryItemByToolCallId(
|
|||
chatHistory: RootState["session"]["history"],
|
||||
toolCallId: string,
|
||||
): ChatHistoryItemWithMessageId | undefined {
|
||||
return chatHistory.find(
|
||||
return chatHistory.findLast(
|
||||
(item) =>
|
||||
item.message.role === "tool" && item.message.toolCallId === toolCallId,
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue