@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.js
CHANGED
|
@@ -2031,6 +2031,7 @@ function AgentThreadProvider({
|
|
|
2031
2031
|
const sendMessageStreamsRef = (0, import_react7.useRef)(/* @__PURE__ */ new Map());
|
|
2032
2032
|
const chunkMessageMerger = (0, import_react7.useRef)((0, import_client_sdk3.createSimpleMessageMerger)());
|
|
2033
2033
|
const lastAgentStateCreatedAtRef = (0, import_react7.useRef)(null);
|
|
2034
|
+
const streamEndedByInterruptRef = (0, import_react7.useRef)(false);
|
|
2034
2035
|
const messageCountRef = (0, import_react7.useRef)(0);
|
|
2035
2036
|
const onToolCompletedRef = (0, import_react7.useRef)(onToolCompleted);
|
|
2036
2037
|
onToolCompletedRef.current = onToolCompleted;
|
|
@@ -2116,6 +2117,7 @@ function AgentThreadProvider({
|
|
|
2116
2117
|
let interrupt;
|
|
2117
2118
|
if (chunk.type === "interrupt") {
|
|
2118
2119
|
const rawChunk = chunk;
|
|
2120
|
+
streamEndedByInterruptRef.current = true;
|
|
2119
2121
|
interrupt = {
|
|
2120
2122
|
type: "interrupt",
|
|
2121
2123
|
id: rawChunk.id,
|
|
@@ -2143,11 +2145,12 @@ function AgentThreadProvider({
|
|
|
2143
2145
|
}
|
|
2144
2146
|
}
|
|
2145
2147
|
const updatedMessages = chunkMessageMerger.current.getMessages();
|
|
2148
|
+
const isStopSignal = interrupt !== void 0 || anyChunk.type === "message_failed";
|
|
2146
2149
|
setState((prev) => ({
|
|
2147
2150
|
...prev,
|
|
2148
2151
|
todos: todos || prev.todos,
|
|
2149
2152
|
messages: updatedMessages,
|
|
2150
|
-
isLoading: true,
|
|
2153
|
+
isLoading: isStopSignal ? false : true,
|
|
2151
2154
|
interrupts: interrupt ? [interrupt] : void 0
|
|
2152
2155
|
}));
|
|
2153
2156
|
},
|
|
@@ -2158,6 +2161,7 @@ function AgentThreadProvider({
|
|
|
2158
2161
|
if (!threadId) {
|
|
2159
2162
|
throw new Error("Thread ID is required to send messages");
|
|
2160
2163
|
}
|
|
2164
|
+
streamEndedByInterruptRef.current = false;
|
|
2161
2165
|
sendMessageStreamsRef.current.forEach((stopFn) => {
|
|
2162
2166
|
stopFn();
|
|
2163
2167
|
});
|
|
@@ -2218,9 +2222,10 @@ function AgentThreadProvider({
|
|
|
2218
2222
|
},
|
|
2219
2223
|
// Chunks handled by resumeStream
|
|
2220
2224
|
async () => {
|
|
2221
|
-
if (options.enableReturnStateWhenStreamCompleted) {
|
|
2225
|
+
if (options.enableReturnStateWhenStreamCompleted && !streamEndedByInterruptRef.current) {
|
|
2222
2226
|
await fetchAndUpdateAgentState(threadId);
|
|
2223
2227
|
}
|
|
2228
|
+
streamEndedByInterruptRef.current = false;
|
|
2224
2229
|
onStreamCompletedRef.current?.();
|
|
2225
2230
|
sendMessageStreamsRef.current.delete(userMessage.id);
|
|
2226
2231
|
},
|
|
@@ -2230,6 +2235,7 @@ function AgentThreadProvider({
|
|
|
2230
2235
|
isLoading: false,
|
|
2231
2236
|
error
|
|
2232
2237
|
}));
|
|
2238
|
+
streamEndedByInterruptRef.current = false;
|
|
2233
2239
|
sendMessageStreamsRef.current.delete(userMessage.id);
|
|
2234
2240
|
}
|
|
2235
2241
|
);
|
|
@@ -2250,9 +2256,10 @@ function AgentThreadProvider({
|
|
|
2250
2256
|
...prev,
|
|
2251
2257
|
isLoading: false
|
|
2252
2258
|
}));
|
|
2253
|
-
if (options.enableReturnStateWhenStreamCompleted) {
|
|
2259
|
+
if (options.enableReturnStateWhenStreamCompleted && !streamEndedByInterruptRef.current) {
|
|
2254
2260
|
await fetchAndUpdateAgentState(threadId);
|
|
2255
2261
|
}
|
|
2262
|
+
streamEndedByInterruptRef.current = false;
|
|
2256
2263
|
onStreamCompletedRef.current?.();
|
|
2257
2264
|
sendMessageStreamsRef.current.delete(userMessage.id);
|
|
2258
2265
|
},
|