Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public interface IRoutingContext
string ConversationId { get; }
string MessageId { get; }
void SetMessageId(string conversationId, string messageId);
void SetMessageAgentId(string agentId);
bool IsEmpty { get; }
string IntentName { get; set; }
int AgentCount { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public async Task<bool> SendMessage(string agentId,
// Enqueue receiving agent first in case it stop completion by OnMessageReceived
var routing = _services.GetRequiredService<IRoutingService>();
routing.Context.SetMessageId(_conversationId, message.MessageId);
routing.Context.SetMessageAgentId(message.CurrentAgentId);

// Save payload in order to assign the payload before hook is invoked
if (replyMessage != null && !string.IsNullOrEmpty(replyMessage.Payload))
Expand Down
10 changes: 8 additions & 2 deletions src/Infrastructure/BotSharp.Core/Routing/RoutingContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class RoutingContext : IRoutingContext
private string[] _routerAgentIds;
private string _conversationId;
private string _messageId;
private string _messageAgentId;
private int _currentRecursionDepth = 0;
private List<RoleDialogModel> _dialogs = [];

Expand Down Expand Up @@ -60,7 +61,7 @@ public string EntryAgentId
{
get
{
return _stack.LastOrDefault() ?? string.Empty;
return _stack.LastOrDefault() ?? _messageAgentId;
}
}

Expand All @@ -70,7 +71,7 @@ public string GetCurrentAgentId()
{
if (_stack.Count == 0)
{
return string.Empty;
return _messageAgentId;
}

return _stack.Peek();
Expand Down Expand Up @@ -228,6 +229,11 @@ public void SetMessageId(string conversationId, string messageId)
_messageId = messageId;
}

public void SetMessageAgentId(string agentId)
{
_messageAgentId = agentId;
}

public int GetRecursiveCounter()
{
return _currentRecursionDepth;
Expand Down
Loading