1
1
using BotSharp . Abstraction . Agents . Models ;
2
2
using BotSharp . Abstraction . MLTasks . Settings ;
3
+ using BotSharp . Abstraction . Routing . Models ;
3
4
using BotSharp . Abstraction . Templating ;
4
5
5
6
namespace BotSharp . Core . Routing ;
@@ -33,7 +34,7 @@ public async Task<bool> InvokeAgent(string agentId, List<RoleDialogModel> dialog
33
34
message . FunctionName = response . FunctionName ;
34
35
message . FunctionArgs = response . FunctionArgs ;
35
36
message . CurrentAgentId = agent . Id ;
36
- await InvokeFunction ( agent , message , dialogs ) ;
37
+ await InvokeFunction ( message , dialogs ) ;
37
38
}
38
39
else
39
40
{
@@ -47,7 +48,7 @@ public async Task<bool> InvokeAgent(string agentId, List<RoleDialogModel> dialog
47
48
return true ;
48
49
}
49
50
50
- private async Task < bool > InvokeFunction ( Agent agent , RoleDialogModel message , List < RoleDialogModel > dialogs )
51
+ private async Task < bool > InvokeFunction ( RoleDialogModel message , List < RoleDialogModel > dialogs )
51
52
{
52
53
// execute function
53
54
// Save states
@@ -61,9 +62,12 @@ private async Task<bool> InvokeFunction(Agent agent, RoleDialogModel message, Li
61
62
// Pass execution result to LLM to get response
62
63
if ( ! message . StopCompletion )
63
64
{
65
+ var routing = _services . GetRequiredService < RoutingContext > ( ) ;
66
+ var agentId = routing . GetCurrentAgentId ( ) ;
67
+
64
68
// Find response template
65
69
var templateService = _services . GetRequiredService < IResponseTemplateService > ( ) ;
66
- var responseTemplate = await templateService . RenderFunctionResponse ( agent . Id , message ) ;
70
+ var responseTemplate = await templateService . RenderFunctionResponse ( agentId , message ) ;
67
71
if ( ! string . IsNullOrEmpty ( responseTemplate ) )
68
72
{
69
73
dialogs . Add ( RoleDialogModel . From ( message ,
@@ -78,7 +82,7 @@ private async Task<bool> InvokeFunction(Agent agent, RoleDialogModel message, Li
78
82
content : message . Content ) ) ;
79
83
80
84
// Send to LLM
81
- await InvokeAgent ( agent . Id , dialogs ) ;
85
+ await InvokeAgent ( agentId , dialogs ) ;
82
86
}
83
87
}
84
88
else
0 commit comments