@axiom-lattice/react-sdk 2.1.100 → 2.1.102
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +10 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1936,6 +1936,7 @@ function AgentThreadProvider({
|
|
|
1936
1936
|
const sendMessageStreamsRef = useRef6(/* @__PURE__ */ new Map());
|
|
1937
1937
|
const chunkMessageMerger = useRef6(createSimpleMessageMerger2());
|
|
1938
1938
|
const lastAgentStateCreatedAtRef = useRef6(null);
|
|
1939
|
+
const streamEndedByInterruptRef = useRef6(false);
|
|
1939
1940
|
const messageCountRef = useRef6(0);
|
|
1940
1941
|
const onToolCompletedRef = useRef6(onToolCompleted);
|
|
1941
1942
|
onToolCompletedRef.current = onToolCompleted;
|
|
@@ -2021,6 +2022,7 @@ function AgentThreadProvider({
|
|
|
2021
2022
|
let interrupt;
|
|
2022
2023
|
if (chunk.type === "interrupt") {
|
|
2023
2024
|
const rawChunk = chunk;
|
|
2025
|
+
streamEndedByInterruptRef.current = true;
|
|
2024
2026
|
interrupt = {
|
|
2025
2027
|
type: "interrupt",
|
|
2026
2028
|
id: rawChunk.id,
|
|
@@ -2048,11 +2050,12 @@ function AgentThreadProvider({
|
|
|
2048
2050
|
}
|
|
2049
2051
|
}
|
|
2050
2052
|
const updatedMessages = chunkMessageMerger.current.getMessages();
|
|
2053
|
+
const isStopSignal = interrupt !== void 0 || anyChunk.type === "message_failed";
|
|
2051
2054
|
setState((prev) => ({
|
|
2052
2055
|
...prev,
|
|
2053
2056
|
todos: todos || prev.todos,
|
|
2054
2057
|
messages: updatedMessages,
|
|
2055
|
-
isLoading: true,
|
|
2058
|
+
isLoading: isStopSignal ? false : true,
|
|
2056
2059
|
interrupts: interrupt ? [interrupt] : void 0
|
|
2057
2060
|
}));
|
|
2058
2061
|
},
|
|
@@ -2063,6 +2066,7 @@ function AgentThreadProvider({
|
|
|
2063
2066
|
if (!threadId) {
|
|
2064
2067
|
throw new Error("Thread ID is required to send messages");
|
|
2065
2068
|
}
|
|
2069
|
+
streamEndedByInterruptRef.current = false;
|
|
2066
2070
|
sendMessageStreamsRef.current.forEach((stopFn) => {
|
|
2067
2071
|
stopFn();
|
|
2068
2072
|
});
|
|
@@ -2123,9 +2127,10 @@ function AgentThreadProvider({
|
|
|
2123
2127
|
},
|
|
2124
2128
|
// Chunks handled by resumeStream
|
|
2125
2129
|
async () => {
|
|
2126
|
-
if (options.enableReturnStateWhenStreamCompleted) {
|
|
2130
|
+
if (options.enableReturnStateWhenStreamCompleted && !streamEndedByInterruptRef.current) {
|
|
2127
2131
|
await fetchAndUpdateAgentState(threadId);
|
|
2128
2132
|
}
|
|
2133
|
+
streamEndedByInterruptRef.current = false;
|
|
2129
2134
|
onStreamCompletedRef.current?.();
|
|
2130
2135
|
sendMessageStreamsRef.current.delete(userMessage.id);
|
|
2131
2136
|
},
|
|
@@ -2135,6 +2140,7 @@ function AgentThreadProvider({
|
|
|
2135
2140
|
isLoading: false,
|
|
2136
2141
|
error
|
|
2137
2142
|
}));
|
|
2143
|
+
streamEndedByInterruptRef.current = false;
|
|
2138
2144
|
sendMessageStreamsRef.current.delete(userMessage.id);
|
|
2139
2145
|
}
|
|
2140
2146
|
);
|
|
@@ -2155,9 +2161,10 @@ function AgentThreadProvider({
|
|
|
2155
2161
|
...prev,
|
|
2156
2162
|
isLoading: false
|
|
2157
2163
|
}));
|
|
2158
|
-
if (options.enableReturnStateWhenStreamCompleted) {
|
|
2164
|
+
if (options.enableReturnStateWhenStreamCompleted && !streamEndedByInterruptRef.current) {
|
|
2159
2165
|
await fetchAndUpdateAgentState(threadId);
|
|
2160
2166
|
}
|
|
2167
|
+
streamEndedByInterruptRef.current = false;
|
|
2161
2168
|
onStreamCompletedRef.current?.();
|
|
2162
2169
|
sendMessageStreamsRef.current.delete(userMessage.id);
|
|
2163
2170
|
},
|