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