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.
- package/dist/hooks/useReactBridge.d.ts.map +1 -1
- package/dist/index.esm.js +9 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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,14 @@ 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(resultResponse);
|
|
538
|
+
if (previousResultResponse === currentResultString) {
|
|
539
|
+
console.warn("Identical tool response detected. Exiting loop to prevent infinite loop.");
|
|
540
|
+
currentToolCall = null;
|
|
541
|
+
break;
|
|
542
|
+
}
|
|
543
|
+
previousResultResponse = currentResultString;
|
|
535
544
|
// Add assistant message with tool result context
|
|
536
545
|
const finalMessage = {
|
|
537
546
|
id: `assistant-final-${Date.now()}-${toolCallCount}`,
|