reactbridge-sdk 0.2.17 → 0.2.18

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.
@@ -1 +1 @@
1
- {"version":3,"file":"useReactBridge.d.ts","sourceRoot":"","sources":["../../src/hooks/useReactBridge.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,qBAAqB,EACrB,oBAAoB,EAIrB,MAAM,UAAU,CAAC;AAElB,wBAAgB,cAAc,CAAC,EAC7B,gBAAgB,EAChB,cAAc,EACd,OAAO,EACP,aAAa,EACb,WAAW,EACX,YAAY,EACZ,eAAe,GAChB,EAAE,qBAAqB,GAAG,oBAAoB,CAmR9C"}
1
+ {"version":3,"file":"useReactBridge.d.ts","sourceRoot":"","sources":["../../src/hooks/useReactBridge.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,qBAAqB,EACrB,oBAAoB,EAIrB,MAAM,UAAU,CAAC;AAElB,wBAAgB,cAAc,CAAC,EAC7B,gBAAgB,EAChB,cAAc,EACd,OAAO,EACP,aAAa,EACb,WAAW,EACX,YAAY,EACZ,eAAe,GAChB,EAAE,qBAAqB,GAAG,oBAAoB,CA6R9C"}
package/dist/index.esm.js CHANGED
@@ -523,6 +523,7 @@ function useReactBridge({ onIntentDetected, currentContext, onError, onSpeechSta
523
523
  let currentResponse = response;
524
524
  let toolCallCount = 0;
525
525
  const maxToolCalls = 50; // Prevent infinite loops
526
+ let previousResultResponse = null;
526
527
  while (currentToolCall && toolCallCount < maxToolCalls) {
527
528
  toolCallCount++;
528
529
  // Execute the current tool
@@ -530,6 +531,14 @@ function useReactBridge({ onIntentDetected, currentContext, onError, onSpeechSta
530
531
  // Step 3: Send tool result back to orchestrator
531
532
  if (lastRequestRef.current && currentResponse.sessionId) {
532
533
  const resultResponse = yield api.sendToolResult(currentResponse.sessionId, toolResult, lastRequestRef.current);
534
+ // Check if result is identical to previous one (prevent infinite loops on duplicate responses)
535
+ const currentResultString = JSON.stringify(resultResponse);
536
+ if (previousResultResponse === currentResultString) {
537
+ console.warn("Identical tool response detected. Exiting loop to prevent infinite loop.");
538
+ currentToolCall = null;
539
+ break;
540
+ }
541
+ previousResultResponse = currentResultString;
533
542
  // Add assistant message with tool result context
534
543
  const finalMessage = {
535
544
  id: `assistant-final-${Date.now()}-${toolCallCount}`,