@@ -80,18 +80,24 @@ public async Task<bool> SendMessage(string agentId,
8080
8181 if ( agent . Type == AgentType . Routing )
8282 {
83+ await routing . Context . Push ( agent . Id , reason : "request started" , updateLazyRouting : false ) ;
84+
8385 // Check the routing mode
8486 var states = _services . GetRequiredService < IConversationStateService > ( ) ;
8587 var routingMode = states . GetState ( StateConst . ROUTING_MODE , agent . Mode ?? RoutingMode . Eager ) ;
86- await routing . Context . Push ( agent . Id , reason : "request started" , updateLazyRouting : false ) ;
88+ var lazyRoutingAgentId = states . GetState ( StateConst . LAZY_ROUTING_AGENT_ID ) ;
8789
88- if ( routingMode == RoutingMode . Lazy )
90+ if ( routingMode == RoutingMode . Lazy && ! string . IsNullOrEmpty ( lazyRoutingAgentId ) )
8991 {
90- message . CurrentAgentId = states . GetState ( StateConst . LAZY_ROUTING_AGENT_ID , message . CurrentAgentId ) ;
92+ message . CurrentAgentId = lazyRoutingAgentId ;
93+ agent = await agentService . LoadAgent ( message . CurrentAgentId ) ;
9194 await routing . Context . Push ( message . CurrentAgentId , reason : "lazy routing" , updateLazyRouting : false ) ;
95+ response = await routing . InstructDirect ( agent , message , dialogs ) ;
96+ }
97+ else
98+ {
99+ response = await routing . InstructLoop ( agent , message , dialogs ) ;
92100 }
93-
94- response = await routing . InstructLoop ( agent , message , dialogs ) ;
95101 }
96102 else
97103 {
0 commit comments