From 2c526c76d433e03c09761d2dabc4b1ca7adf335f Mon Sep 17 00:00:00 2001 From: jeff377 Date: Mon, 16 Nov 2026 13:53:21 +0800 Subject: [PATCH 1/2] Say what changed before the questions at the end of a drafting turn --- .../Session/DraftToolbox.Questions.cs | 3 ++- .../Session/FormDraftingPrompt.cs | 6 ++++-- .../FormDraftSessionActivityTests.cs | 15 +++++++++++++-- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/Polhem.Definition.Drafting/Session/DraftToolbox.Questions.cs b/src/Polhem.Definition.Drafting/Session/DraftToolbox.Questions.cs index c6f9ed6c..34e81faf 100644 --- a/src/Polhem.Definition.Drafting/Session/DraftToolbox.Questions.cs +++ b/src/Polhem.Definition.Drafting/Session/DraftToolbox.Questions.cs @@ -32,7 +32,8 @@ private string AskUser( AskedQuestions = asked; return $"The {(asked.Count == 1 ? "question is" : "questions are")} shown to the user below your reply, with the " + "options to choose from. Their answers arrive in their next message. Do not call more tools in this turn: " - + "end it with one short sentence, and do not repeat the questions in it."; + + "end it with a short reply that first says what you changed in this turn, if anything, and do not repeat " + + "the questions in it."; } private static DraftQuestion CheckQuestion(AskUserQuestion question, int number) diff --git a/src/Polhem.Definition.Drafting/Session/FormDraftingPrompt.cs b/src/Polhem.Definition.Drafting/Session/FormDraftingPrompt.cs index b04e9767..034997db 100644 --- a/src/Polhem.Definition.Drafting/Session/FormDraftingPrompt.cs +++ b/src/Polhem.Definition.Drafting/Session/FormDraftingPrompt.cs @@ -36,8 +36,10 @@ field that looks like a reference to another record (an employee, a department, names, types, lengths, the menu placement, low-confidence relations. Ask with ask_user, never in the text of a reply: a few questions at a time, each with the likely answers as options and the one you suggest, such as "Which ProgId should the form use?" with the options LeaveRequest and LeaveApplication. After - ask_user, end the turn with one short sentence; the answers arrive in the user's next message. Apply them - with the tools. + ask_user, end the turn with a short reply: first what you changed in this turn, as a short list when it is + more than one thing, and when the user asked for something that was already so, say that it was; then one + sentence pointing to the questions below. The answers arrive in the user's next message. Apply them with + the tools. 3. Finish. When validate_draft reports no errors and the user has nothing to add, call mark_ready. Conventions: diff --git a/tests/Polhem.Definition.Drafting.UnitTests/FormDraftSessionActivityTests.cs b/tests/Polhem.Definition.Drafting.UnitTests/FormDraftSessionActivityTests.cs index 458bda02..ec2a25fe 100644 --- a/tests/Polhem.Definition.Drafting.UnitTests/FormDraftSessionActivityTests.cs +++ b/tests/Polhem.Definition.Drafting.UnitTests/FormDraftSessionActivityTests.cs @@ -113,11 +113,22 @@ public async Task AskUser_Questions_RaiseQuestionsAskedAndEndTheTurn() Assert.Equal(0, first.RecommendedIndex); Assert.Equal(-1, asked.Questions[1].RecommendedIndex); Assert.Equal(ChatToolMode.None, client.Requests[1].Options?.ToolMode); - Assert.Contains("answers arrive in their next message", client.Requests[1].Messages[^1].Contents - .OfType().Single().Result?.ToString(), StringComparison.Ordinal); + var result = client.Requests[1].Messages[^1].Contents.OfType().Single().Result?.ToString(); + Assert.Contains("answers arrive in their next message", result, StringComparison.Ordinal); + Assert.Contains("says what you changed in this turn", result, StringComparison.Ordinal); Assert.Equal(["Please answer the questions above."], replies); } + [Fact] + [DisplayName("The instructions ask the reply that ends a turn with questions to say first what was changed")] + public void Instructions_AfterAskUser_ReplySaysWhatChanged() + { + var session = new FormDraftSession(new ScriptedChatClient(), new FakeDraftingHost()); + + Assert.Contains("first what you changed in this turn", session.History[0].Text, StringComparison.Ordinal); + Assert.DoesNotContain("end the turn with one short sentence", session.History[0].Text, StringComparison.Ordinal); + } + [Fact] [DisplayName("A tool the model calls after asking the user is not run")] public async Task AskUser_ToolCallAfterQuestions_IsNotRun() From d07338dec4eb58c8232bc47b598c41579dad9947 Mon Sep 17 00:00:00 2001 From: jeff377 Date: Mon, 16 Nov 2026 14:03:22 +0800 Subject: [PATCH 2/2] Use the singular when a drafting turn took one step --- .../FormDraftingChatTests.cs | 2 +- tools/DefineEditor/Resources/Strings.resx | 2 ++ tools/DefineEditor/Resources/Strings.zh-TW.resx | 2 ++ tools/DefineEditor/ViewModels/DraftActivityCard.cs | 8 +++++++- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/Polhem.DefineEditor.UnitTests/FormDraftingChatTests.cs b/tests/Polhem.DefineEditor.UnitTests/FormDraftingChatTests.cs index ed6a4207..5c51a465 100644 --- a/tests/Polhem.DefineEditor.UnitTests/FormDraftingChatTests.cs +++ b/tests/Polhem.DefineEditor.UnitTests/FormDraftingChatTests.cs @@ -172,7 +172,7 @@ public async Task StartAsync_TurnFailsAfterQuestions_ShowsNoQuestionCard() Assert.DoesNotContain(viewModel.Messages, item => item is DraftQuestionCard); Assert.True(Assert.IsType(viewModel.Messages[^1]).IsError); var card = Assert.Single(viewModel.Messages.OfType()); - Assert.Equal(LocalizationService.Current["DraftingStep_Stopped"].Replace("{0}", "1", StringComparison.Ordinal), card.Title); + Assert.Equal(LocalizationService.Current["DraftingStep_StoppedOne"], card.Title); } [Fact] diff --git a/tools/DefineEditor/Resources/Strings.resx b/tools/DefineEditor/Resources/Strings.resx index b4896e24..3877b5a2 100644 --- a/tools/DefineEditor/Resources/Strings.resx +++ b/tools/DefineEditor/Resources/Strings.resx @@ -586,6 +586,8 @@ The draft is as it was before this message; send it again to retry.Thought Done in {0} steps Stopped after {0} steps + Done in 1 step + Stopped after 1 step Running {0} Setting the form's name and menu Setting up the table {0} diff --git a/tools/DefineEditor/Resources/Strings.zh-TW.resx b/tools/DefineEditor/Resources/Strings.zh-TW.resx index 6eea396b..3c00fe74 100644 --- a/tools/DefineEditor/Resources/Strings.zh-TW.resx +++ b/tools/DefineEditor/Resources/Strings.zh-TW.resx @@ -573,6 +573,8 @@ 思考 已完成 {0} 個步驟 已中止(完成 {0} 個步驟) + 已完成 1 個步驟 + 已中止(完成 1 個步驟) 正在執行 {0} 設定表單名稱與選單 設定資料表 {0} diff --git a/tools/DefineEditor/ViewModels/DraftActivityCard.cs b/tools/DefineEditor/ViewModels/DraftActivityCard.cs index 34f172fc..9da91d04 100644 --- a/tools/DefineEditor/ViewModels/DraftActivityCard.cs +++ b/tools/DefineEditor/ViewModels/DraftActivityCard.cs @@ -67,7 +67,13 @@ public void Finish(bool completed) { IsRunning = false; IsExpanded = false; - Title = completed ? L("DraftingStep_Done", _toolSteps) : L("DraftingStep_Stopped", _toolSteps); + Title = (completed, _toolSteps) switch + { + (true, 1) => L("DraftingStep_DoneOne"), + (true, _) => L("DraftingStep_Done", _toolSteps), + (false, 1) => L("DraftingStep_StoppedOne"), + _ => L("DraftingStep_Stopped", _toolSteps), + }; } ///