@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.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,
@@ -2064,6 +2066,7 @@ function AgentThreadProvider({
2064
2066
  if (!threadId) {
2065
2067
  throw new Error("Thread ID is required to send messages");
2066
2068
  }
2069
+ streamEndedByInterruptRef.current = false;
2067
2070
  sendMessageStreamsRef.current.forEach((stopFn) => {
2068
2071
  stopFn();
2069
2072
  });
@@ -2124,9 +2127,10 @@ function AgentThreadProvider({
2124
2127
  },
2125
2128
  // Chunks handled by resumeStream
2126
2129
  async () => {
2127
- if (options.enableReturnStateWhenStreamCompleted) {
2130
+ if (options.enableReturnStateWhenStreamCompleted && !streamEndedByInterruptRef.current) {
2128
2131
  await fetchAndUpdateAgentState(threadId);
2129
2132
  }
2133
+ streamEndedByInterruptRef.current = false;
2130
2134
  onStreamCompletedRef.current?.();
2131
2135
  sendMessageStreamsRef.current.delete(userMessage.id);
2132
2136
  },
@@ -2136,6 +2140,7 @@ function AgentThreadProvider({
2136
2140
  isLoading: false,
2137
2141
  error
2138
2142
  }));
2143
+ streamEndedByInterruptRef.current = false;
2139
2144
  sendMessageStreamsRef.current.delete(userMessage.id);
2140
2145
  }
2141
2146
  );
@@ -2156,9 +2161,10 @@ function AgentThreadProvider({
2156
2161
  ...prev,
2157
2162
  isLoading: false
2158
2163
  }));
2159
- if (options.enableReturnStateWhenStreamCompleted) {
2164
+ if (options.enableReturnStateWhenStreamCompleted && !streamEndedByInterruptRef.current) {
2160
2165
  await fetchAndUpdateAgentState(threadId);
2161
2166
  }
2167
+ streamEndedByInterruptRef.current = false;
2162
2168
  onStreamCompletedRef.current?.();
2163
2169
  sendMessageStreamsRef.current.delete(userMessage.id);
2164
2170
  },