fix: unpack tool arguments with ** when calling registry.execute()
- SHA
2b801903e04d49107b6f5b9e75ae4dd60a857a99- Parents
-
dc9c4ca - Tree
30f445e
2b80190
2b801903e04d49107b6f5b9e75ae4dd60a857a99dc9c4ca
30f445e| Status | File | + | - |
|---|---|---|---|
| M |
src/loader/agent/loop.py
|
9 | 5 |
src/loader/agent/loop.pymodified@@ -1035,27 +1035,31 @@ class Agent: | ||
| 1035 | 1035 | )) |
| 1036 | 1036 | |
| 1037 | 1037 | # Execute the tool |
| 1038 | + is_error = False | |
| 1038 | 1039 | try: |
| 1039 | - result = await self.registry.execute(tc.name, tc.arguments) | |
| 1040 | - result_text = str(result) | |
| 1040 | + result = await self.registry.execute(tc.name, **tc.arguments) | |
| 1041 | + result_text = result.output | |
| 1042 | + is_error = result.is_error | |
| 1041 | 1043 | except ConfirmationRequired as e: |
| 1042 | 1044 | if on_confirmation: |
| 1043 | 1045 | confirmed = await on_confirmation(tc.name, e.message, e.details) |
| 1044 | 1046 | if confirmed: |
| 1045 | - result = await self.registry.execute(tc.name, tc.arguments, confirmed=True) | |
| 1046 | - result_text = str(result) | |
| 1047 | + result = await self.registry.execute(tc.name, **tc.arguments, confirmed=True) | |
| 1048 | + result_text = result.output | |
| 1049 | + is_error = result.is_error | |
| 1047 | 1050 | else: |
| 1048 | 1051 | result_text = "Tool execution cancelled by user." |
| 1049 | 1052 | else: |
| 1050 | 1053 | result_text = f"Tool requires confirmation: {e.message}" |
| 1051 | 1054 | except Exception as e: |
| 1052 | 1055 | result_text = f"Error: {e}" |
| 1056 | + is_error = True | |
| 1053 | 1057 | |
| 1054 | 1058 | await emit(AgentEvent( |
| 1055 | 1059 | type="tool_result", |
| 1056 | 1060 | content=result_text, |
| 1057 | 1061 | tool_name=tc.name, |
| 1058 | - is_error="Error:" in result_text, | |
| 1062 | + is_error=is_error, | |
| 1059 | 1063 | )) |
| 1060 | 1064 | |
| 1061 | 1065 | self.messages.append(Message( |