@axiom-lattice/react-sdk 2.1.101 → 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 +8 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -2
- 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,
|
|
@@ -2159,6 +2161,7 @@ function AgentThreadProvider({
|
|
|
2159
2161
|
if (!threadId) {
|
|
2160
2162
|
throw new Error("Thread ID is required to send messages");
|
|
2161
2163
|
}
|
|
2164
|
+
streamEndedByInterruptRef.current = false;
|
|
2162
2165
|
sendMessageStreamsRef.current.forEach((stopFn) => {
|
|
2163
2166
|
stopFn();
|
|
2164
2167
|
});
|
|
@@ -2219,9 +2222,10 @@ function AgentThreadProvider({
|
|
|
2219
2222
|
},
|
|
2220
2223
|
// Chunks handled by resumeStream
|
|
2221
2224
|
async () => {
|
|
2222
|
-
if (options.enableReturnStateWhenStreamCompleted) {
|
|
2225
|
+
if (options.enableReturnStateWhenStreamCompleted && !streamEndedByInterruptRef.current) {
|
|
2223
2226
|
await fetchAndUpdateAgentState(threadId);
|
|
2224
2227
|
}
|
|
2228
|
+
streamEndedByInterruptRef.current = false;
|
|
2225
2229
|
onStreamCompletedRef.current?.();
|
|
2226
2230
|
sendMessageStreamsRef.current.delete(userMessage.id);
|
|
2227
2231
|
},
|
|
@@ -2231,6 +2235,7 @@ function AgentThreadProvider({
|
|
|
2231
2235
|
isLoading: false,
|
|
2232
2236
|
error
|
|
2233
2237
|
}));
|
|
2238
|
+
streamEndedByInterruptRef.current = false;
|
|
2234
2239
|
sendMessageStreamsRef.current.delete(userMessage.id);
|
|
2235
2240
|
}
|
|
2236
2241
|
);
|
|
@@ -2251,9 +2256,10 @@ function AgentThreadProvider({
|
|
|
2251
2256
|
...prev,
|
|
2252
2257
|
isLoading: false
|
|
2253
2258
|
}));
|
|
2254
|
-
if (options.enableReturnStateWhenStreamCompleted) {
|
|
2259
|
+
if (options.enableReturnStateWhenStreamCompleted && !streamEndedByInterruptRef.current) {
|
|
2255
2260
|
await fetchAndUpdateAgentState(threadId);
|
|
2256
2261
|
}
|
|
2262
|
+
streamEndedByInterruptRef.current = false;
|
|
2257
2263
|
onStreamCompletedRef.current?.();
|
|
2258
2264
|
sendMessageStreamsRef.current.delete(userMessage.id);
|
|
2259
2265
|
},
|