Skip to content

Commit 18721a6

Browse files
author
Haiping Chen
committed
Auto restore function name in InvokeFunction.
1 parent 2582ecd commit 18721a6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/Infrastructure/BotSharp.Core/Routing/RoutingService.InvokeFunction.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,17 @@ public async Task<bool> InvokeFunction(string name, RoleDialogModel message)
99
var function = _services.GetServices<IFunctionCallback>().FirstOrDefault(x => x.Name == name);
1010
if (function == null) return false;
1111

12+
var originalFunctionName = message.FunctionName;
1213
message.FunctionName = name;
1314
message.Role = AgentRole.Function;
14-
return await function.Execute(message);
15+
var result = await function.Execute(message);
16+
17+
// restore original function name
18+
if (!message.StopCompletion)
19+
{
20+
message.FunctionName = originalFunctionName;
21+
}
22+
23+
return result;
1524
}
1625
}

0 commit comments

Comments
 (0)