reactbridge-sdk 0.2.17 → 0.2.19

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 CHANGED
@@ -525,6 +525,7 @@ function useReactBridge({ onIntentDetected, currentContext, onError, onSpeechSta
525
525
  let currentResponse = response;
526
526
  let toolCallCount = 0;
527
527
  const maxToolCalls = 50; // Prevent infinite loops
528
+ let previousResultResponse = null;
528
529
  while (currentToolCall && toolCallCount < maxToolCalls) {
529
530
  toolCallCount++;
530
531
  // Execute the current tool
@@ -532,6 +533,17 @@ function useReactBridge({ onIntentDetected, currentContext, onError, onSpeechSta
532
533
  // Step 3: Send tool result back to orchestrator
533
534
  if (lastRequestRef.current && currentResponse.sessionId) {
534
535
  const resultResponse = yield api.sendToolResult(currentResponse.sessionId, toolResult, lastRequestRef.current);
536
+ // Check if result is identical to previous one (prevent infinite loops on duplicate responses)
537
+ const currentResultString = JSON.stringify({
538
+ message: resultResponse.message,
539
+ toolCall: resultResponse.toolCall,
540
+ });
541
+ if (previousResultResponse === currentResultString) {
542
+ console.warn("Identical tool response detected. Exiting loop to prevent infinite loop.");
543
+ currentToolCall = null;
544
+ break;
545
+ }
546
+ previousResultResponse = currentResultString;
535
547
  // Add assistant message with tool result context
536
548
  const finalMessage = {
537
549
  id: `assistant-final-${Date.now()}-${toolCallCount}`,