Skip to content

Fix OnRoutingInstructionRevised #382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 31, 2024
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
@@ -1,3 +1,4 @@
using BotSharp.Abstraction.Infrastructures.Enums;
using BotSharp.Abstraction.Routing.Settings;

namespace BotSharp.Core.Routing.Handlers;
Expand Down Expand Up @@ -39,11 +40,8 @@ public RouteToAgentRoutingHandler(IServiceProvider services, ILogger<RouteToAgen

public async Task<bool> Handle(IRoutingService routing, FunctionCallFromLlm inst, RoleDialogModel message)
{
message.FunctionArgs = JsonSerializer.Serialize(inst);
var ret = await routing.InvokeFunction(message.FunctionName, message);

var states = _services.GetRequiredService<IConversationStateService>();
var goalAgent = states.GetState("user_goal_agent");
var goalAgent = states.GetState(StateConst.EXPECTED_GOAL_AGENT);
if (!string.IsNullOrEmpty(goalAgent) && inst.OriginalAgent != goalAgent)
{
inst.OriginalAgent = goalAgent;
Expand All @@ -53,6 +51,9 @@ await hook.OnRoutingInstructionRevised(inst, message)
);
}

message.FunctionArgs = JsonSerializer.Serialize(inst);
var ret = await routing.InvokeFunction(message.FunctionName, message);

var agentId = routing.Context.GetCurrentAgentId();

// Update next action agent's name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ public async Task OnRoutingInstructionRevised(FunctionCallFromLlm instruct, Role
{
var conversationId = _state.GetConversationId();
var agent = await _agentService.LoadAgent(message.CurrentAgentId);
var log = $"Revised user goal agent to: {agent?.Name}";
var log = $"Revised user goal agent to {instruct.OriginalAgent}";

var input = new ContentLogInputModel(conversationId, message)
{
Expand Down