tenseleyflow/loader / 7466f7b

Browse files

fix: use skip_confirmation flag for re-execution after confirmation (match main tool loop)

Authored by espadonne
SHA
7466f7b823ce3f7748da1df24aa843d6263120a8
Parents
2b80190
Tree
d0b5e5e

1 changed file

StatusFile+-
M src/loader/agent/loop.py 25 4
src/loader/agent/loop.pymodified
@@ -1041,16 +1041,37 @@ class Agent:
10411041
                         result_text = result.output
10421042
                         is_error = result.is_error
10431043
                     except ConfirmationRequired as e:
1044
+                        # Emit confirmation event
1045
+                        await emit(AgentEvent(
1046
+                            type="confirmation",
1047
+                            tool_name=e.tool_name,
1048
+                            confirm_message=e.message,
1049
+                            confirm_details=e.details,
1050
+                        ))
10441051
                         if on_confirmation:
10451052
                             confirmed = await on_confirmation(tc.name, e.message, e.details)
10461053
                             if confirmed:
1047
-                                result = await self.registry.execute(tc.name, **tc.arguments, confirmed=True)
1048
-                                result_text = result.output
1049
-                                is_error = result.is_error
1054
+                                # Re-execute with skip_confirmation
1055
+                                old_skip = self.registry.skip_confirmation
1056
+                                self.registry.skip_confirmation = True
1057
+                                try:
1058
+                                    result = await self.registry.execute(tc.name, **tc.arguments)
1059
+                                    result_text = result.output
1060
+                                    is_error = result.is_error
1061
+                                finally:
1062
+                                    self.registry.skip_confirmation = old_skip
10501063
                             else:
10511064
                                 result_text = "Tool execution cancelled by user."
10521065
                         else:
1053
-                            result_text = f"Tool requires confirmation: {e.message}"
1066
+                            # No callback - auto-confirm for extracted tool calls
1067
+                            old_skip = self.registry.skip_confirmation
1068
+                            self.registry.skip_confirmation = True
1069
+                            try:
1070
+                                result = await self.registry.execute(tc.name, **tc.arguments)
1071
+                                result_text = result.output
1072
+                                is_error = result.is_error
1073
+                            finally:
1074
+                                self.registry.skip_confirmation = old_skip
10541075
                     except Exception as e:
10551076
                         result_text = f"Error: {e}"
10561077
                         is_error = True