From 53fc7acd7401a2f1a72d4236a7a46b111681c841 Mon Sep 17 00:00:00 2001 From: "nick.yi" Date: Tue, 24 Nov 2026 16:39:43 +0800 Subject: [PATCH] fix(routing): show the current user goal agent in the naive reasoner prompt The reasoner told the router to keep the existing user goal agent but never rendered its value, so the router inferred it from the visible dialog and could overwrite the goal with the agent currently handling a sub-step. Co-Authored-By: Claude Opus 5.5 --- .../BotSharp.Core/Routing/Reasoning/NaiveReasoner.cs | 3 ++- .../templates/reasoner.naive.liquid | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Infrastructure/BotSharp.Core/Routing/Reasoning/NaiveReasoner.cs b/src/Infrastructure/BotSharp.Core/Routing/Reasoning/NaiveReasoner.cs index 39e8be430..8f0865397 100644 --- a/src/Infrastructure/BotSharp.Core/Routing/Reasoning/NaiveReasoner.cs +++ b/src/Infrastructure/BotSharp.Core/Routing/Reasoning/NaiveReasoner.cs @@ -104,7 +104,8 @@ private string GetNextStepPrompt(Agent router) return render.Render(template, new Dictionary { { StateConst.EXPECTED_ACTION_AGENT, states.GetState(StateConst.EXPECTED_ACTION_AGENT) }, - { StateConst.EXPECTED_GOAL_AGENT, states.GetState(StateConst.EXPECTED_GOAL_AGENT) } + { StateConst.EXPECTED_GOAL_AGENT, states.GetState(StateConst.EXPECTED_GOAL_AGENT) }, + { StateConst.USER_GOAL_AGENT, states.GetState(StateConst.USER_GOAL_AGENT) } }); } } diff --git a/src/Infrastructure/BotSharp.Core/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/templates/reasoner.naive.liquid b/src/Infrastructure/BotSharp.Core/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/templates/reasoner.naive.liquid index 396a4449d..257b770cd 100644 --- a/src/Infrastructure/BotSharp.Core/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/templates/reasoner.naive.liquid +++ b/src/Infrastructure/BotSharp.Core/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/templates/reasoner.naive.liquid @@ -10,5 +10,5 @@ If the user only provides requested information, keep the previous next action a Expected user goal agent is {{ expected_user_goal_agent }}. {%- else -%} User goal agent is inferred from the user's active goal. -Keep the existing user goal agent unless the latest user message explicitly starts a different task or workflow. +Keep the existing user goal agent{% if user_goal_agent != blank %} ({{ user_goal_agent }}){% endif %} unless the latest user message explicitly starts a different task or workflow. {%- endif %} \ No newline at end of file