From 6bae23359360d49973a237d2e4872d89016d5b37 Mon Sep 17 00:00:00 2001 From: Nikola Kukrika Date: Tue, 24 Feb 2026 17:58:22 +0100 Subject: [PATCH 01/17] First implementation --- .../Agent/Interaction/AgentTask.Codeunit.al | 13 +++ .../Internal/AgentTaskImpl.Codeunit.al | 10 +++ src/Tools/AI Test Toolkit/app.json | 7 ++ .../src/Agent/AgentTaskLog.Table.al | 79 +++++++++++++++++ .../src/Agent/AgentTestContext.Codeunit.al | 37 ++++++++ .../Agent/AgentTestContextImpl.Codeunit.al | 85 +++++++++++++++++++ .../src/Agent/AgentTestSuite.TableExt.al | 21 +++++ .../src/TestSuite/AITTestMethodLine.Table.al | 1 - .../src/TestSuite/AITTestSuiteMgt.Codeunit.al | 6 ++ 9 files changed, 258 insertions(+), 1 deletion(-) create mode 100644 src/Tools/AI Test Toolkit/src/Agent/AgentTaskLog.Table.al create mode 100644 src/Tools/AI Test Toolkit/src/Agent/AgentTestContext.Codeunit.al create mode 100644 src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al create mode 100644 src/Tools/AI Test Toolkit/src/Agent/AgentTestSuite.TableExt.al diff --git a/src/System Application/App/Agent/Interaction/AgentTask.Codeunit.al b/src/System Application/App/Agent/Interaction/AgentTask.Codeunit.al index 04b239563f..add1a99049 100644 --- a/src/System Application/App/Agent/Interaction/AgentTask.Codeunit.al +++ b/src/System Application/App/Agent/Interaction/AgentTask.Codeunit.al @@ -136,6 +136,19 @@ codeunit 4303 "Agent Task" exit(AgentTaskImpl.IsTaskStopped(AgentTask)); end; + /// + /// Gets the total Copilot credits consumed by the agent task. + /// + /// The agent task to get consumed credits for. + /// The total Copilot credits consumed by the agent task. + procedure GetConsumedCredits(var AgentTask: Record "Agent Task"): Decimal + var + AgentTaskImpl: Codeunit "Agent Task Impl."; + begin + FeatureAccessManagement.AgentTaskManagementPreviewEnabled(true); + exit(AgentTaskImpl.GetConsumedCredits(AgentTask)); + end; + var FeatureAccessManagement: Codeunit "Feature Access Management"; diff --git a/src/System Application/App/Agent/Interaction/Internal/AgentTaskImpl.Codeunit.al b/src/System Application/App/Agent/Interaction/Internal/AgentTaskImpl.Codeunit.al index b8efb0818a..16f0ec7dd0 100644 --- a/src/System Application/App/Agent/Interaction/Internal/AgentTaskImpl.Codeunit.al +++ b/src/System Application/App/Agent/Interaction/Internal/AgentTaskImpl.Codeunit.al @@ -7,6 +7,7 @@ namespace System.Agents; using System.Agents.Troubleshooting; using System.Environment; +using System.Environment.Consumption; using System.Integration; codeunit 4300 "Agent Task Impl." @@ -152,6 +153,15 @@ codeunit 4300 "Agent Task Impl." exit((AgentTask.Status = AgentTask.Status::"Stopped by User") or (AgentTask.Status = AgentTask.Status::"Stopped by System")); end; + procedure GetConsumedCredits(var AgentTask: Record "Agent Task"): Decimal + var + UserAIConsumptionData: Record "User AI Consumption Data"; + begin + UserAIConsumptionData.SetRange("Agent Task Id", AgentTask.ID); + UserAIConsumptionData.CalcSums("Copilot Credits"); + exit(UserAIConsumptionData."Copilot Credits"); + end; + internal procedure TryGetAgentRecordFromTaskId(TaskId: Integer; var Agent: Record Agent): Boolean var AgentTask: Record "Agent Task"; diff --git a/src/Tools/AI Test Toolkit/app.json b/src/Tools/AI Test Toolkit/app.json index 13d4929911..18178425d1 100644 --- a/src/Tools/AI Test Toolkit/app.json +++ b/src/Tools/AI Test Toolkit/app.json @@ -26,6 +26,13 @@ "version": "28.0.0.0" } ], + "internalsVisibleTo": [ + { + "id": "5afe217e-507a-40b4-9aa5-f4325b6e8230", + "name": "Agent Test Library", + "publisher": "Microsoft" + } + ], "screenshots": [], "platform": "28.0.0.0", "idRanges": [ diff --git a/src/Tools/AI Test Toolkit/src/Agent/AgentTaskLog.Table.al b/src/Tools/AI Test Toolkit/src/Agent/AgentTaskLog.Table.al new file mode 100644 index 0000000000..6ffb9a6791 --- /dev/null +++ b/src/Tools/AI Test Toolkit/src/Agent/AgentTaskLog.Table.al @@ -0,0 +1,79 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ + +namespace System.TestTools.AITestToolkit; + +table 149050 "Agent Task Log" +{ + Caption = 'AI Agent Task Log'; + DataClassification = SystemMetadata; + Extensible = true; + Access = Public; + ReplicateData = false; + InherentEntitlements = RIMDX; + InherentPermissions = RIMDX; + + fields + { + field(1; "Entry No."; Integer) + { + Caption = 'Entry No.'; + AutoIncrement = true; + ToolTip = 'Specifies the Log Entry No..'; + } + field(2; "Test Suite Code"; Code[100]) + { + Caption = 'Eval Suite Code'; + NotBlank = true; + TableRelation = "AIT Test Suite"; + ToolTip = 'Specifies the Eval Suite Code.'; + } + field(3; "Test Method Line No."; Integer) + { + Caption = 'Line No.'; + ToolTip = 'Specifies the Test Method Line No.'; + } + field(10; Status; Option) + { + Caption = 'Status'; + OptionMembers = Success,Error; + ToolTip = 'Specifies the status of the iteration.'; + } + field(11; Operation; Text[100]) + { + Caption = 'Operation'; + ToolTip = 'Specifies the operation.'; + } + field(13; Version; Integer) + { + Caption = 'Version'; + ToolTip = 'Specifies the Version No. of the eval run.'; + } + field(17; "Procedure Name"; Text[128]) + { + Caption = 'Procedure Name'; + DataClassification = CustomerContent; + ToolTip = 'Specifies the name of the procedure being executed.'; + } + field(5000; "Agent Task ID"; BigInteger) + { + Caption = 'Agent Task ID'; + NotBlank = true; + ToolTip = 'Specifies the Agent Task ID.'; + } + } + + keys + { + key(Key1; "Entry No.") + { + Clustered = true; + } + key(Key2; "Test Suite Code", Version, "Test Method Line No.", "Agent Task ID", Operation, "Procedure Name") + { + IncludedFields = Status; + } + } +} diff --git a/src/Tools/AI Test Toolkit/src/Agent/AgentTestContext.Codeunit.al b/src/Tools/AI Test Toolkit/src/Agent/AgentTestContext.Codeunit.al new file mode 100644 index 0000000000..65dbecd6a3 --- /dev/null +++ b/src/Tools/AI Test Toolkit/src/Agent/AgentTestContext.Codeunit.al @@ -0,0 +1,37 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ + +namespace System.Agents; + +/// +/// Exposes Agent specific functionality that can be used by the AI tests. +/// +codeunit 149048 "Agent Test Context" +{ + SingleInstance = true; + InherentEntitlements = X; + InherentPermissions = X; + + /// + /// Gets the agent that is used by the test suite. + /// + /// The user security ID of the agent used by the test suite. If no agent is set, a null GUID is returned. + procedure GetAgentRecord(var AgentUserSecurityID: Guid) + begin + AgentTestContextImpl.GetAgentRecord(AgentUserSecurityID); + end; + + /// + /// Adds agent task to be reported as used by the test + /// + /// The id of the agent task to be added to the log. + procedure AddTaskToLog(AgentTaskId: BigInteger) + begin + AgentTestContextImpl.AddTaskToLog(AgentTaskId); + end; + + var + AgentTestContextImpl: Codeunit "Agent Test Context Impl."; +} \ No newline at end of file diff --git a/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al b/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al new file mode 100644 index 0000000000..2522798713 --- /dev/null +++ b/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al @@ -0,0 +1,85 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ + +namespace System.Agents; + +using System.TestTools.AITestToolkit; +using System.TestTools.TestRunner; + +codeunit 149049 "Agent Test Context Impl." +{ + SingleInstance = true; + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + var + GlobalAgentUserSecurityID: Guid; + AgentIsNotActiveErr: Label 'Agent %1 set on suite %2 is not active.', Comment = '%1 = Agent ID, %2 = Suite Code'; + + procedure GetAgentRecord(var AgentUserSecurityID: Guid) + begin + AgentUserSecurityID := GlobalAgentUserSecurityID; + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Test Runner - Mgt", OnRunTestSuite, '', false, false)] + local procedure OnRunTestSuite(var TestMethodLine: Record "Test Method Line") + var + AITTestSuite: Record "AIT Test Suite"; + Agent: Codeunit Agent; + AITTestContext: Codeunit "AIT Test Context"; + begin + AITTestContext.GetAITTestSuite(AITTestSuite); + + if IsNullGuid(AITTestSuite."Agent User Security ID") then + exit; + + if not Agent.IsActive(GlobalAgentUserSecurityID) then + Error(AgentIsNotActiveErr, AITTestSuite.Code, AITTestSuite."Agent User Security ID"); + end; + + procedure AddTaskToLog(AgentTaskId: BigInteger) + begin + if not AgentTaskList.Contains(AgentTaskId) then + AgentTaskList.Add(AgentTaskId); + end; + + procedure ClearTaskLog() + begin + Clear(AgentTaskList); + end; + + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"AIT Test Suite Mgt.", OnAfterInsertAITLogEntry, '', false, false)] + local procedure InsertAgentTaskLogs(var AITLogEntry: Record "AIT Log Entry") + begin + LogAgentTasks(AITLogEntry); + end; + + local procedure LogAgentTasks(var AITLogEntry: Record "AIT Log Entry") + var + AgentTaskId: BigInteger; + begin + if AgentTaskList.Count() = 0 then + exit; + + foreach AgentTaskId in AgentTaskList do + LogAgentTask(AgentTaskId, AITLogEntry); + + ClearTaskLog(); + end; + + local procedure LogAgentTask(AgentTaskId: BigInteger; var AITLogEntry: Record "AIT Log Entry") + var + AgentTaskLog: Record "Agent Task Log"; + begin + AgentTaskLog.TransferFields(AITLogEntry, true); + AgentTaskLog."Agent Task ID" := AgentTaskId; + AgentTaskLog.Insert(); + end; + + var + AgentTaskList: List of [BigInteger]; +} \ No newline at end of file diff --git a/src/Tools/AI Test Toolkit/src/Agent/AgentTestSuite.TableExt.al b/src/Tools/AI Test Toolkit/src/Agent/AgentTestSuite.TableExt.al new file mode 100644 index 0000000000..ad15a1a18e --- /dev/null +++ b/src/Tools/AI Test Toolkit/src/Agent/AgentTestSuite.TableExt.al @@ -0,0 +1,21 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ + +namespace System.Agents; + +using System.TestTools.AITestToolkit; + +tableextension 149050 "Agent Test Suite" extends "AIT Test Suite" +{ + fields + { + field(4900; "Agent User Security ID"; Guid) + { + DataClassification = SystemMetadata; + Caption = 'Agent User Security ID'; + ToolTip = 'Specifies the agent to be used by the test suite.'; + } + } +} \ No newline at end of file diff --git a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLine.Table.al b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLine.Table.al index 93cae23b30..83c10adbb5 100644 --- a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLine.Table.al +++ b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLine.Table.al @@ -223,7 +223,6 @@ table 149032 "AIT Test Method Line" CalcFormula = sum("AIT Log Entry"."Tokens Consumed" where("Test Suite Code" = field("Test Suite Code"), "Test Method Line No." = field("Line No."), Version = field("Base Version Filter"), Operation = const('Run Procedure'), "Procedure Name" = filter(<> ''))); } } - keys { key(Key1; "Test Suite Code", "Line No.") diff --git a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuiteMgt.Codeunit.al b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuiteMgt.Codeunit.al index bcb32cf979..4a381d5e34 100644 --- a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuiteMgt.Codeunit.al +++ b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuiteMgt.Codeunit.al @@ -397,6 +397,7 @@ codeunit 149034 "AIT Test Suite Mgt." AITLogEntry."No. of Turns Passed" := AITTestRunIteration.GetNumberOfTurnsPassedForLastTestMethodLine(); AITLogEntry."Test Method Line Accuracy" := AITTestRunIteration.GetAccuracyForLastTestMethodLine(); AITLogEntry.Insert(true); + OnAfterInsertAITLogEntry(AITLogEntry); Commit(); AITTestRunIteration.AddToNoOfLogEntriesInserted(); @@ -535,6 +536,11 @@ codeunit 149034 "AIT Test Suite Mgt." DownloadFromStream(ResultsInStream, DownloadResultsLbl, '', 'xlsx', FilenameTxt); end; + [InternalEvent(false, false)] + local procedure OnAfterInsertAITLogEntry(var AITLogEntry: Record "AIT Log Entry") + begin + end; + [EventSubscriber(ObjectType::Table, Database::"AIT Test Suite", OnBeforeDeleteEvent, '', false, false)] local procedure DeleteLinesOnDeleteAITTestSuite(var Rec: Record "AIT Test Suite"; RunTrigger: Boolean) var From 8d7dc56c1ad5a5e618fe1ec1cd52e7494af27173 Mon Sep 17 00:00:00 2001 From: Nikola Kukrika Date: Wed, 25 Feb 2026 20:52:22 +0100 Subject: [PATCH 02/17] Implementing the copilot credits, agent tasks and fixing libraries --- .../Agent/Interaction/AgentTask.Codeunit.al | 7 +- .../AgentTaskMessageBuilder.Codeunit.al | 2 +- .../Internal/AgentTaskImpl.Codeunit.al | 5 +- .../Internal/AgentTaskList.Page.al | 18 ++ .../AgentTaskMsgBuilderImpl.Codeunit.al | 8 +- .../App/Agent/Setup/AgentImpl.Codeunit.al | 7 +- .../src/API/AITLogEntryAPI.Page.al | 16 ++ .../src/API/AITTestMethodLinesAPI.Page.al | 27 ++ .../src/Agent/AgentTaskLog.Table.al | 14 ++ .../src/Agent/AgentTestContext.Codeunit.al | 2 +- .../Agent/AgentTestContextImpl.Codeunit.al | 237 +++++++++++++++++- .../src/Agent/AgentTestSuite.TableExt.al | 4 +- .../src/Logs/AITLogEntries.Page.al | 29 +++ .../src/Logs/AITRunHistory.Codeunit.al | 5 + .../src/Logs/AITRunHistory.Page.al | 42 ++++ .../src/Logs/AITRunHistory.Table.al | 24 ++ .../Logs/AITTestMethodLinesCompare.Page.al | 11 + .../src/Logs/AITTestSuiteCompare.Page.al | 11 + .../src/TestSuite/AITTestMethodLine.Table.al | 5 + .../src/TestSuite/AITTestMethodLines.Page.al | 46 +++- .../src/TestSuite/AITTestSuite.Page.al | 29 +++ .../src/TestSuite/AITTestSuiteMgt.Codeunit.al | 2 + 22 files changed, 533 insertions(+), 18 deletions(-) diff --git a/src/System Application/App/Agent/Interaction/AgentTask.Codeunit.al b/src/System Application/App/Agent/Interaction/AgentTask.Codeunit.al index add1a99049..99509811bf 100644 --- a/src/System Application/App/Agent/Interaction/AgentTask.Codeunit.al +++ b/src/System Application/App/Agent/Interaction/AgentTask.Codeunit.al @@ -139,14 +139,13 @@ codeunit 4303 "Agent Task" /// /// Gets the total Copilot credits consumed by the agent task. /// - /// The agent task to get consumed credits for. + /// The ID of the agent task to get consumed credits for. /// The total Copilot credits consumed by the agent task. - procedure GetConsumedCredits(var AgentTask: Record "Agent Task"): Decimal + procedure GetCopilotCreditsConsumed(AgentTaskID: BigInteger): Decimal var AgentTaskImpl: Codeunit "Agent Task Impl."; begin - FeatureAccessManagement.AgentTaskManagementPreviewEnabled(true); - exit(AgentTaskImpl.GetConsumedCredits(AgentTask)); + exit(AgentTaskImpl.GetCopilotCreditsConsumed(AgentTaskID)); end; var diff --git a/src/System Application/App/Agent/Interaction/AgentTaskMessageBuilder.Codeunit.al b/src/System Application/App/Agent/Interaction/AgentTaskMessageBuilder.Codeunit.al index bfe8c8b893..e158072389 100644 --- a/src/System Application/App/Agent/Interaction/AgentTaskMessageBuilder.Codeunit.al +++ b/src/System Application/App/Agent/Interaction/AgentTaskMessageBuilder.Codeunit.al @@ -207,7 +207,7 @@ codeunit 4316 "Agent Task Message Builder" /// /// The file to attach. /// This instance of the Agent Task Message Builder. - procedure AddAttachment(AgentTaskFile: Record "Agent Task File"): codeunit "Agent Task Message Builder" + procedure AddAttachment(var AgentTaskFile: Record "Agent Task File"): codeunit "Agent Task Message Builder" begin FeatureAccessManagement.AgentTaskManagementPreviewEnabled(true); AgentTaskMsgBuilderImpl.AddAttachment(AgentTaskFile); diff --git a/src/System Application/App/Agent/Interaction/Internal/AgentTaskImpl.Codeunit.al b/src/System Application/App/Agent/Interaction/Internal/AgentTaskImpl.Codeunit.al index 16f0ec7dd0..d3c254c99d 100644 --- a/src/System Application/App/Agent/Interaction/Internal/AgentTaskImpl.Codeunit.al +++ b/src/System Application/App/Agent/Interaction/Internal/AgentTaskImpl.Codeunit.al @@ -153,10 +153,13 @@ codeunit 4300 "Agent Task Impl." exit((AgentTask.Status = AgentTask.Status::"Stopped by User") or (AgentTask.Status = AgentTask.Status::"Stopped by System")); end; - procedure GetConsumedCredits(var AgentTask: Record "Agent Task"): Decimal + procedure GetCopilotCreditsConsumed(AgentTaskID: BigInteger): Decimal var + AgentTask: Record "Agent Task"; UserAIConsumptionData: Record "User AI Consumption Data"; begin + if not AgentTask.Get(AgentTaskID) then + exit(0); UserAIConsumptionData.SetRange("Agent Task Id", AgentTask.ID); UserAIConsumptionData.CalcSums("Copilot Credits"); exit(UserAIConsumptionData."Copilot Credits"); diff --git a/src/System Application/App/Agent/Interaction/Internal/AgentTaskList.Page.al b/src/System Application/App/Agent/Interaction/Internal/AgentTaskList.Page.al index 0ed5567452..e09121a7fe 100644 --- a/src/System Application/App/Agent/Interaction/Internal/AgentTaskList.Page.al +++ b/src/System Application/App/Agent/Interaction/Internal/AgentTaskList.Page.al @@ -129,6 +129,21 @@ page 4300 "Agent Task List" { area(Processing) { + action(ShowTask) + { + ApplicationArea = All; + Caption = 'Show task'; + ToolTip = 'Show the selected task in the task pane.'; + Enabled = TaskSelected; + Image = Task; + + trigger OnAction() + var + TaskPane: Codeunit "Task Pane"; + begin + TaskPane.ShowTask(Rec); + end; + } action(ViewTaskMessage) { ApplicationArea = All; @@ -201,6 +216,9 @@ page 4300 "Agent Task List" actionref(ViewTaskLogEntries_Promoted; ViewTaskLogEntries) { } + actionref(ShowTask_Promoted; ShowTask) + { + } } } } diff --git a/src/System Application/App/Agent/Interaction/Internal/AgentTaskMsgBuilderImpl.Codeunit.al b/src/System Application/App/Agent/Interaction/Internal/AgentTaskMsgBuilderImpl.Codeunit.al index 9c32114882..960b935ce5 100644 --- a/src/System Application/App/Agent/Interaction/Internal/AgentTaskMsgBuilderImpl.Codeunit.al +++ b/src/System Application/App/Agent/Interaction/Internal/AgentTaskMsgBuilderImpl.Codeunit.al @@ -151,10 +151,12 @@ codeunit 4311 "Agent Task Msg. Builder Impl." [Scope('OnPrem')] procedure AddAttachment(var AgentTaskFile: Record "Agent Task File"): codeunit "Agent Task Msg. Builder Impl." + var + InStream: InStream; begin - TempAgentTaskFileToAttach.Copy(AgentTaskFile); - TempAgentTaskFileToAttach.ID := TempAgentTaskFileToAttach.Count() + 1; - TempAgentTaskFileToAttach.Insert(); + AgentTaskFile.CalcFields(Content); + AgentTaskFile.Content.CreateInStream(InStream); + AddAttachment(AgentTaskFile."File Name", AgentTaskFile."File MIME Type", InStream); exit(this); end; diff --git a/src/System Application/App/Agent/Setup/AgentImpl.Codeunit.al b/src/System Application/App/Agent/Setup/AgentImpl.Codeunit.al index 005c0c9a9e..965e1593ee 100644 --- a/src/System Application/App/Agent/Setup/AgentImpl.Codeunit.al +++ b/src/System Application/App/Agent/Setup/AgentImpl.Codeunit.al @@ -398,12 +398,17 @@ codeunit 4301 "Agent Impl." end; procedure SelectAgent(var Agent: Record "Agent") + begin + SelectAgent(Agent, false); + end; + + procedure SelectAgent(var Agent: Record "Agent"; AlwaysShowUI: Boolean) begin Agent.SetRange(State, Agent.State::Enabled); if Agent.Count() = 0 then Error(NoActiveAgentsErr); - if Agent.Count() = 1 then begin + if (Agent.Count() = 1) and (not AlwaysShowUI) then begin Agent.FindFirst(); exit; end; diff --git a/src/Tools/AI Test Toolkit/src/API/AITLogEntryAPI.Page.al b/src/Tools/AI Test Toolkit/src/API/AITLogEntryAPI.Page.al index be5445df80..22abe45fd1 100644 --- a/src/Tools/AI Test Toolkit/src/API/AITLogEntryAPI.Page.al +++ b/src/Tools/AI Test Toolkit/src/API/AITLogEntryAPI.Page.al @@ -58,6 +58,16 @@ page 149038 "AIT Log Entry API" { Caption = 'Total Tokens Consumed'; } + field(copilotCredits; CopilotCredits) + { + Caption = 'Copilot credits'; + Editable = false; + } + field(agentTaskIDs; AgentTaskIDs) + { + Caption = 'Agent tasks'; + Editable = false; + } field("startTime"; Rec."Start Time") { Caption = 'Start Time'; @@ -127,6 +137,8 @@ page 149038 "AIT Log Entry API" } trigger OnAfterGetRecord() + var + AgentTestContextImpl: Codeunit "Agent Test Context Impl."; begin InputText := Rec.GetInputBlob(); OutputText := Rec.GetOutputBlob(); @@ -134,6 +146,8 @@ page 149038 "AIT Log Entry API" ErrorCallStackText := Rec.GetErrorCallStack(); SuiteDescription := Rec.GetSuiteDescription(); TestMethodLineDescription := Rec.GetTestMethodLineDescription(); + CopilotCredits := AgentTestContextImpl.GetCopilotCreditsForLogEntry(Rec."Entry No."); + AgentTaskIDs := AgentTestContextImpl.GetAgentTaskIDsForLogEntry(Rec."Entry No."); end; var @@ -143,4 +157,6 @@ page 149038 "AIT Log Entry API" ErrorCallStackText: Text; SuiteDescription: Text[250]; TestMethodLineDescription: Text[250]; + CopilotCredits: Decimal; + AgentTaskIDs: Text; } \ No newline at end of file diff --git a/src/Tools/AI Test Toolkit/src/API/AITTestMethodLinesAPI.Page.al b/src/Tools/AI Test Toolkit/src/API/AITTestMethodLinesAPI.Page.al index 4bf4e271ab..32dd6161be 100644 --- a/src/Tools/AI Test Toolkit/src/API/AITTestMethodLinesAPI.Page.al +++ b/src/Tools/AI Test Toolkit/src/API/AITTestMethodLinesAPI.Page.al @@ -87,7 +87,34 @@ page 149030 "AIT Test Method Lines API" { Caption = 'Total Tokens Consumed'; } + field(copilotCredits; CopilotCredits) + { + Caption = 'Copilot credits'; + Editable = false; + } + field(agentTaskIDs; AgentTaskIDs) + { + Caption = 'Agent tasks'; + Editable = false; + } } } } + + trigger OnAfterGetRecord() + var + AgentTestContextImpl: Codeunit "Agent Test Context Impl."; + TestSuite: Record "AIT Test Suite"; + VersionFilter: Text; + begin + VersionFilter := Rec.GetFilter(Rec."Version Filter"); + if VersionFilter = '' then + VersionFilter := Format(Rec."Version Filter", 0, 9); + CopilotCredits := AgentTestContextImpl.GetCopilotCredits(Rec."Test Suite Code", VersionFilter, '', Rec."Line No."); + AgentTaskIDs := AgentTestContextImpl.GetAgentTaskIDs(Rec."Test Suite Code", VersionFilter, '', Rec."Line No."); + end; + + var + CopilotCredits: Decimal; + AgentTaskIDs: Text; } \ No newline at end of file diff --git a/src/Tools/AI Test Toolkit/src/Agent/AgentTaskLog.Table.al b/src/Tools/AI Test Toolkit/src/Agent/AgentTaskLog.Table.al index 6ffb9a6791..3bef9b3c7c 100644 --- a/src/Tools/AI Test Toolkit/src/Agent/AgentTaskLog.Table.al +++ b/src/Tools/AI Test Toolkit/src/Agent/AgentTaskLog.Table.al @@ -51,12 +51,23 @@ table 149050 "Agent Task Log" Caption = 'Version'; ToolTip = 'Specifies the Version No. of the eval run.'; } + field(15; Tag; Text[20]) + { + DataClassification = CustomerContent; + Caption = 'Tag'; + ToolTip = 'Specifies the Tag that we entered in the AI Eval Suite.'; + } field(17; "Procedure Name"; Text[128]) { Caption = 'Procedure Name'; DataClassification = CustomerContent; ToolTip = 'Specifies the name of the procedure being executed.'; } + field(5001; "Test Log Entry ID"; Integer) + { + Caption = 'Test Log Entry ID'; + ToolTip = 'Specifies the AIT Log Entry ID that this agent task is associated with.'; + } field(5000; "Agent Task ID"; BigInteger) { Caption = 'Agent Task ID'; @@ -75,5 +86,8 @@ table 149050 "Agent Task Log" { IncludedFields = Status; } + key(Key3; "Test Log Entry ID", "Agent Task ID") + { + } } } diff --git a/src/Tools/AI Test Toolkit/src/Agent/AgentTestContext.Codeunit.al b/src/Tools/AI Test Toolkit/src/Agent/AgentTestContext.Codeunit.al index 65dbecd6a3..335815cce4 100644 --- a/src/Tools/AI Test Toolkit/src/Agent/AgentTestContext.Codeunit.al +++ b/src/Tools/AI Test Toolkit/src/Agent/AgentTestContext.Codeunit.al @@ -3,7 +3,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // ------------------------------------------------------------------------------------------------ -namespace System.Agents; +namespace System.TestTools.AITestToolkit; /// /// Exposes Agent specific functionality that can be used by the AI tests. diff --git a/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al b/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al index 2522798713..883b53d1c4 100644 --- a/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al +++ b/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al @@ -3,9 +3,9 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // ------------------------------------------------------------------------------------------------ -namespace System.Agents; +namespace System.TestTools.AITestToolkit; -using System.TestTools.AITestToolkit; +using System.Agents; using System.TestTools.TestRunner; codeunit 149049 "Agent Test Context Impl." @@ -36,6 +36,7 @@ codeunit 149049 "Agent Test Context Impl." if IsNullGuid(AITTestSuite."Agent User Security ID") then exit; + GlobalAgentUserSecurityID := AITTestSuite."Agent User Security ID"; if not Agent.IsActive(GlobalAgentUserSecurityID) then Error(AgentIsNotActiveErr, AITTestSuite.Code, AITTestSuite."Agent User Security ID"); end; @@ -75,11 +76,241 @@ codeunit 149049 "Agent Test Context Impl." var AgentTaskLog: Record "Agent Task Log"; begin - AgentTaskLog.TransferFields(AITLogEntry, true); + AgentTaskLog.TransferFields(AITLogEntry, false); AgentTaskLog."Agent Task ID" := AgentTaskId; + AgentTaskLog."Test Log Entry ID" := AITLogEntry."Entry No."; AgentTaskLog.Insert(); end; + /// + /// Gets the comma-separated list of Agent Task IDs for a specific log entry. + /// + /// The log entry number. + /// Comma-separated string of Agent Task IDs. + procedure GetAgentTaskIDsForLogEntry(LogEntryNo: Integer): Text + var + AgentTaskLog: Record "Agent Task Log"; + TaskIDList: List of [BigInteger]; + TaskIDTextList: List of [Text]; + begin + AgentTaskLog.SetRange("Test Log Entry ID", LogEntryNo); + + if AgentTaskLog.FindSet() then + repeat + if not TaskIDList.Contains(AgentTaskLog."Agent Task ID") then begin + TaskIDList.Add(AgentTaskLog."Agent Task ID"); + TaskIDTextList.Add(Format(AgentTaskLog."Agent Task ID")); + end; + until AgentTaskLog.Next() = 0; + + exit(ConcatenateList(TaskIDTextList, ', ')); + end; + + /// + /// Gets the comma-separated list of Agent Task IDs for the given test suite, version, and line number. + /// + /// The test suite code. + /// The version number. + /// The tag. + /// The test method line number. Use 0 for all lines. + /// Comma-separated string of Agent Task IDs. + procedure GetAgentTaskIDs(TestSuiteCode: Code[100]; VersionNumber: Integer; Tag: Text[20]; TestMethodLineNo: Integer): Text + var + VersionFilterText: Text; + begin + if VersionNumber > 0 then + VersionFilterText := Format(VersionNumber); + exit(GetAgentTaskIDs(TestSuiteCode, VersionFilterText, Tag, TestMethodLineNo)); + end; + + /// + /// Gets the comma-separated list of Agent Task IDs for the given test suite, version, and line number. + /// + /// The test suite code. + /// The version filter. + /// The tag. + /// The test method line number. Use 0 for all lines. + /// Comma-separated string of Agent Task IDs. + procedure GetAgentTaskIDs(TestSuiteCode: Code[100]; VersionFilter: Text; Tag: Text[20]; TestMethodLineNo: Integer): Text + var + AgentTaskLog: Record "Agent Task Log"; + TaskIDList: List of [BigInteger]; + TaskIDTextList: List of [Text]; + begin + AgentTaskLog.SetRange("Test Suite Code", TestSuiteCode); + if Tag <> '' then + AgentTaskLog.SetRange(Tag, Tag); + if VersionFilter <> '' then + AgentTaskLog.SetFilter(Version, VersionFilter); + if TestMethodLineNo <> 0 then + AgentTaskLog.SetRange("Test Method Line No.", TestMethodLineNo); + + if AgentTaskLog.FindSet() then + repeat + if not TaskIDList.Contains(AgentTaskLog."Agent Task ID") then begin + TaskIDList.Add(AgentTaskLog."Agent Task ID"); + TaskIDTextList.Add(Format(AgentTaskLog."Agent Task ID")); + end; + until AgentTaskLog.Next() = 0; + + exit(ConcatenateList(TaskIDTextList, ', ')); + end; + + /// + /// Gets the total Copilot Credits consumed for a specific log entry. + /// + /// The log entry number. + /// Total Copilot Credits consumed. + procedure GetCopilotCreditsForLogEntry(LogEntryNo: Integer): Decimal + var + AgentTaskLog: Record "Agent Task Log"; + AgentTask: Codeunit "Agent Task"; + TaskIDList: List of [BigInteger]; + TotalCredits: Decimal; + begin + AgentTaskLog.SetRange("Test Log Entry ID", LogEntryNo); + + if AgentTaskLog.FindSet() then + repeat + if not TaskIDList.Contains(AgentTaskLog."Agent Task ID") then begin + TaskIDList.Add(AgentTaskLog."Agent Task ID"); + TotalCredits += AgentTask.GetCopilotCreditsConsumed(AgentTaskLog."Agent Task ID"); + end; + until AgentTaskLog.Next() = 0; + + exit(TotalCredits); + end; + + /// + /// Gets the total Copilot Credits consumed for the given test suite, version, and line number. + /// + /// The test suite code. + /// The tag. + /// The version number. + /// The test method line number. Use 0 for all lines. + /// Total Copilot Credits consumed. + procedure GetCopilotCredits(TestSuiteCode: Code[100]; VersionNumber: Integer; Tag: Text[20]; TestMethodLineNo: Integer): Decimal + var + VersionFilterText: Text; + begin + if VersionNumber > 0 then + VersionFilterText := Format(VersionNumber); + exit(GetCopilotCredits(TestSuiteCode, VersionFilterText, Tag, TestMethodLineNo)); + end; + + /// + /// Gets the total Copilot Credits consumed for the given test suite, version, and line number. + /// + /// The test suite code. + /// The version filter. + /// The tag. + /// The test method line number. Use 0 for all lines. + /// Total Copilot Credits consumed. + procedure GetCopilotCredits(TestSuiteCode: Code[100]; VersionFilter: Text; Tag: Text[20]; TestMethodLineNo: Integer): Decimal + var + AgentTaskLog: Record "Agent Task Log"; + AgentTask: Codeunit "Agent Task"; + TaskIDList: List of [BigInteger]; + TotalCredits: Decimal; + begin + AgentTaskLog.SetRange("Test Suite Code", TestSuiteCode); + if VersionFilter <> '' then + AgentTaskLog.SetFilter(Version, VersionFilter); + + if Tag <> '' then + AgentTaskLog.SetRange(Tag, Tag); + + if TestMethodLineNo > 0 then + AgentTaskLog.SetRange("Test Method Line No.", TestMethodLineNo); + + if AgentTaskLog.FindSet() then + repeat + if not TaskIDList.Contains(AgentTaskLog."Agent Task ID") then begin + TaskIDList.Add(AgentTaskLog."Agent Task ID"); + TotalCredits += AgentTask.GetCopilotCreditsConsumed(AgentTaskLog."Agent Task ID"); + end; + until AgentTaskLog.Next() = 0; + + exit(TotalCredits); + end; + + /// + /// Gets the count of Agent Tasks from a comma-separated list of Agent Task IDs. + /// + /// Comma-separated string of Agent Task IDs. + /// The number of Agent Tasks in the list. + procedure GetAgentTaskCount(CommaSeparatedTaskIDs: Text): Integer + var + TaskIDList: List of [Text]; + begin + if CommaSeparatedTaskIDs = '' then + exit(0); + + TaskIDList := CommaSeparatedTaskIDs.Split(','); + exit(TaskIDList.Count()); + end; + + /// + /// Opens the Agent Task List page filtered to the specified Agent Task IDs. + /// + /// Comma-separated string of Agent Task IDs. + procedure OpenAgentTaskList(CommaSeparatedTaskIDs: Text) + var + AgentTask: Record "Agent Task"; + AgentTaskListPage: Page "Agent Task List"; + FilterText: Text; + begin + FilterText := ConvertCommaSeparatedToFilter(CommaSeparatedTaskIDs); + if FilterText = '' then + exit; + + AgentTask.SetFilter(ID, FilterText); + AgentTaskListPage.SetTableView(AgentTask); + AgentTaskListPage.Run(); + end; + + local procedure ConvertCommaSeparatedToFilter(CommaSeparatedValues: Text): Text + var + Values: List of [Text]; + Value: Text; + FilterText: Text; + IsFirst: Boolean; + begin + if CommaSeparatedValues = '' then + exit(''); + + Values := CommaSeparatedValues.Split(','); + IsFirst := true; + foreach Value in Values do begin + Value := Value.Trim(); + if Value <> '' then begin + if IsFirst then begin + FilterText := Value; + IsFirst := false; + end else + FilterText += '|' + Value; + end; + end; + exit(FilterText); + end; + + local procedure ConcatenateList(TextList: List of [Text]; Separator: Text): Text + var + Result: Text; + Item: Text; + IsFirst: Boolean; + begin + IsFirst := true; + foreach Item in TextList do begin + if IsFirst then begin + Result := Item; + IsFirst := false; + end else + Result += Separator + Item; + end; + exit(Result); + end; + var AgentTaskList: List of [BigInteger]; } \ No newline at end of file diff --git a/src/Tools/AI Test Toolkit/src/Agent/AgentTestSuite.TableExt.al b/src/Tools/AI Test Toolkit/src/Agent/AgentTestSuite.TableExt.al index ad15a1a18e..8ba265aa2a 100644 --- a/src/Tools/AI Test Toolkit/src/Agent/AgentTestSuite.TableExt.al +++ b/src/Tools/AI Test Toolkit/src/Agent/AgentTestSuite.TableExt.al @@ -3,9 +3,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // ------------------------------------------------------------------------------------------------ -namespace System.Agents; - -using System.TestTools.AITestToolkit; +namespace System.TestTools.AITestToolkit; tableextension 149050 "Agent Test Suite" extends "AIT Test Suite" { diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITLogEntries.Page.al b/src/Tools/AI Test Toolkit/src/Logs/AITLogEntries.Page.al index 20788758c6..eb0e0419e7 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITLogEntries.Page.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITLogEntries.Page.al @@ -122,6 +122,25 @@ page 149033 "AIT Log Entries" field("Tokens Consumed"; Rec."Tokens Consumed") { } + field("Copilot Credits"; CopilotCredits) + { + Caption = 'Copilot credits'; + ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks for this log entry.'; + Editable = false; + } + field("Agent Task IDs"; AgentTaskIDs) + { + Caption = 'Agent tasks'; + ToolTip = 'Specifies the comma-separated list of Agent Task IDs related to this log entry.'; + Editable = false; + + trigger OnDrillDown() + var + AgentTestContextImpl: Codeunit "Agent Test Context Impl."; + begin + AgentTestContextImpl.OpenAgentTaskList(AgentTaskIDs); + end; + } field(TestRunDuration; TestRunDuration) { Caption = 'Duration'; @@ -341,6 +360,7 @@ page 149033 "AIT Log Entries" } var + AgentTestContextImpl: Codeunit "Agent Test Context Impl."; ClickToShowLbl: Label 'Show eval input'; DoYouWantToDeleteQst: Label 'Do you want to delete all entries within the filter?'; InputText: Text; @@ -353,6 +373,8 @@ page 149033 "AIT Log Entries" TestRunDuration: Duration; IsFilteredToErrors: Boolean; ShowSensitiveData: Boolean; + CopilotCredits: Decimal; + AgentTaskIDs: Text; trigger OnAfterGetRecord() var @@ -364,6 +386,7 @@ page 149033 "AIT Log Entries" SetErrorFields(); SetStatusStyleExpr(); SetTurnsStyleExpr(); + UpdateAgentTaskMetrics(); end; local procedure SetStatusStyleExpr() @@ -416,4 +439,10 @@ page 149033 "AIT Log Entries" OutputText := Rec.GetOutputBlob(); end; end; + + local procedure UpdateAgentTaskMetrics() + begin + CopilotCredits := AgentTestContextImpl.GetCopilotCreditsForLogEntry(Rec."Entry No."); + AgentTaskIDs := AgentTestContextImpl.GetAgentTaskIDsForLogEntry(Rec."Entry No."); + end; } \ No newline at end of file diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Codeunit.al b/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Codeunit.al index 436dfc6137..dfb6953b13 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Codeunit.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Codeunit.al @@ -12,6 +12,7 @@ codeunit 149036 "AIT Run History" procedure GetHistory(Code: Code[100]; LineNo: Integer; AITViewBy: Enum "AIT Run History - View By"; var TempAITRunHistory: Record "AIT Run History" temporary) var AITRunHistory: Record "AIT Run History"; + AgentTestContextImpl: Codeunit "Agent Test Context Impl."; SeenTags: List of [Text[20]]; begin TempAITRunHistory.DeleteAll(); @@ -21,6 +22,8 @@ codeunit 149036 "AIT Run History" if AITRunHistory.FindSet() then repeat TempAITRunHistory.TransferFields(AITRunHistory); + TempAITRunHistory."Copilot Credits" := AgentTestContextImpl.GetCopilotCredits(AITRunHistory."Test Suite Code", AITRunHistory.Version, '', LineNo); + TempAITRunHistory."Agent Task IDs" := CopyStr(AgentTestContextImpl.GetAgentTaskIDs(AITRunHistory."Test Suite Code", AITRunHistory.Version, '', LineNo), 1, MaxStrLen(TempAITRunHistory."Agent Task IDs")); TempAITRunHistory.Insert(); until AITRunHistory.Next() = 0; @@ -29,6 +32,8 @@ codeunit 149036 "AIT Run History" repeat if not SeenTags.Contains(AITRunHistory.Tag) then begin TempAITRunHistory.TransferFields(AITRunHistory); + TempAITRunHistory."Copilot Credits - By Tag" := AgentTestContextImpl.GetCopilotCredits(AITRunHistory."Test Suite Code", '', AITRunHistory.Tag, LineNo); + TempAITRunHistory."Agent Task IDs - By Tag" := CopyStr(AgentTestContextImpl.GetAgentTaskIDs(AITRunHistory."Test Suite Code", '', AITRunHistory.Tag, LineNo), 1, MaxStrLen(TempAITRunHistory."Agent Task IDs - By Tag")); TempAITRunHistory.Insert(); end; SeenTags.Add(AITRunHistory.Tag); diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Page.al b/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Page.al index db6a7b8429..e290b34420 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Page.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Page.al @@ -139,6 +139,27 @@ page 149032 "AIT Run History" Caption = 'Total Tokens Consumed'; ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module.'; } + field("Copilot Credits - By Version"; Rec."Copilot Credits") + { + Visible = ViewBy = ViewBy::Version; + Caption = 'Copilot credits'; + ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks in the current version.'; + Editable = false; + } + field("Agent Task IDs - By Version"; Rec."Agent Task IDs") + { + Visible = ViewBy = ViewBy::Version; + Caption = 'Agent tasks'; + ToolTip = 'Specifies the comma-separated list of Agent Task IDs related to the current version.'; + Editable = false; + + trigger OnDrillDown() + var + AgentTestContextImpl: Codeunit "Agent Test Context Impl."; + begin + AgentTestContextImpl.OpenAgentTaskList(Rec."Agent Task IDs"); + end; + } field("No. of Tests - By Tag"; Rec."No. of Tests Executed - By Tag") { Visible = ViewBy = ViewBy::Tag; @@ -185,6 +206,27 @@ page 149032 "AIT Run History" Caption = 'Total Tokens Consumed'; ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module.'; } + field("Copilot Credits - By Tag"; Rec."Copilot Credits - By Tag") + { + Visible = ViewBy = ViewBy::Tag; + Caption = 'Copilot credits'; + ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks for the tag.'; + Editable = false; + } + field("Agent Task IDs - By Tag"; Rec."Agent Task IDs - By Tag") + { + Visible = ViewBy = ViewBy::Tag; + Caption = 'Agent tasks'; + ToolTip = 'Specifies the comma-separated list of Agent Task IDs related to the tag.'; + Editable = false; + + trigger OnDrillDown() + var + AgentTestContextImpl: Codeunit "Agent Test Context Impl."; + begin + AgentTestContextImpl.OpenAgentTaskList(Rec."Agent Task IDs - By Tag"); + end; + } } } } diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Table.al b/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Table.al index 6144bbe2a7..842a87eda1 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Table.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Table.al @@ -82,6 +82,18 @@ table 149036 "AIT Run History" CalcFormula = average("AIT Log Entry"."Test Method Line Accuracy" where("Test Suite Code" = field("Test Suite Code"), "Test Method Line No." = field("Line No. Filter"), Version = field("Version"), Operation = const('Run Procedure'), "Procedure Name" = filter(<> ''))); AutoFormatType = 0; } + field(15; "Copilot Credits"; Decimal) + { + Caption = 'Copilot credits'; + ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks in the current version.'; + Editable = false; + } + field(16; "Agent Task IDs"; Text[2048]) + { + Caption = 'Agent tasks'; + ToolTip = 'Specifies the comma-separated list of Agent Task IDs related to the current version.'; + Editable = false; + } field(20; "No. of Tests Executed - By Tag"; Integer) { Caption = 'No. of Evals Executed'; @@ -123,6 +135,18 @@ table 149036 "AIT Run History" CalcFormula = average("AIT Log Entry"."Test Method Line Accuracy" where("Test Suite Code" = field("Test Suite Code"), "Test Method Line No." = field("Line No. Filter"), Tag = field(Tag), Operation = const('Run Procedure'), "Procedure Name" = filter(<> ''))); AutoFormatType = 0; } + field(25; "Copilot Credits - By Tag"; Decimal) + { + Caption = 'Copilot credits'; + ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks for the tag.'; + Editable = false; + } + field(26; "Agent Task IDs - By Tag"; Text[2048]) + { + Caption = 'Agent tasks'; + ToolTip = 'Specifies the comma-separated list of Agent Task IDs related to the tag.'; + Editable = false; + } } keys diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITTestMethodLinesCompare.Page.al b/src/Tools/AI Test Toolkit/src/Logs/AITTestMethodLinesCompare.Page.al index 8e68da352b..31c45235da 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITTestMethodLinesCompare.Page.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITTestMethodLinesCompare.Page.al @@ -83,6 +83,16 @@ page 149035 "AIT Test Method Lines Compare" Caption = 'Total Tokens Consumed'; ToolTip = 'Specifies the aggregated number of tokens consumed by the eval. This is applicable only when using Microsoft AI Module.'; } + label(CopilotCredits) + { + Caption = 'Copilot credits'; + ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks.'; + } + label(AgentTaskIDs) + { + Caption = 'Agent tasks'; + ToolTip = 'Specifies the comma-separated list of Agent Task IDs.'; + } } group("Latest Version") { @@ -166,6 +176,7 @@ page 149035 "AIT Test Method Lines Compare" } var + AgentTestContextImpl: Codeunit "Agent Test Context Impl."; Version: Integer; BaseVersion: Integer; diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITTestSuiteCompare.Page.al b/src/Tools/AI Test Toolkit/src/Logs/AITTestSuiteCompare.Page.al index b3f46516e6..97c2903571 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITTestSuiteCompare.Page.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITTestSuiteCompare.Page.al @@ -84,6 +84,16 @@ page 149036 "AIT Test Suite Compare" Caption = 'Total Tokens Consumed'; ToolTip = 'Specifies the aggregated number of tokens consumed by the eval. This is applicable only when using Microsoft AI Module.'; } + label(CopilotCredits) + { + Caption = 'Copilot credits'; + ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks.'; + } + label(AgentTaskIDs) + { + Caption = 'Agent tasks'; + ToolTip = 'Specifies the comma-separated list of Agent Task IDs.'; + } } group("Latest Version") { @@ -170,6 +180,7 @@ page 149036 "AIT Test Suite Compare" } var + AgentTestContextImpl: Codeunit "Agent Test Context Impl."; BaseVersion: Integer; trigger OnOpenPage() diff --git a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLine.Table.al b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLine.Table.al index 83c10adbb5..34c82f0a89 100644 --- a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLine.Table.al +++ b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLine.Table.al @@ -214,14 +214,19 @@ table 149032 "AIT Test Method Line" FieldClass = FlowField; CalcFormula = sum("AIT Log Entry"."Tokens Consumed" where("Test Suite Code" = field("Test Suite Code"), "Test Method Line No." = field("Line No."), Version = field("Version Filter"), Operation = const('Run Procedure'), "Procedure Name" = filter(<> ''))); } +#if not CLEAN26 field(121; "Tokens Consumed - Base"; Integer) { + ObsoleteState = Pending; + ObsoleteReason = 'This field is deprecated as it is not used in any page or calculation. It will be removed in future versions.'; + ObsoleteTag = '26.0'; Caption = 'Tokens Consumed - Base'; ToolTip = 'Specifies the number of tokens consumed by the eval in the base version. This is applicable only when using Microsoft AI Module.'; Editable = false; FieldClass = FlowField; CalcFormula = sum("AIT Log Entry"."Tokens Consumed" where("Test Suite Code" = field("Test Suite Code"), "Test Method Line No." = field("Line No."), Version = field("Base Version Filter"), Operation = const('Run Procedure'), "Procedure Name" = filter(<> ''))); } +#endif } keys { diff --git a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLines.Page.al b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLines.Page.al index 974260ef8b..e5854f0366 100644 --- a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLines.Page.al +++ b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLines.Page.al @@ -4,6 +4,7 @@ // ------------------------------------------------------------------------------------------------ namespace System.TestTools.AITestToolkit; +using System.TestTools.TestRunner; page 149034 "AIT Test Method Lines" { @@ -84,7 +85,7 @@ page 149034 "AIT Test Method Lines" ToolTip = 'Specifies the number of failed evals for the eval line.'; Style = Unfavorable; - trigger OnDrillDown() + trigger OnAssistEdit() var AITTestSuite: Record "AIT Test Suite"; AITLogEntry: Codeunit "AIT Log Entry"; @@ -151,6 +152,25 @@ page 149034 "AIT Test Method Lines" field("Tokens Consumed"; Rec."Tokens Consumed") { } + field("Copilot Credits"; CopilotCredits) + { + Caption = 'Copilot credits'; + ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks for this eval line.'; + Editable = false; + } + field("Agent Task Count"; AgentTaskCount) + { + Caption = 'Agent tasks'; + ToolTip = 'Specifies the number of Agent Tasks related to this eval line.'; + Editable = false; + + trigger OnDrillDown() + var + AgentTestContextImpl: Codeunit "Agent Test Context Impl."; + begin + AgentTestContextImpl.OpenAgentTaskList(AgentTaskIDs); + end; + } field(AvgDuration; AITTestSuiteMgt.GetAvgDuration(Rec)) { Caption = 'Average Duration (ms)'; @@ -263,9 +283,13 @@ page 149034 "AIT Test Method Lines" var AITTestSuite: Record "AIT Test Suite"; AITTestSuiteMgt: Codeunit "AIT Test Suite Mgt."; + AgentTestContextImpl: Codeunit "Agent Test Context Impl."; NoLineSelectedErr: Label 'Select a line to compare'; TurnsText: Text; EvaluationSetupTxt: Text; + CopilotCredits: Decimal; + AgentTaskIDs: Text; + AgentTaskCount: Integer; trigger OnInsertRecord(BelowxRec: Boolean): Boolean begin @@ -279,6 +303,12 @@ page 149034 "AIT Test Method Lines" begin EvaluationSetupTxt := AITTestSuiteMgt.GetEvaluationSetupText(CopyStr(Rec."Test Suite Code", 1, 10), Rec."Line No."); TurnsText := AITTestSuiteMgt.GetTurnsAsText(Rec); + UpdateAgentTaskMetrics(); + end; + + trigger OnAfterGetCurrRecord() + begin + UpdateAgentTaskMetrics(); end; local procedure GetAvg(NumIterations: Integer; TotalNo: Integer): Integer @@ -295,6 +325,20 @@ page 149034 "AIT Test Method Lines" exit(Round((100 * (No - BaseNo)) / BaseNo, 0.1)); end; + local procedure UpdateAgentTaskMetrics() + var + VersionFilter: Text; + CurrentFilterGroup: Integer; + begin + CurrentFilterGroup := Rec.FilterGroup(); + Rec.FilterGroup(4); + VersionFilter := Rec.GetFilter(Rec."Version Filter"); + Rec.FilterGroup(CurrentFilterGroup); + CopilotCredits := AgentTestContextImpl.GetCopilotCredits(Rec."Test Suite Code", VersionFilter, '', Rec."Line No."); + AgentTaskIDs := AgentTestContextImpl.GetAgentTaskIDs(Rec."Test Suite Code", VersionFilter, '', Rec."Line No."); + AgentTaskCount := AgentTestContextImpl.GetAgentTaskCount(AgentTaskIDs); + end; + internal procedure Refresh() begin CurrPage.Update(false); diff --git a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al index e7c71dc3ba..8743e13eb3 100644 --- a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al +++ b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al @@ -221,6 +221,23 @@ page 149031 "AIT Test Suite" Caption = 'Average Tokens Consumed'; ToolTip = 'Specifies the average number of tokens consumed by the evals in the last run.'; } + field("Copilot Credits"; CopilotCredits) + { + Editable = false; + Caption = 'Copilot credits'; + ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks in the current version.'; + } + field("Agent Task Count"; AgentTaskCount) + { + Editable = false; + Caption = 'Agent tasks'; + ToolTip = 'Specifies the number of Agent Tasks related to the current version.'; + + trigger OnDrillDown() + begin + AgentTestContextImpl.OpenAgentTaskList(AgentTaskIDs); + end; + } } } @@ -409,9 +426,13 @@ page 149031 "AIT Test Suite" var AITTestSuiteMgt: Codeunit "AIT Test Suite Mgt."; + AgentTestContextImpl: Codeunit "Agent Test Context Impl."; AvgTimeDuration: Duration; AvgTokensConsumed: Integer; TotalDuration: Duration; + CopilotCredits: Decimal; + AgentTaskIDs: Text; + AgentTaskCount: Integer; PageCaptionLbl: Label 'AI Eval'; TestRunnerDisplayName: Text; Language: Text; @@ -437,6 +458,7 @@ page 149031 "AIT Test Suite" begin UpdateTotalDuration(); UpdateAverages(); + UpdateAgentTaskMetrics(); Language := AITTestSuiteLanguage.GetLanguageDisplayName(Rec."Run Language ID"); TestRunnerDisplayName := TestSuiteMgt.GetTestRunnerDisplayName(Rec."Test Runner Id"); EvaluationSetupTxt := AITTestSuiteMgt.GetEvaluationSetupText(Rec.Code, 0); @@ -461,4 +483,11 @@ page 149031 "AIT Test Suite" else AvgTokensConsumed := 0; end; + + local procedure UpdateAgentTaskMetrics() + begin + CopilotCredits := AgentTestContextImpl.GetCopilotCredits(Rec.Code, Rec.Version, '', 0); + AgentTaskIDs := AgentTestContextImpl.GetAgentTaskIDs(Rec.Code, Rec.Version, '', 0); + AgentTaskCount := AgentTestContextImpl.GetAgentTaskCount(AgentTaskIDs); + end; } \ No newline at end of file diff --git a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuiteMgt.Codeunit.al b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuiteMgt.Codeunit.al index 4a381d5e34..a40d01d6f1 100644 --- a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuiteMgt.Codeunit.al +++ b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuiteMgt.Codeunit.al @@ -163,10 +163,12 @@ codeunit 149034 "AIT Test Suite Mgt." var AITRunHistory: Record "AIT Run History"; AITTestContext: Codeunit "AIT Test Context"; + AgentTestContextImpl: Codeunit "Agent Test Context Impl."; begin AITRunHistory."Test Suite Code" := Code; AITRunHistory.Version := Version; AITRunHistory.Tag := Tag; + AITRunHistory."Copilot Credits" := AgentTestContextImpl.GetCopilotCredits(Code, Version, Tag, 0); AITRunHistory.Insert(); AITTestContext.OnAfterRunComplete(Code, Version, Tag); From de61e6cc0c610b02181182694e0d6386970704a9 Mon Sep 17 00:00:00 2001 From: Nikola Kukrika Date: Wed, 25 Feb 2026 21:04:53 +0100 Subject: [PATCH 03/17] Slight refactoring --- .../src/API/AITTestMethodLinesAPI.Page.al | 27 -------- .../Agent/AgentTestContextImpl.Codeunit.al | 66 ++++++++----------- 2 files changed, 29 insertions(+), 64 deletions(-) diff --git a/src/Tools/AI Test Toolkit/src/API/AITTestMethodLinesAPI.Page.al b/src/Tools/AI Test Toolkit/src/API/AITTestMethodLinesAPI.Page.al index 32dd6161be..4bf4e271ab 100644 --- a/src/Tools/AI Test Toolkit/src/API/AITTestMethodLinesAPI.Page.al +++ b/src/Tools/AI Test Toolkit/src/API/AITTestMethodLinesAPI.Page.al @@ -87,34 +87,7 @@ page 149030 "AIT Test Method Lines API" { Caption = 'Total Tokens Consumed'; } - field(copilotCredits; CopilotCredits) - { - Caption = 'Copilot credits'; - Editable = false; - } - field(agentTaskIDs; AgentTaskIDs) - { - Caption = 'Agent tasks'; - Editable = false; - } } } } - - trigger OnAfterGetRecord() - var - AgentTestContextImpl: Codeunit "Agent Test Context Impl."; - TestSuite: Record "AIT Test Suite"; - VersionFilter: Text; - begin - VersionFilter := Rec.GetFilter(Rec."Version Filter"); - if VersionFilter = '' then - VersionFilter := Format(Rec."Version Filter", 0, 9); - CopilotCredits := AgentTestContextImpl.GetCopilotCredits(Rec."Test Suite Code", VersionFilter, '', Rec."Line No."); - AgentTaskIDs := AgentTestContextImpl.GetAgentTaskIDs(Rec."Test Suite Code", VersionFilter, '', Rec."Line No."); - end; - - var - CopilotCredits: Decimal; - AgentTaskIDs: Text; } \ No newline at end of file diff --git a/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al b/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al index 883b53d1c4..f7a537b1cb 100644 --- a/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al +++ b/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al @@ -94,16 +94,7 @@ codeunit 149049 "Agent Test Context Impl." TaskIDTextList: List of [Text]; begin AgentTaskLog.SetRange("Test Log Entry ID", LogEntryNo); - - if AgentTaskLog.FindSet() then - repeat - if not TaskIDList.Contains(AgentTaskLog."Agent Task ID") then begin - TaskIDList.Add(AgentTaskLog."Agent Task ID"); - TaskIDTextList.Add(Format(AgentTaskLog."Agent Task ID")); - end; - until AgentTaskLog.Next() = 0; - - exit(ConcatenateList(TaskIDTextList, ', ')); + exit(GetAgentTaskIDs(AgentTaskLog)); end; /// @@ -134,8 +125,6 @@ codeunit 149049 "Agent Test Context Impl." procedure GetAgentTaskIDs(TestSuiteCode: Code[100]; VersionFilter: Text; Tag: Text[20]; TestMethodLineNo: Integer): Text var AgentTaskLog: Record "Agent Task Log"; - TaskIDList: List of [BigInteger]; - TaskIDTextList: List of [Text]; begin AgentTaskLog.SetRange("Test Suite Code", TestSuiteCode); if Tag <> '' then @@ -145,15 +134,7 @@ codeunit 149049 "Agent Test Context Impl." if TestMethodLineNo <> 0 then AgentTaskLog.SetRange("Test Method Line No.", TestMethodLineNo); - if AgentTaskLog.FindSet() then - repeat - if not TaskIDList.Contains(AgentTaskLog."Agent Task ID") then begin - TaskIDList.Add(AgentTaskLog."Agent Task ID"); - TaskIDTextList.Add(Format(AgentTaskLog."Agent Task ID")); - end; - until AgentTaskLog.Next() = 0; - - exit(ConcatenateList(TaskIDTextList, ', ')); + exit(GetAgentTaskIDs(AgentTaskLog)); end; /// @@ -164,21 +145,10 @@ codeunit 149049 "Agent Test Context Impl." procedure GetCopilotCreditsForLogEntry(LogEntryNo: Integer): Decimal var AgentTaskLog: Record "Agent Task Log"; - AgentTask: Codeunit "Agent Task"; - TaskIDList: List of [BigInteger]; - TotalCredits: Decimal; + begin AgentTaskLog.SetRange("Test Log Entry ID", LogEntryNo); - - if AgentTaskLog.FindSet() then - repeat - if not TaskIDList.Contains(AgentTaskLog."Agent Task ID") then begin - TaskIDList.Add(AgentTaskLog."Agent Task ID"); - TotalCredits += AgentTask.GetCopilotCreditsConsumed(AgentTaskLog."Agent Task ID"); - end; - until AgentTaskLog.Next() = 0; - - exit(TotalCredits); + exit(GetCopilotCredits(AgentTaskLog)); end; /// @@ -209,9 +179,6 @@ codeunit 149049 "Agent Test Context Impl." procedure GetCopilotCredits(TestSuiteCode: Code[100]; VersionFilter: Text; Tag: Text[20]; TestMethodLineNo: Integer): Decimal var AgentTaskLog: Record "Agent Task Log"; - AgentTask: Codeunit "Agent Task"; - TaskIDList: List of [BigInteger]; - TotalCredits: Decimal; begin AgentTaskLog.SetRange("Test Suite Code", TestSuiteCode); if VersionFilter <> '' then @@ -223,6 +190,15 @@ codeunit 149049 "Agent Test Context Impl." if TestMethodLineNo > 0 then AgentTaskLog.SetRange("Test Method Line No.", TestMethodLineNo); + exit(GetCopilotCredits(AgentTaskLog)); + end; + + local procedure GetCopilotCredits(var AgentTaskLog: Record "Agent Task Log"): Decimal + var + AgentTask: Codeunit "Agent Task"; + TaskIDList: List of [BigInteger]; + TotalCredits: Decimal; + begin if AgentTaskLog.FindSet() then repeat if not TaskIDList.Contains(AgentTaskLog."Agent Task ID") then begin @@ -269,6 +245,22 @@ codeunit 149049 "Agent Test Context Impl." AgentTaskListPage.Run(); end; + local procedure GetAgentTaskIDs(var AgentTaskLog: Record "Agent Task Log"): Text + var + TaskIDList: List of [BigInteger]; + TaskIDTextList: List of [Text]; + begin + if AgentTaskLog.FindSet() then + repeat + if not TaskIDList.Contains(AgentTaskLog."Agent Task ID") then begin + TaskIDList.Add(AgentTaskLog."Agent Task ID"); + TaskIDTextList.Add(Format(AgentTaskLog."Agent Task ID")); + end; + until AgentTaskLog.Next() = 0; + + exit(ConcatenateList(TaskIDTextList, ', ')); + end; + local procedure ConvertCommaSeparatedToFilter(CommaSeparatedValues: Text): Text var Values: List of [Text]; From ee9ba0bb2dc666438dd30a0c4a08980f5465bbe1 Mon Sep 17 00:00:00 2001 From: Nikola Kukrika Date: Thu, 26 Feb 2026 13:00:31 +0100 Subject: [PATCH 04/17] Code review feedback and AL cop --- .../Internal/AgentTaskList.Page.al | 18 ------------------ .../src/Agent/AgentTaskLog.Table.al | 10 +++++----- .../Agent/AgentTestContextImpl.Codeunit.al | 19 ++++++++----------- .../src/Logs/AITLogEntries.Page.al | 1 + .../src/Logs/AITRunHistory.Page.al | 2 ++ .../src/Logs/AITRunHistory.Table.al | 2 ++ .../Logs/AITTestMethodLinesCompare.Page.al | 1 - .../src/Logs/AITTestSuiteCompare.Page.al | 1 - .../src/TestSuite/AITTestMethodLines.Page.al | 2 +- .../src/TestSuite/AITTestSuite.Page.al | 1 + 10 files changed, 20 insertions(+), 37 deletions(-) diff --git a/src/System Application/App/Agent/Interaction/Internal/AgentTaskList.Page.al b/src/System Application/App/Agent/Interaction/Internal/AgentTaskList.Page.al index e09121a7fe..0ed5567452 100644 --- a/src/System Application/App/Agent/Interaction/Internal/AgentTaskList.Page.al +++ b/src/System Application/App/Agent/Interaction/Internal/AgentTaskList.Page.al @@ -129,21 +129,6 @@ page 4300 "Agent Task List" { area(Processing) { - action(ShowTask) - { - ApplicationArea = All; - Caption = 'Show task'; - ToolTip = 'Show the selected task in the task pane.'; - Enabled = TaskSelected; - Image = Task; - - trigger OnAction() - var - TaskPane: Codeunit "Task Pane"; - begin - TaskPane.ShowTask(Rec); - end; - } action(ViewTaskMessage) { ApplicationArea = All; @@ -216,9 +201,6 @@ page 4300 "Agent Task List" actionref(ViewTaskLogEntries_Promoted; ViewTaskLogEntries) { } - actionref(ShowTask_Promoted; ShowTask) - { - } } } } diff --git a/src/Tools/AI Test Toolkit/src/Agent/AgentTaskLog.Table.al b/src/Tools/AI Test Toolkit/src/Agent/AgentTaskLog.Table.al index 3bef9b3c7c..2c225a06c2 100644 --- a/src/Tools/AI Test Toolkit/src/Agent/AgentTaskLog.Table.al +++ b/src/Tools/AI Test Toolkit/src/Agent/AgentTaskLog.Table.al @@ -63,17 +63,17 @@ table 149050 "Agent Task Log" DataClassification = CustomerContent; ToolTip = 'Specifies the name of the procedure being executed.'; } - field(5001; "Test Log Entry ID"; Integer) - { - Caption = 'Test Log Entry ID'; - ToolTip = 'Specifies the AIT Log Entry ID that this agent task is associated with.'; - } field(5000; "Agent Task ID"; BigInteger) { Caption = 'Agent Task ID'; NotBlank = true; ToolTip = 'Specifies the Agent Task ID.'; } + field(5001; "Test Log Entry ID"; Integer) + { + Caption = 'Test Log Entry ID'; + ToolTip = 'Specifies the AIT Log Entry ID that this agent task is associated with.'; + } } keys diff --git a/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al b/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al index f7a537b1cb..16e70054c9 100644 --- a/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al +++ b/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al @@ -90,8 +90,6 @@ codeunit 149049 "Agent Test Context Impl." procedure GetAgentTaskIDsForLogEntry(LogEntryNo: Integer): Text var AgentTaskLog: Record "Agent Task Log"; - TaskIDList: List of [BigInteger]; - TaskIDTextList: List of [Text]; begin AgentTaskLog.SetRange("Test Log Entry ID", LogEntryNo); exit(GetAgentTaskIDs(AgentTaskLog)); @@ -264,7 +262,7 @@ codeunit 149049 "Agent Test Context Impl." local procedure ConvertCommaSeparatedToFilter(CommaSeparatedValues: Text): Text var Values: List of [Text]; - Value: Text; + CurrentValue: Text; FilterText: Text; IsFirst: Boolean; begin @@ -273,15 +271,14 @@ codeunit 149049 "Agent Test Context Impl." Values := CommaSeparatedValues.Split(','); IsFirst := true; - foreach Value in Values do begin - Value := Value.Trim(); - if Value <> '' then begin + foreach CurrentValue in Values do begin + CurrentValue := CurrentValue.Trim(); + if CurrentValue <> '' then if IsFirst then begin - FilterText := Value; + FilterText := CurrentValue; IsFirst := false; end else - FilterText += '|' + Value; - end; + FilterText += '|' + CurrentValue; end; exit(FilterText); end; @@ -293,13 +290,13 @@ codeunit 149049 "Agent Test Context Impl." IsFirst: Boolean; begin IsFirst := true; - foreach Item in TextList do begin + foreach Item in TextList do if IsFirst then begin Result := Item; IsFirst := false; end else Result += Separator + Item; - end; + exit(Result); end; diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITLogEntries.Page.al b/src/Tools/AI Test Toolkit/src/Logs/AITLogEntries.Page.al index eb0e0419e7..f7a82e9b2c 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITLogEntries.Page.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITLogEntries.Page.al @@ -124,6 +124,7 @@ page 149033 "AIT Log Entries" } field("Copilot Credits"; CopilotCredits) { + AutoFormatType = 0; Caption = 'Copilot credits'; ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks for this log entry.'; Editable = false; diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Page.al b/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Page.al index e290b34420..571bc3cc39 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Page.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Page.al @@ -141,6 +141,7 @@ page 149032 "AIT Run History" } field("Copilot Credits - By Version"; Rec."Copilot Credits") { + AutoFormatType = 0; Visible = ViewBy = ViewBy::Version; Caption = 'Copilot credits'; ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks in the current version.'; @@ -208,6 +209,7 @@ page 149032 "AIT Run History" } field("Copilot Credits - By Tag"; Rec."Copilot Credits - By Tag") { + AutoFormatType = 0; Visible = ViewBy = ViewBy::Tag; Caption = 'Copilot credits'; ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks for the tag.'; diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Table.al b/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Table.al index 842a87eda1..c312022161 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Table.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Table.al @@ -84,6 +84,7 @@ table 149036 "AIT Run History" } field(15; "Copilot Credits"; Decimal) { + AutoFormatType = 0; Caption = 'Copilot credits'; ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks in the current version.'; Editable = false; @@ -137,6 +138,7 @@ table 149036 "AIT Run History" } field(25; "Copilot Credits - By Tag"; Decimal) { + AutoFormatType = 0; Caption = 'Copilot credits'; ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks for the tag.'; Editable = false; diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITTestMethodLinesCompare.Page.al b/src/Tools/AI Test Toolkit/src/Logs/AITTestMethodLinesCompare.Page.al index 31c45235da..eee8009092 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITTestMethodLinesCompare.Page.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITTestMethodLinesCompare.Page.al @@ -176,7 +176,6 @@ page 149035 "AIT Test Method Lines Compare" } var - AgentTestContextImpl: Codeunit "Agent Test Context Impl."; Version: Integer; BaseVersion: Integer; diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITTestSuiteCompare.Page.al b/src/Tools/AI Test Toolkit/src/Logs/AITTestSuiteCompare.Page.al index 97c2903571..d840b4d441 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITTestSuiteCompare.Page.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITTestSuiteCompare.Page.al @@ -180,7 +180,6 @@ page 149036 "AIT Test Suite Compare" } var - AgentTestContextImpl: Codeunit "Agent Test Context Impl."; BaseVersion: Integer; trigger OnOpenPage() diff --git a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLines.Page.al b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLines.Page.al index e5854f0366..4eef4a8647 100644 --- a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLines.Page.al +++ b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLines.Page.al @@ -4,7 +4,6 @@ // ------------------------------------------------------------------------------------------------ namespace System.TestTools.AITestToolkit; -using System.TestTools.TestRunner; page 149034 "AIT Test Method Lines" { @@ -154,6 +153,7 @@ page 149034 "AIT Test Method Lines" } field("Copilot Credits"; CopilotCredits) { + AutoFormatType = 0; Caption = 'Copilot credits'; ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks for this eval line.'; Editable = false; diff --git a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al index 8743e13eb3..a8da50f324 100644 --- a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al +++ b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al @@ -223,6 +223,7 @@ page 149031 "AIT Test Suite" } field("Copilot Credits"; CopilotCredits) { + AutoFormatType = 0; Editable = false; Caption = 'Copilot credits'; ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks in the current version.'; From a59c056af250a138eb456f47462527cac1cab3cb Mon Sep 17 00:00:00 2001 From: Nikola Kukrika Date: Thu, 26 Feb 2026 21:44:12 +0100 Subject: [PATCH 05/17] Moving Agent User ID to the AI Evals Tool --- .../AgentTaskMessageBuilder.Codeunit.al | 7 +- .../Setup/SetupPart/AgentSetup.Codeunit.al | 11 +++ .../SetupPart/AgentSetupImpl.Codeunit.al | 21 +++++ .../src/Agent/AgentTestSuite.PageExt.al | 80 +++++++++++++++++++ 4 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 src/Tools/AI Test Toolkit/src/Agent/AgentTestSuite.PageExt.al diff --git a/src/System Application/App/Agent/Interaction/AgentTaskMessageBuilder.Codeunit.al b/src/System Application/App/Agent/Interaction/AgentTaskMessageBuilder.Codeunit.al index e158072389..39a231cbda 100644 --- a/src/System Application/App/Agent/Interaction/AgentTaskMessageBuilder.Codeunit.al +++ b/src/System Application/App/Agent/Interaction/AgentTaskMessageBuilder.Codeunit.al @@ -207,13 +207,18 @@ codeunit 4316 "Agent Task Message Builder" /// /// The file to attach. /// This instance of the Agent Task Message Builder. +#if not CLEAN28 +#pragma warning disable AS0078 +#endif procedure AddAttachment(var AgentTaskFile: Record "Agent Task File"): codeunit "Agent Task Message Builder" begin FeatureAccessManagement.AgentTaskManagementPreviewEnabled(true); AgentTaskMsgBuilderImpl.AddAttachment(AgentTaskFile); exit(this); end; - +#if not CLEAN28 +#pragma warning restore AS0078 +#endif /// /// Uploads a file to the task message. /// The file will be attached when the message is created. diff --git a/src/System Application/App/Agent/Setup/SetupPart/AgentSetup.Codeunit.al b/src/System Application/App/Agent/Setup/SetupPart/AgentSetup.Codeunit.al index fa206bc07b..c33d1be78e 100644 --- a/src/System Application/App/Agent/Setup/SetupPart/AgentSetup.Codeunit.al +++ b/src/System Application/App/Agent/Setup/SetupPart/AgentSetup.Codeunit.al @@ -107,6 +107,17 @@ codeunit 4324 "Agent Setup" exit(AgentSetupImpl.OpenAgentLookup(AgentUserSecurityId)); end; + /// + /// Finds the agent user security ID based on the provided user name. + /// The user name to search for. You can provide a partial or full user name. + /// The security ID of the agent user if found, otherwise a null guid. + /// True if an agent with the provided user name is found, false otherwise. + procedure FindAgentByUserName(AgentUserName: Text; var AgentUserSecurityId: Guid): Boolean + begin + FeatureAccessManagement.AgentTaskManagementPreviewEnabled(true); + exit(AgentSetupImpl.FindAgentByUserName(AgentUserName, AgentUserSecurityId)); + end; + /// /// Allows the user to select an agent out of the list of enabled agents. /// diff --git a/src/System Application/App/Agent/Setup/SetupPart/AgentSetupImpl.Codeunit.al b/src/System Application/App/Agent/Setup/SetupPart/AgentSetupImpl.Codeunit.al index 05e7af166c..d3c32ed0cd 100644 --- a/src/System Application/App/Agent/Setup/SetupPart/AgentSetupImpl.Codeunit.al +++ b/src/System Application/App/Agent/Setup/SetupPart/AgentSetupImpl.Codeunit.al @@ -91,6 +91,27 @@ codeunit 4325 "Agent Setup Impl." AgentImpl.OpenSetupPageId(Agent."Agent Metadata Provider", AgentUserSecurityID); end; + [Scope('OnPrem')] + procedure FindAgentByUserName(AgentUserName: Text; var AgentUserSecurityId: Guid): Boolean + var + AgentRec: Record Agent; + begin + AgentRec.SetRange("User Name", AgentUserName); + if AgentRec.FindFirst() then begin + AgentUserSecurityId := AgentRec."User Security ID"; + exit(true); + end; + + AgentRec.SetFilter("User Name", '@' + AgentUserName + '*'); + if AgentRec.FindFirst() then begin + AgentUserSecurityId := AgentRec."User Security ID"; + AgentUserName := AgentRec."User Name"; + exit(true); + end; + + exit(false); + end; + [Scope('OnPrem')] procedure OpenAgentLookup(var AgentUserSecurityId: Guid): Boolean var diff --git a/src/Tools/AI Test Toolkit/src/Agent/AgentTestSuite.PageExt.al b/src/Tools/AI Test Toolkit/src/Agent/AgentTestSuite.PageExt.al new file mode 100644 index 0000000000..73315868a7 --- /dev/null +++ b/src/Tools/AI Test Toolkit/src/Agent/AgentTestSuite.PageExt.al @@ -0,0 +1,80 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ + +namespace System.TestLibraries.Agents; + +using System.Agents; +using System.TestTools.AITestToolkit; + +pageextension 149047 "Agent Test Suite" extends "AIT Test Suite" +{ + layout + { + addafter("Test Runner Id") + { + field(TestSuiteAgent; AgentUserName) + { + ApplicationArea = All; + Caption = 'Agent'; + ToolTip = 'Specifies the agent to be used by the tests.'; + + trigger OnValidate() + begin + ValidateAgentName(); + end; + + trigger OnAssistEdit() + begin + LookupAgent(); + end; + } + } + } + + trigger OnAfterGetCurrRecord() + var + Agent: Codeunit Agent; + begin + AgentUserName := ''; + + if IsNullGuid(Rec."Agent User Security ID") then + exit; + + AgentUserName := Agent.GetUserName(Rec."Agent User Security ID"); + end; + + local procedure LookupAgent() + var + AgentSetup: Codeunit "Agent Setup"; + Agent: Codeunit Agent; + AgentUserSecurityId: Guid; + begin + if not AgentSetup.OpenAgentLookup(AgentUserSecurityId) then + exit; + Rec."Agent User Security ID" := AgentUserSecurityId; + AgentUserName := Agent.GetUserName(AgentUserSecurityId); + Rec.Modify(); + end; + + local procedure ValidateAgentName() + var + AgentSetup: Codeunit "Agent Setup"; + begin + if AgentUserName = '' then begin + Clear(Rec."Agent User Security ID"); + Rec.Modify(); + exit; + end; + + if not AgentSetup.FindAgentByUserName(AgentUserName, Rec."Agent User Security ID") then + Error(AgentWithNameNotFoundErr, AgentUserName); + + Rec.Modify(); + end; + + var + AgentUserName: Code[50]; + AgentWithNameNotFoundErr: Label 'An agent with the name %1 was not found.', Comment = '%1 - The name of the agent.'; +} \ No newline at end of file From a5cd9d78dfa2f824d08e10b73477bd023382affc Mon Sep 17 00:00:00 2001 From: Nikola Kukrika Date: Thu, 26 Feb 2026 22:33:19 +0100 Subject: [PATCH 06/17] Extracting the agent functionality to page extensions --- .../src/Agent/AgentLogEntries.PageExt.al | 58 +++++++++++++ .../src/Agent/AgentRunHistory.PageExt.al | 81 +++++++++++++++++++ .../src/Agent/AgentRunHistory.TableExt.al | 43 ++++++++++ .../Agent/AgentTestContextImpl.Codeunit.al | 73 +++++------------ .../src/Agent/AgentTestMethodLines.PageExt.al | 73 +++++++++++++++++ .../src/Agent/AgentTestSuite.PageExt.al | 47 ++++++++++- .../src/Logs/AITLogEntries.Page.al | 32 +------- .../src/Logs/AITRunHistory.Page.al | 55 ++----------- .../src/Logs/AITRunHistory.Table.al | 27 ------- .../src/TestSuite/AITTestMethodLines.Page.al | 42 +--------- .../src/TestSuite/AITTestSuite.Page.al | 37 ++------- 11 files changed, 345 insertions(+), 223 deletions(-) create mode 100644 src/Tools/AI Test Toolkit/src/Agent/AgentLogEntries.PageExt.al create mode 100644 src/Tools/AI Test Toolkit/src/Agent/AgentRunHistory.PageExt.al create mode 100644 src/Tools/AI Test Toolkit/src/Agent/AgentRunHistory.TableExt.al create mode 100644 src/Tools/AI Test Toolkit/src/Agent/AgentTestMethodLines.PageExt.al diff --git a/src/Tools/AI Test Toolkit/src/Agent/AgentLogEntries.PageExt.al b/src/Tools/AI Test Toolkit/src/Agent/AgentLogEntries.PageExt.al new file mode 100644 index 0000000000..02f7cedf65 --- /dev/null +++ b/src/Tools/AI Test Toolkit/src/Agent/AgentLogEntries.PageExt.al @@ -0,0 +1,58 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ + +namespace System.TestTools.AITestToolkit; + +pageextension 149030 "Agent Log Entries" extends "AIT Log Entries" +{ + layout + { + addafter("Tokens Consumed") + { + field("Copilot Credits"; CopilotCredits) + { + ApplicationArea = All; + AutoFormatType = 0; + Caption = 'Copilot credits'; + ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks for this log entry.'; + Editable = false; + Visible = IsAgentTestType; + } + field("Agent Task IDs"; AgentTaskIDs) + { + ApplicationArea = All; + Caption = 'Agent tasks'; + ToolTip = 'Specifies the comma-separated list of Agent Task IDs related to this log entry.'; + Editable = false; + Visible = IsAgentTestType; + + trigger OnDrillDown() + var + AgentTestContextImpl: Codeunit "Agent Test Context Impl."; + begin + AgentTestContextImpl.OpenAgentTaskList(AgentTaskIDs); + end; + } + } + } + + var + AgentTestContextImpl: Codeunit "Agent Test Context Impl."; + CopilotCredits: Decimal; + AgentTaskIDs: Text; + IsAgentTestType: Boolean; + + trigger OnAfterGetRecord() + begin + UpdateAgentTaskMetrics(); + end; + + local procedure UpdateAgentTaskMetrics() + begin + IsAgentTestType := AgentTestContextImpl.IsAgentTestType(Rec."Test Suite Code"); + CopilotCredits := AgentTestContextImpl.GetCopilotCreditsForLogEntry(Rec."Entry No."); + AgentTaskIDs := AgentTestContextImpl.GetAgentTaskIDsForLogEntry(Rec."Entry No."); + end; +} diff --git a/src/Tools/AI Test Toolkit/src/Agent/AgentRunHistory.PageExt.al b/src/Tools/AI Test Toolkit/src/Agent/AgentRunHistory.PageExt.al new file mode 100644 index 0000000000..61d7ddea93 --- /dev/null +++ b/src/Tools/AI Test Toolkit/src/Agent/AgentRunHistory.PageExt.al @@ -0,0 +1,81 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ + +namespace System.TestTools.AITestToolkit; + +pageextension 149032 "Agent Run History" extends "AIT Run History" +{ + layout + { + addafter("Tokens - By Version") + { + field("Copilot Credits - By Version"; Rec."Copilot Credits") + { + ApplicationArea = All; + AutoFormatType = 0; + Visible = (ViewBy = ViewBy::Version) and IsAgentTestType; + Caption = 'Copilot credits'; + ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks in the current version.'; + Editable = false; + } + field("Agent Task IDs - By Version"; Rec."Agent Task IDs") + { + ApplicationArea = All; + Visible = (ViewBy = ViewBy::Version) and IsAgentTestType; + Caption = 'Agent tasks'; + ToolTip = 'Specifies the comma-separated list of Agent Task IDs related to the current version.'; + Editable = false; + + trigger OnDrillDown() + var + AgentTestContextImpl: Codeunit "Agent Test Context Impl."; + begin + AgentTestContextImpl.OpenAgentTaskList(Rec."Agent Task IDs"); + end; + } + } + addafter("Tokens - By Tag") + { + field("Copilot Credits - By Tag"; Rec."Copilot Credits - By Tag") + { + ApplicationArea = All; + AutoFormatType = 0; + Visible = (ViewBy = ViewBy::Tag) and IsAgentTestType; + Caption = 'Copilot credits'; + ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks for the tag.'; + Editable = false; + } + field("Agent Task IDs - By Tag"; Rec."Agent Task IDs - By Tag") + { + ApplicationArea = All; + Visible = (ViewBy = ViewBy::Tag) and IsAgentTestType; + Caption = 'Agent tasks'; + ToolTip = 'Specifies the comma-separated list of Agent Task IDs related to the tag.'; + Editable = false; + + trigger OnDrillDown() + var + AgentTestContextImpl: Codeunit "Agent Test Context Impl."; + begin + AgentTestContextImpl.OpenAgentTaskList(Rec."Agent Task IDs - By Tag"); + end; + } + } + } + + var + AgentTestContextImpl: Codeunit "Agent Test Context Impl."; + IsAgentTestType: Boolean; + + trigger OnAfterGetRecord() + begin + UpdateVisibility(); + end; + + local procedure UpdateVisibility() + begin + IsAgentTestType := AgentTestContextImpl.IsAgentTestType(Rec."Test Suite Code"); + end; +} diff --git a/src/Tools/AI Test Toolkit/src/Agent/AgentRunHistory.TableExt.al b/src/Tools/AI Test Toolkit/src/Agent/AgentRunHistory.TableExt.al new file mode 100644 index 0000000000..7f9bfbf457 --- /dev/null +++ b/src/Tools/AI Test Toolkit/src/Agent/AgentRunHistory.TableExt.al @@ -0,0 +1,43 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ + +namespace System.TestTools.AITestToolkit; + +tableextension 149030 "Agent Run History" extends "AIT Run History" +{ + fields + { + field(15; "Copilot Credits"; Decimal) + { + DataClassification = SystemMetadata; + AutoFormatType = 0; + Caption = 'Copilot credits'; + ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks in the current version.'; + Editable = false; + } + field(16; "Agent Task IDs"; Text[2048]) + { + DataClassification = SystemMetadata; + Caption = 'Agent tasks'; + ToolTip = 'Specifies the comma-separated list of Agent Task IDs related to the current version.'; + Editable = false; + } + field(25; "Copilot Credits - By Tag"; Decimal) + { + DataClassification = SystemMetadata; + AutoFormatType = 0; + Caption = 'Copilot credits'; + ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks for the tag.'; + Editable = false; + } + field(26; "Agent Task IDs - By Tag"; Text[2048]) + { + DataClassification = SystemMetadata; + Caption = 'Agent tasks'; + ToolTip = 'Specifies the comma-separated list of Agent Task IDs related to the tag.'; + Editable = false; + } + } +} diff --git a/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al b/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al index 16e70054c9..dcc6d9eee6 100644 --- a/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al +++ b/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al @@ -6,6 +6,7 @@ namespace System.TestTools.AITestToolkit; using System.Agents; +using System.Environment; using System.TestTools.TestRunner; codeunit 149049 "Agent Test Context Impl." @@ -82,11 +83,6 @@ codeunit 149049 "Agent Test Context Impl." AgentTaskLog.Insert(); end; - /// - /// Gets the comma-separated list of Agent Task IDs for a specific log entry. - /// - /// The log entry number. - /// Comma-separated string of Agent Task IDs. procedure GetAgentTaskIDsForLogEntry(LogEntryNo: Integer): Text var AgentTaskLog: Record "Agent Task Log"; @@ -95,14 +91,6 @@ codeunit 149049 "Agent Test Context Impl." exit(GetAgentTaskIDs(AgentTaskLog)); end; - /// - /// Gets the comma-separated list of Agent Task IDs for the given test suite, version, and line number. - /// - /// The test suite code. - /// The version number. - /// The tag. - /// The test method line number. Use 0 for all lines. - /// Comma-separated string of Agent Task IDs. procedure GetAgentTaskIDs(TestSuiteCode: Code[100]; VersionNumber: Integer; Tag: Text[20]; TestMethodLineNo: Integer): Text var VersionFilterText: Text; @@ -112,14 +100,6 @@ codeunit 149049 "Agent Test Context Impl." exit(GetAgentTaskIDs(TestSuiteCode, VersionFilterText, Tag, TestMethodLineNo)); end; - /// - /// Gets the comma-separated list of Agent Task IDs for the given test suite, version, and line number. - /// - /// The test suite code. - /// The version filter. - /// The tag. - /// The test method line number. Use 0 for all lines. - /// Comma-separated string of Agent Task IDs. procedure GetAgentTaskIDs(TestSuiteCode: Code[100]; VersionFilter: Text; Tag: Text[20]; TestMethodLineNo: Integer): Text var AgentTaskLog: Record "Agent Task Log"; @@ -135,11 +115,6 @@ codeunit 149049 "Agent Test Context Impl." exit(GetAgentTaskIDs(AgentTaskLog)); end; - /// - /// Gets the total Copilot Credits consumed for a specific log entry. - /// - /// The log entry number. - /// Total Copilot Credits consumed. procedure GetCopilotCreditsForLogEntry(LogEntryNo: Integer): Decimal var AgentTaskLog: Record "Agent Task Log"; @@ -149,14 +124,6 @@ codeunit 149049 "Agent Test Context Impl." exit(GetCopilotCredits(AgentTaskLog)); end; - /// - /// Gets the total Copilot Credits consumed for the given test suite, version, and line number. - /// - /// The test suite code. - /// The tag. - /// The version number. - /// The test method line number. Use 0 for all lines. - /// Total Copilot Credits consumed. procedure GetCopilotCredits(TestSuiteCode: Code[100]; VersionNumber: Integer; Tag: Text[20]; TestMethodLineNo: Integer): Decimal var VersionFilterText: Text; @@ -166,14 +133,6 @@ codeunit 149049 "Agent Test Context Impl." exit(GetCopilotCredits(TestSuiteCode, VersionFilterText, Tag, TestMethodLineNo)); end; - /// - /// Gets the total Copilot Credits consumed for the given test suite, version, and line number. - /// - /// The test suite code. - /// The version filter. - /// The tag. - /// The test method line number. Use 0 for all lines. - /// Total Copilot Credits consumed. procedure GetCopilotCredits(TestSuiteCode: Code[100]; VersionFilter: Text; Tag: Text[20]; TestMethodLineNo: Integer): Decimal var AgentTaskLog: Record "Agent Task Log"; @@ -208,11 +167,6 @@ codeunit 149049 "Agent Test Context Impl." exit(TotalCredits); end; - /// - /// Gets the count of Agent Tasks from a comma-separated list of Agent Task IDs. - /// - /// Comma-separated string of Agent Task IDs. - /// The number of Agent Tasks in the list. procedure GetAgentTaskCount(CommaSeparatedTaskIDs: Text): Integer var TaskIDList: List of [Text]; @@ -224,10 +178,27 @@ codeunit 149049 "Agent Test Context Impl." exit(TaskIDList.Count()); end; - /// - /// Opens the Agent Task List page filtered to the specified Agent Task IDs. - /// - /// Comma-separated string of Agent Task IDs. + procedure IsAgentTestType(TestSuiteCode: Code[100]): Boolean + var + AITTestSuite: Record "AIT Test Suite"; + begin + if not AITTestSuite.Get(TestSuiteCode) then + exit(false); + + exit(AITTestSuite."Test Type" = AITTestSuite."Test Type"::Agent); + end; + + procedure ShouldShowTokens(TestSuiteCode: Code[100]): Boolean + var + EnvironmentInformation: Codeunit "Environment Information"; + begin + // Hide tokens if it's Agent test type AND SaaS environment + if IsAgentTestType(TestSuiteCode) and EnvironmentInformation.IsSaaSInfrastructure() then + exit(false); + + exit(true); + end; + procedure OpenAgentTaskList(CommaSeparatedTaskIDs: Text) var AgentTask: Record "Agent Task"; diff --git a/src/Tools/AI Test Toolkit/src/Agent/AgentTestMethodLines.PageExt.al b/src/Tools/AI Test Toolkit/src/Agent/AgentTestMethodLines.PageExt.al new file mode 100644 index 0000000000..0da2de7c65 --- /dev/null +++ b/src/Tools/AI Test Toolkit/src/Agent/AgentTestMethodLines.PageExt.al @@ -0,0 +1,73 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ + +namespace System.TestTools.AITestToolkit; + +pageextension 149033 "Agent Test Method Lines" extends "AIT Test Method Lines" +{ + layout + { + addafter("Tokens Consumed") + { + field("Copilot Credits"; CopilotCredits) + { + ApplicationArea = All; + AutoFormatType = 0; + Caption = 'Copilot credits'; + ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks for this eval line.'; + Editable = false; + Visible = IsAgentTestType; + } + field("Agent Task Count"; AgentTaskCount) + { + ApplicationArea = All; + Caption = 'Agent tasks'; + ToolTip = 'Specifies the number of Agent Tasks related to this eval line.'; + Editable = false; + Visible = IsAgentTestType; + + trigger OnDrillDown() + var + AgentTestContextImpl: Codeunit "Agent Test Context Impl."; + begin + AgentTestContextImpl.OpenAgentTaskList(AgentTaskIDs); + end; + } + } + } + + var + AgentTestContextImpl: Codeunit "Agent Test Context Impl."; + CopilotCredits: Decimal; + AgentTaskIDs: Text; + AgentTaskCount: Integer; + IsAgentTestType: Boolean; + + trigger OnAfterGetRecord() + begin + UpdateAgentTaskMetrics(); + end; + + trigger OnAfterGetCurrRecord() + begin + UpdateAgentTaskMetrics(); + end; + + local procedure UpdateAgentTaskMetrics() + var + VersionFilter: Text; + CurrentFilterGroup: Integer; + begin + IsAgentTestType := AgentTestContextImpl.IsAgentTestType(Rec."Test Suite Code"); + + CurrentFilterGroup := Rec.FilterGroup(); + Rec.FilterGroup(4); + VersionFilter := Rec.GetFilter(Rec."Version Filter"); + Rec.FilterGroup(CurrentFilterGroup); + CopilotCredits := AgentTestContextImpl.GetCopilotCredits(Rec."Test Suite Code", VersionFilter, '', Rec."Line No."); + AgentTaskIDs := AgentTestContextImpl.GetAgentTaskIDs(Rec."Test Suite Code", VersionFilter, '', Rec."Line No."); + AgentTaskCount := AgentTestContextImpl.GetAgentTaskCount(AgentTaskIDs); + end; +} diff --git a/src/Tools/AI Test Toolkit/src/Agent/AgentTestSuite.PageExt.al b/src/Tools/AI Test Toolkit/src/Agent/AgentTestSuite.PageExt.al index 73315868a7..eb30dadad3 100644 --- a/src/Tools/AI Test Toolkit/src/Agent/AgentTestSuite.PageExt.al +++ b/src/Tools/AI Test Toolkit/src/Agent/AgentTestSuite.PageExt.al @@ -8,7 +8,7 @@ namespace System.TestLibraries.Agents; using System.Agents; using System.TestTools.AITestToolkit; -pageextension 149047 "Agent Test Suite" extends "AIT Test Suite" +pageextension 149034 "Agent Test Suite" extends "AIT Test Suite" { layout { @@ -16,6 +16,7 @@ pageextension 149047 "Agent Test Suite" extends "AIT Test Suite" { field(TestSuiteAgent; AgentUserName) { + Visible = IsAgentTestType; ApplicationArea = All; Caption = 'Agent'; ToolTip = 'Specifies the agent to be used by the tests.'; @@ -31,9 +32,48 @@ pageextension 149047 "Agent Test Suite" extends "AIT Test Suite" end; } } + addlast("Latest Run") + { + field("Copilot Credits"; CopilotCredits) + { + Visible = IsAgentTestType; + ApplicationArea = All; + AutoFormatType = 0; + Editable = false; + Caption = 'Copilot credits'; + ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks in the current version.'; + } + field("Agent Task Count"; AgentTaskCount) + { + Visible = IsAgentTestType; + ApplicationArea = All; + Editable = false; + Caption = 'Agent tasks'; + ToolTip = 'Specifies the number of Agent Tasks related to the current version.'; + + trigger OnDrillDown() + begin + AgentTestContextImpl.OpenAgentTaskList(AgentTaskIDs); + end; + } + } } trigger OnAfterGetCurrRecord() + begin + UpdateAgentTaskMetrics(); + UpdateAgentUserName(); + end; + + local procedure UpdateAgentTaskMetrics() + begin + IsAgentTestType := AgentTestContextImpl.IsAgentTestType(Rec.Code); + CopilotCredits := AgentTestContextImpl.GetCopilotCredits(Rec.Code, Rec.Version, '', 0); + AgentTaskIDs := AgentTestContextImpl.GetAgentTaskIDs(Rec.Code, Rec.Version, '', 0); + AgentTaskCount := AgentTestContextImpl.GetAgentTaskCount(AgentTaskIDs); + end; + + local procedure UpdateAgentUserName() var Agent: Codeunit Agent; begin @@ -75,6 +115,11 @@ pageextension 149047 "Agent Test Suite" extends "AIT Test Suite" end; var + AgentTestContextImpl: Codeunit "Agent Test Context Impl."; + CopilotCredits: Decimal; + AgentTaskIDs: Text; + AgentTaskCount: Integer; + IsAgentTestType: Boolean; AgentUserName: Code[50]; AgentWithNameNotFoundErr: Label 'An agent with the name %1 was not found.', Comment = '%1 - The name of the agent.'; } \ No newline at end of file diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITLogEntries.Page.al b/src/Tools/AI Test Toolkit/src/Logs/AITLogEntries.Page.al index f7a82e9b2c..d08b8041cd 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITLogEntries.Page.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITLogEntries.Page.al @@ -121,26 +121,7 @@ page 149033 "AIT Log Entries" } field("Tokens Consumed"; Rec."Tokens Consumed") { - } - field("Copilot Credits"; CopilotCredits) - { - AutoFormatType = 0; - Caption = 'Copilot credits'; - ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks for this log entry.'; - Editable = false; - } - field("Agent Task IDs"; AgentTaskIDs) - { - Caption = 'Agent tasks'; - ToolTip = 'Specifies the comma-separated list of Agent Task IDs related to this log entry.'; - Editable = false; - - trigger OnDrillDown() - var - AgentTestContextImpl: Codeunit "Agent Test Context Impl."; - begin - AgentTestContextImpl.OpenAgentTaskList(AgentTaskIDs); - end; + Visible = ShowTokens; } field(TestRunDuration; TestRunDuration) { @@ -374,8 +355,7 @@ page 149033 "AIT Log Entries" TestRunDuration: Duration; IsFilteredToErrors: Boolean; ShowSensitiveData: Boolean; - CopilotCredits: Decimal; - AgentTaskIDs: Text; + ShowTokens: Boolean; trigger OnAfterGetRecord() var @@ -387,7 +367,7 @@ page 149033 "AIT Log Entries" SetErrorFields(); SetStatusStyleExpr(); SetTurnsStyleExpr(); - UpdateAgentTaskMetrics(); + ShowTokens := AgentTestContextImpl.ShouldShowTokens(Rec."Test Suite Code"); end; local procedure SetStatusStyleExpr() @@ -440,10 +420,4 @@ page 149033 "AIT Log Entries" OutputText := Rec.GetOutputBlob(); end; end; - - local procedure UpdateAgentTaskMetrics() - begin - CopilotCredits := AgentTestContextImpl.GetCopilotCreditsForLogEntry(Rec."Entry No."); - AgentTaskIDs := AgentTestContextImpl.GetAgentTaskIDsForLogEntry(Rec."Entry No."); - end; } \ No newline at end of file diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Page.al b/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Page.al index 571bc3cc39..5726528590 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Page.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Page.al @@ -135,32 +135,10 @@ page 149032 "AIT Run History" } field("Tokens - By Version"; Rec."Tokens Consumed") { - Visible = ViewBy = ViewBy::Version; + Visible = (ViewBy = ViewBy::Version) and ShowTokens; Caption = 'Total Tokens Consumed'; ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module.'; } - field("Copilot Credits - By Version"; Rec."Copilot Credits") - { - AutoFormatType = 0; - Visible = ViewBy = ViewBy::Version; - Caption = 'Copilot credits'; - ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks in the current version.'; - Editable = false; - } - field("Agent Task IDs - By Version"; Rec."Agent Task IDs") - { - Visible = ViewBy = ViewBy::Version; - Caption = 'Agent tasks'; - ToolTip = 'Specifies the comma-separated list of Agent Task IDs related to the current version.'; - Editable = false; - - trigger OnDrillDown() - var - AgentTestContextImpl: Codeunit "Agent Test Context Impl."; - begin - AgentTestContextImpl.OpenAgentTaskList(Rec."Agent Task IDs"); - end; - } field("No. of Tests - By Tag"; Rec."No. of Tests Executed - By Tag") { Visible = ViewBy = ViewBy::Tag; @@ -203,43 +181,25 @@ page 149032 "AIT Run History" } field("Tokens - By Tag"; Rec."Tokens Consumed - By Tag") { - Visible = ViewBy = ViewBy::Tag; + Visible = (ViewBy = ViewBy::Tag) and ShowTokens; Caption = 'Total Tokens Consumed'; ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module.'; } - field("Copilot Credits - By Tag"; Rec."Copilot Credits - By Tag") - { - AutoFormatType = 0; - Visible = ViewBy = ViewBy::Tag; - Caption = 'Copilot credits'; - ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks for the tag.'; - Editable = false; - } - field("Agent Task IDs - By Tag"; Rec."Agent Task IDs - By Tag") - { - Visible = ViewBy = ViewBy::Tag; - Caption = 'Agent tasks'; - ToolTip = 'Specifies the comma-separated list of Agent Task IDs related to the tag.'; - Editable = false; - - trigger OnDrillDown() - var - AgentTestContextImpl: Codeunit "Agent Test Context Impl."; - begin - AgentTestContextImpl.OpenAgentTaskList(Rec."Agent Task IDs - By Tag"); - end; - } } } } } var + AgentTestContextImpl: Codeunit "Agent Test Context Impl."; TestSuiteCode: Code[100]; - ViewBy: Enum "AIT Run History - View By"; LineNo: Integer; ApplyLineFilter: Boolean; LineNoFilter: Text; + ShowTokens: Boolean; + + protected var + ViewBy: Enum "AIT Run History - View By"; trigger OnOpenPage() begin @@ -273,6 +233,7 @@ page 149032 "AIT Run History" LineNo := 0; AITRunHistory.GetHistory(TestSuiteCode, LineNo, ViewBy, Rec); + ShowTokens := AgentTestContextImpl.ShouldShowTokens(TestSuiteCode); CurrPage.Update(); end; } \ No newline at end of file diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Table.al b/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Table.al index c312022161..603df2eb35 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Table.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Table.al @@ -9,7 +9,6 @@ table 149036 "AIT Run History" { Caption = 'AI Eval Run History'; DataClassification = SystemMetadata; - Extensible = false; Access = Internal; ReplicateData = false; @@ -82,19 +81,6 @@ table 149036 "AIT Run History" CalcFormula = average("AIT Log Entry"."Test Method Line Accuracy" where("Test Suite Code" = field("Test Suite Code"), "Test Method Line No." = field("Line No. Filter"), Version = field("Version"), Operation = const('Run Procedure'), "Procedure Name" = filter(<> ''))); AutoFormatType = 0; } - field(15; "Copilot Credits"; Decimal) - { - AutoFormatType = 0; - Caption = 'Copilot credits'; - ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks in the current version.'; - Editable = false; - } - field(16; "Agent Task IDs"; Text[2048]) - { - Caption = 'Agent tasks'; - ToolTip = 'Specifies the comma-separated list of Agent Task IDs related to the current version.'; - Editable = false; - } field(20; "No. of Tests Executed - By Tag"; Integer) { Caption = 'No. of Evals Executed'; @@ -136,19 +122,6 @@ table 149036 "AIT Run History" CalcFormula = average("AIT Log Entry"."Test Method Line Accuracy" where("Test Suite Code" = field("Test Suite Code"), "Test Method Line No." = field("Line No. Filter"), Tag = field(Tag), Operation = const('Run Procedure'), "Procedure Name" = filter(<> ''))); AutoFormatType = 0; } - field(25; "Copilot Credits - By Tag"; Decimal) - { - AutoFormatType = 0; - Caption = 'Copilot credits'; - ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks for the tag.'; - Editable = false; - } - field(26; "Agent Task IDs - By Tag"; Text[2048]) - { - Caption = 'Agent tasks'; - ToolTip = 'Specifies the comma-separated list of Agent Task IDs related to the tag.'; - Editable = false; - } } keys diff --git a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLines.Page.al b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLines.Page.al index 4eef4a8647..448bae47ca 100644 --- a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLines.Page.al +++ b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLines.Page.al @@ -150,26 +150,7 @@ page 149034 "AIT Test Method Lines" } field("Tokens Consumed"; Rec."Tokens Consumed") { - } - field("Copilot Credits"; CopilotCredits) - { - AutoFormatType = 0; - Caption = 'Copilot credits'; - ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks for this eval line.'; - Editable = false; - } - field("Agent Task Count"; AgentTaskCount) - { - Caption = 'Agent tasks'; - ToolTip = 'Specifies the number of Agent Tasks related to this eval line.'; - Editable = false; - - trigger OnDrillDown() - var - AgentTestContextImpl: Codeunit "Agent Test Context Impl."; - begin - AgentTestContextImpl.OpenAgentTaskList(AgentTaskIDs); - end; + Visible = ShowTokens; } field(AvgDuration; AITTestSuiteMgt.GetAvgDuration(Rec)) { @@ -287,9 +268,7 @@ page 149034 "AIT Test Method Lines" NoLineSelectedErr: Label 'Select a line to compare'; TurnsText: Text; EvaluationSetupTxt: Text; - CopilotCredits: Decimal; - AgentTaskIDs: Text; - AgentTaskCount: Integer; + ShowTokens: Boolean; trigger OnInsertRecord(BelowxRec: Boolean): Boolean begin @@ -303,12 +282,11 @@ page 149034 "AIT Test Method Lines" begin EvaluationSetupTxt := AITTestSuiteMgt.GetEvaluationSetupText(CopyStr(Rec."Test Suite Code", 1, 10), Rec."Line No."); TurnsText := AITTestSuiteMgt.GetTurnsAsText(Rec); - UpdateAgentTaskMetrics(); + ShowTokens := AgentTestContextImpl.ShouldShowTokens(Rec."Test Suite Code"); end; trigger OnAfterGetCurrRecord() begin - UpdateAgentTaskMetrics(); end; local procedure GetAvg(NumIterations: Integer; TotalNo: Integer): Integer @@ -325,20 +303,6 @@ page 149034 "AIT Test Method Lines" exit(Round((100 * (No - BaseNo)) / BaseNo, 0.1)); end; - local procedure UpdateAgentTaskMetrics() - var - VersionFilter: Text; - CurrentFilterGroup: Integer; - begin - CurrentFilterGroup := Rec.FilterGroup(); - Rec.FilterGroup(4); - VersionFilter := Rec.GetFilter(Rec."Version Filter"); - Rec.FilterGroup(CurrentFilterGroup); - CopilotCredits := AgentTestContextImpl.GetCopilotCredits(Rec."Test Suite Code", VersionFilter, '', Rec."Line No."); - AgentTaskIDs := AgentTestContextImpl.GetAgentTaskIDs(Rec."Test Suite Code", VersionFilter, '', Rec."Line No."); - AgentTaskCount := AgentTestContextImpl.GetAgentTaskCount(AgentTaskIDs); - end; - internal procedure Refresh() begin CurrPage.Update(false); diff --git a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al index a8da50f324..56d20ebed7 100644 --- a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al +++ b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al @@ -33,6 +33,10 @@ page 149031 "AIT Test Suite" field(Description; Rec.Description) { } + field(TestType; Rec."Test Type") + { + Importance = Additional; + } field(Dataset; Rec."Input Dataset") { ShowMandatory = true; @@ -214,30 +218,14 @@ page 149031 "AIT Test Suite" } field("Tokens Consumed"; Rec."Tokens Consumed") { + Visible = ShowTokens; } field("Average Tokens Consumed"; AvgTokensConsumed) { Editable = false; Caption = 'Average Tokens Consumed'; ToolTip = 'Specifies the average number of tokens consumed by the evals in the last run.'; - } - field("Copilot Credits"; CopilotCredits) - { - AutoFormatType = 0; - Editable = false; - Caption = 'Copilot credits'; - ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks in the current version.'; - } - field("Agent Task Count"; AgentTaskCount) - { - Editable = false; - Caption = 'Agent tasks'; - ToolTip = 'Specifies the number of Agent Tasks related to the current version.'; - - trigger OnDrillDown() - begin - AgentTestContextImpl.OpenAgentTaskList(AgentTaskIDs); - end; + Visible = ShowTokens; } } @@ -431,14 +419,12 @@ page 149031 "AIT Test Suite" AvgTimeDuration: Duration; AvgTokensConsumed: Integer; TotalDuration: Duration; - CopilotCredits: Decimal; - AgentTaskIDs: Text; - AgentTaskCount: Integer; PageCaptionLbl: Label 'AI Eval'; TestRunnerDisplayName: Text; Language: Text; InputDatasetChangedQst: Label 'You have modified the input dataset.\\Do you want to update the lines?'; EvaluationSetupTxt: Text; + ShowTokens: Boolean; trigger OnOpenPage() var @@ -459,10 +445,10 @@ page 149031 "AIT Test Suite" begin UpdateTotalDuration(); UpdateAverages(); - UpdateAgentTaskMetrics(); Language := AITTestSuiteLanguage.GetLanguageDisplayName(Rec."Run Language ID"); TestRunnerDisplayName := TestSuiteMgt.GetTestRunnerDisplayName(Rec."Test Runner Id"); EvaluationSetupTxt := AITTestSuiteMgt.GetEvaluationSetupText(Rec.Code, 0); + ShowTokens := AgentTestContextImpl.ShouldShowTokens(Rec.Code); end; local procedure UpdateTotalDuration() @@ -484,11 +470,4 @@ page 149031 "AIT Test Suite" else AvgTokensConsumed := 0; end; - - local procedure UpdateAgentTaskMetrics() - begin - CopilotCredits := AgentTestContextImpl.GetCopilotCredits(Rec.Code, Rec.Version, '', 0); - AgentTaskIDs := AgentTestContextImpl.GetAgentTaskIDs(Rec.Code, Rec.Version, '', 0); - AgentTaskCount := AgentTestContextImpl.GetAgentTaskCount(AgentTaskIDs); - end; } \ No newline at end of file From 6260cb997516ff6f4f1970e8b12560955d3a96d2 Mon Sep 17 00:00:00 2001 From: Nikola Kukrika Date: Thu, 26 Feb 2026 22:38:57 +0100 Subject: [PATCH 07/17] Small refactoring --- .../src/Logs/AITTestMethodLinesCompare.Page.al | 10 ---------- .../src/Logs/AITTestSuiteCompare.Page.al | 10 ---------- .../src/TestSuite/AITTestMethodLines.Page.al | 12 +++++++++--- .../src/TestSuite/AITTestSuite.Page.al | 6 ++++++ 4 files changed, 15 insertions(+), 23 deletions(-) diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITTestMethodLinesCompare.Page.al b/src/Tools/AI Test Toolkit/src/Logs/AITTestMethodLinesCompare.Page.al index eee8009092..8e68da352b 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITTestMethodLinesCompare.Page.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITTestMethodLinesCompare.Page.al @@ -83,16 +83,6 @@ page 149035 "AIT Test Method Lines Compare" Caption = 'Total Tokens Consumed'; ToolTip = 'Specifies the aggregated number of tokens consumed by the eval. This is applicable only when using Microsoft AI Module.'; } - label(CopilotCredits) - { - Caption = 'Copilot credits'; - ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks.'; - } - label(AgentTaskIDs) - { - Caption = 'Agent tasks'; - ToolTip = 'Specifies the comma-separated list of Agent Task IDs.'; - } } group("Latest Version") { diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITTestSuiteCompare.Page.al b/src/Tools/AI Test Toolkit/src/Logs/AITTestSuiteCompare.Page.al index d840b4d441..b3f46516e6 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITTestSuiteCompare.Page.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITTestSuiteCompare.Page.al @@ -84,16 +84,6 @@ page 149036 "AIT Test Suite Compare" Caption = 'Total Tokens Consumed'; ToolTip = 'Specifies the aggregated number of tokens consumed by the eval. This is applicable only when using Microsoft AI Module.'; } - label(CopilotCredits) - { - Caption = 'Copilot credits'; - ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks.'; - } - label(AgentTaskIDs) - { - Caption = 'Agent tasks'; - ToolTip = 'Specifies the comma-separated list of Agent Task IDs.'; - } } group("Latest Version") { diff --git a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLines.Page.al b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLines.Page.al index 448bae47ca..3a43d50e10 100644 --- a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLines.Page.al +++ b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLines.Page.al @@ -280,13 +280,19 @@ page 149034 "AIT Test Method Lines" trigger OnAfterGetRecord() begin - EvaluationSetupTxt := AITTestSuiteMgt.GetEvaluationSetupText(CopyStr(Rec."Test Suite Code", 1, 10), Rec."Line No."); - TurnsText := AITTestSuiteMgt.GetTurnsAsText(Rec); - ShowTokens := AgentTestContextImpl.ShouldShowTokens(Rec."Test Suite Code"); + UpdateControls(); end; trigger OnAfterGetCurrRecord() begin + UpdateControls(); + end; + + local procedure UpdateControls() + begin + EvaluationSetupTxt := AITTestSuiteMgt.GetEvaluationSetupText(CopyStr(Rec."Test Suite Code", 1, 10), Rec."Line No."); + TurnsText := AITTestSuiteMgt.GetTurnsAsText(Rec); + ShowTokens := AgentTestContextImpl.ShouldShowTokens(Rec."Test Suite Code"); end; local procedure GetAvg(NumIterations: Integer; TotalNo: Integer): Integer diff --git a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al index 56d20ebed7..9bf6afd8a5 100644 --- a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al +++ b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al @@ -36,6 +36,11 @@ page 149031 "AIT Test Suite" field(TestType; Rec."Test Type") { Importance = Additional; + trigger OnValidate() + begin + if Rec."Test Type" <> xRec."Test Type" then + Message(YouNeedToOpenAndCloseThePageMsg); + end; } field(Dataset; Rec."Input Dataset") { @@ -423,6 +428,7 @@ page 149031 "AIT Test Suite" TestRunnerDisplayName: Text; Language: Text; InputDatasetChangedQst: Label 'You have modified the input dataset.\\Do you want to update the lines?'; + YouNeedToOpenAndCloseThePageMsg: Label 'You need to open and close the page for the change to take effect on the UI controls.'; EvaluationSetupTxt: Text; ShowTokens: Boolean; From 18cabdb846bcbf0b55d86d9141f747cb4c375524 Mon Sep 17 00:00:00 2001 From: Nikola Kukrika Date: Fri, 27 Feb 2026 10:15:05 +0100 Subject: [PATCH 08/17] Refactoring --- .../src/Agent/AgentLogEntries.PageExt.al | 4 ---- .../src/Agent/AgentRunHistory.PageExt.al | 22 +++++-------------- .../Agent/AgentTestContextImpl.Codeunit.al | 22 ------------------- .../src/Agent/AgentTestMethodLines.PageExt.al | 5 ----- .../src/Agent/AgentTestSuite.PageExt.al | 5 ----- .../src/Logs/AITLogEntries.Page.al | 4 ---- .../src/Logs/AITRunHistory.Page.al | 7 ++---- .../src/TestSuite/AITTestMethodLines.Page.al | 4 ---- .../src/TestSuite/AITTestSuite.Page.al | 5 ----- 9 files changed, 7 insertions(+), 71 deletions(-) diff --git a/src/Tools/AI Test Toolkit/src/Agent/AgentLogEntries.PageExt.al b/src/Tools/AI Test Toolkit/src/Agent/AgentLogEntries.PageExt.al index 02f7cedf65..83ffb0f25f 100644 --- a/src/Tools/AI Test Toolkit/src/Agent/AgentLogEntries.PageExt.al +++ b/src/Tools/AI Test Toolkit/src/Agent/AgentLogEntries.PageExt.al @@ -18,7 +18,6 @@ pageextension 149030 "Agent Log Entries" extends "AIT Log Entries" Caption = 'Copilot credits'; ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks for this log entry.'; Editable = false; - Visible = IsAgentTestType; } field("Agent Task IDs"; AgentTaskIDs) { @@ -26,7 +25,6 @@ pageextension 149030 "Agent Log Entries" extends "AIT Log Entries" Caption = 'Agent tasks'; ToolTip = 'Specifies the comma-separated list of Agent Task IDs related to this log entry.'; Editable = false; - Visible = IsAgentTestType; trigger OnDrillDown() var @@ -42,7 +40,6 @@ pageextension 149030 "Agent Log Entries" extends "AIT Log Entries" AgentTestContextImpl: Codeunit "Agent Test Context Impl."; CopilotCredits: Decimal; AgentTaskIDs: Text; - IsAgentTestType: Boolean; trigger OnAfterGetRecord() begin @@ -51,7 +48,6 @@ pageextension 149030 "Agent Log Entries" extends "AIT Log Entries" local procedure UpdateAgentTaskMetrics() begin - IsAgentTestType := AgentTestContextImpl.IsAgentTestType(Rec."Test Suite Code"); CopilotCredits := AgentTestContextImpl.GetCopilotCreditsForLogEntry(Rec."Entry No."); AgentTaskIDs := AgentTestContextImpl.GetAgentTaskIDsForLogEntry(Rec."Entry No."); end; diff --git a/src/Tools/AI Test Toolkit/src/Agent/AgentRunHistory.PageExt.al b/src/Tools/AI Test Toolkit/src/Agent/AgentRunHistory.PageExt.al index 61d7ddea93..0f34da3f3c 100644 --- a/src/Tools/AI Test Toolkit/src/Agent/AgentRunHistory.PageExt.al +++ b/src/Tools/AI Test Toolkit/src/Agent/AgentRunHistory.PageExt.al @@ -15,7 +15,7 @@ pageextension 149032 "Agent Run History" extends "AIT Run History" { ApplicationArea = All; AutoFormatType = 0; - Visible = (ViewBy = ViewBy::Version) and IsAgentTestType; + Visible = ViewBy = ViewBy::Version; Caption = 'Copilot credits'; ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks in the current version.'; Editable = false; @@ -23,7 +23,7 @@ pageextension 149032 "Agent Run History" extends "AIT Run History" field("Agent Task IDs - By Version"; Rec."Agent Task IDs") { ApplicationArea = All; - Visible = (ViewBy = ViewBy::Version) and IsAgentTestType; + Visible = ViewBy = ViewBy::Version; Caption = 'Agent tasks'; ToolTip = 'Specifies the comma-separated list of Agent Task IDs related to the current version.'; Editable = false; @@ -42,7 +42,7 @@ pageextension 149032 "Agent Run History" extends "AIT Run History" { ApplicationArea = All; AutoFormatType = 0; - Visible = (ViewBy = ViewBy::Tag) and IsAgentTestType; + Visible = ViewBy = ViewBy::Tag; Caption = 'Copilot credits'; ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks for the tag.'; Editable = false; @@ -50,7 +50,7 @@ pageextension 149032 "Agent Run History" extends "AIT Run History" field("Agent Task IDs - By Tag"; Rec."Agent Task IDs - By Tag") { ApplicationArea = All; - Visible = (ViewBy = ViewBy::Tag) and IsAgentTestType; + Visible = ViewBy = ViewBy::Tag; Caption = 'Agent tasks'; ToolTip = 'Specifies the comma-separated list of Agent Task IDs related to the tag.'; Editable = false; @@ -65,17 +65,5 @@ pageextension 149032 "Agent Run History" extends "AIT Run History" } } - var - AgentTestContextImpl: Codeunit "Agent Test Context Impl."; - IsAgentTestType: Boolean; - - trigger OnAfterGetRecord() - begin - UpdateVisibility(); - end; - - local procedure UpdateVisibility() - begin - IsAgentTestType := AgentTestContextImpl.IsAgentTestType(Rec."Test Suite Code"); - end; } + diff --git a/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al b/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al index dcc6d9eee6..1f4ebf45be 100644 --- a/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al +++ b/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al @@ -6,7 +6,6 @@ namespace System.TestTools.AITestToolkit; using System.Agents; -using System.Environment; using System.TestTools.TestRunner; codeunit 149049 "Agent Test Context Impl." @@ -178,27 +177,6 @@ codeunit 149049 "Agent Test Context Impl." exit(TaskIDList.Count()); end; - procedure IsAgentTestType(TestSuiteCode: Code[100]): Boolean - var - AITTestSuite: Record "AIT Test Suite"; - begin - if not AITTestSuite.Get(TestSuiteCode) then - exit(false); - - exit(AITTestSuite."Test Type" = AITTestSuite."Test Type"::Agent); - end; - - procedure ShouldShowTokens(TestSuiteCode: Code[100]): Boolean - var - EnvironmentInformation: Codeunit "Environment Information"; - begin - // Hide tokens if it's Agent test type AND SaaS environment - if IsAgentTestType(TestSuiteCode) and EnvironmentInformation.IsSaaSInfrastructure() then - exit(false); - - exit(true); - end; - procedure OpenAgentTaskList(CommaSeparatedTaskIDs: Text) var AgentTask: Record "Agent Task"; diff --git a/src/Tools/AI Test Toolkit/src/Agent/AgentTestMethodLines.PageExt.al b/src/Tools/AI Test Toolkit/src/Agent/AgentTestMethodLines.PageExt.al index 0da2de7c65..7f6336d7ed 100644 --- a/src/Tools/AI Test Toolkit/src/Agent/AgentTestMethodLines.PageExt.al +++ b/src/Tools/AI Test Toolkit/src/Agent/AgentTestMethodLines.PageExt.al @@ -18,7 +18,6 @@ pageextension 149033 "Agent Test Method Lines" extends "AIT Test Method Lines" Caption = 'Copilot credits'; ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks for this eval line.'; Editable = false; - Visible = IsAgentTestType; } field("Agent Task Count"; AgentTaskCount) { @@ -26,7 +25,6 @@ pageextension 149033 "Agent Test Method Lines" extends "AIT Test Method Lines" Caption = 'Agent tasks'; ToolTip = 'Specifies the number of Agent Tasks related to this eval line.'; Editable = false; - Visible = IsAgentTestType; trigger OnDrillDown() var @@ -43,7 +41,6 @@ pageextension 149033 "Agent Test Method Lines" extends "AIT Test Method Lines" CopilotCredits: Decimal; AgentTaskIDs: Text; AgentTaskCount: Integer; - IsAgentTestType: Boolean; trigger OnAfterGetRecord() begin @@ -60,8 +57,6 @@ pageextension 149033 "Agent Test Method Lines" extends "AIT Test Method Lines" VersionFilter: Text; CurrentFilterGroup: Integer; begin - IsAgentTestType := AgentTestContextImpl.IsAgentTestType(Rec."Test Suite Code"); - CurrentFilterGroup := Rec.FilterGroup(); Rec.FilterGroup(4); VersionFilter := Rec.GetFilter(Rec."Version Filter"); diff --git a/src/Tools/AI Test Toolkit/src/Agent/AgentTestSuite.PageExt.al b/src/Tools/AI Test Toolkit/src/Agent/AgentTestSuite.PageExt.al index eb30dadad3..5bfd848df1 100644 --- a/src/Tools/AI Test Toolkit/src/Agent/AgentTestSuite.PageExt.al +++ b/src/Tools/AI Test Toolkit/src/Agent/AgentTestSuite.PageExt.al @@ -16,7 +16,6 @@ pageextension 149034 "Agent Test Suite" extends "AIT Test Suite" { field(TestSuiteAgent; AgentUserName) { - Visible = IsAgentTestType; ApplicationArea = All; Caption = 'Agent'; ToolTip = 'Specifies the agent to be used by the tests.'; @@ -36,7 +35,6 @@ pageextension 149034 "Agent Test Suite" extends "AIT Test Suite" { field("Copilot Credits"; CopilotCredits) { - Visible = IsAgentTestType; ApplicationArea = All; AutoFormatType = 0; Editable = false; @@ -45,7 +43,6 @@ pageextension 149034 "Agent Test Suite" extends "AIT Test Suite" } field("Agent Task Count"; AgentTaskCount) { - Visible = IsAgentTestType; ApplicationArea = All; Editable = false; Caption = 'Agent tasks'; @@ -67,7 +64,6 @@ pageextension 149034 "Agent Test Suite" extends "AIT Test Suite" local procedure UpdateAgentTaskMetrics() begin - IsAgentTestType := AgentTestContextImpl.IsAgentTestType(Rec.Code); CopilotCredits := AgentTestContextImpl.GetCopilotCredits(Rec.Code, Rec.Version, '', 0); AgentTaskIDs := AgentTestContextImpl.GetAgentTaskIDs(Rec.Code, Rec.Version, '', 0); AgentTaskCount := AgentTestContextImpl.GetAgentTaskCount(AgentTaskIDs); @@ -119,7 +115,6 @@ pageextension 149034 "Agent Test Suite" extends "AIT Test Suite" CopilotCredits: Decimal; AgentTaskIDs: Text; AgentTaskCount: Integer; - IsAgentTestType: Boolean; AgentUserName: Code[50]; AgentWithNameNotFoundErr: Label 'An agent with the name %1 was not found.', Comment = '%1 - The name of the agent.'; } \ No newline at end of file diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITLogEntries.Page.al b/src/Tools/AI Test Toolkit/src/Logs/AITLogEntries.Page.al index d08b8041cd..20788758c6 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITLogEntries.Page.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITLogEntries.Page.al @@ -121,7 +121,6 @@ page 149033 "AIT Log Entries" } field("Tokens Consumed"; Rec."Tokens Consumed") { - Visible = ShowTokens; } field(TestRunDuration; TestRunDuration) { @@ -342,7 +341,6 @@ page 149033 "AIT Log Entries" } var - AgentTestContextImpl: Codeunit "Agent Test Context Impl."; ClickToShowLbl: Label 'Show eval input'; DoYouWantToDeleteQst: Label 'Do you want to delete all entries within the filter?'; InputText: Text; @@ -355,7 +353,6 @@ page 149033 "AIT Log Entries" TestRunDuration: Duration; IsFilteredToErrors: Boolean; ShowSensitiveData: Boolean; - ShowTokens: Boolean; trigger OnAfterGetRecord() var @@ -367,7 +364,6 @@ page 149033 "AIT Log Entries" SetErrorFields(); SetStatusStyleExpr(); SetTurnsStyleExpr(); - ShowTokens := AgentTestContextImpl.ShouldShowTokens(Rec."Test Suite Code"); end; local procedure SetStatusStyleExpr() diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Page.al b/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Page.al index 5726528590..6bbc973b53 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Page.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Page.al @@ -135,7 +135,7 @@ page 149032 "AIT Run History" } field("Tokens - By Version"; Rec."Tokens Consumed") { - Visible = (ViewBy = ViewBy::Version) and ShowTokens; + Visible = ViewBy = ViewBy::Version; Caption = 'Total Tokens Consumed'; ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module.'; } @@ -181,7 +181,7 @@ page 149032 "AIT Run History" } field("Tokens - By Tag"; Rec."Tokens Consumed - By Tag") { - Visible = (ViewBy = ViewBy::Tag) and ShowTokens; + Visible = ViewBy = ViewBy::Tag; Caption = 'Total Tokens Consumed'; ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module.'; } @@ -191,12 +191,10 @@ page 149032 "AIT Run History" } var - AgentTestContextImpl: Codeunit "Agent Test Context Impl."; TestSuiteCode: Code[100]; LineNo: Integer; ApplyLineFilter: Boolean; LineNoFilter: Text; - ShowTokens: Boolean; protected var ViewBy: Enum "AIT Run History - View By"; @@ -233,7 +231,6 @@ page 149032 "AIT Run History" LineNo := 0; AITRunHistory.GetHistory(TestSuiteCode, LineNo, ViewBy, Rec); - ShowTokens := AgentTestContextImpl.ShouldShowTokens(TestSuiteCode); CurrPage.Update(); end; } \ No newline at end of file diff --git a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLines.Page.al b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLines.Page.al index 3a43d50e10..d0530a2d62 100644 --- a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLines.Page.al +++ b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLines.Page.al @@ -150,7 +150,6 @@ page 149034 "AIT Test Method Lines" } field("Tokens Consumed"; Rec."Tokens Consumed") { - Visible = ShowTokens; } field(AvgDuration; AITTestSuiteMgt.GetAvgDuration(Rec)) { @@ -264,11 +263,9 @@ page 149034 "AIT Test Method Lines" var AITTestSuite: Record "AIT Test Suite"; AITTestSuiteMgt: Codeunit "AIT Test Suite Mgt."; - AgentTestContextImpl: Codeunit "Agent Test Context Impl."; NoLineSelectedErr: Label 'Select a line to compare'; TurnsText: Text; EvaluationSetupTxt: Text; - ShowTokens: Boolean; trigger OnInsertRecord(BelowxRec: Boolean): Boolean begin @@ -292,7 +289,6 @@ page 149034 "AIT Test Method Lines" begin EvaluationSetupTxt := AITTestSuiteMgt.GetEvaluationSetupText(CopyStr(Rec."Test Suite Code", 1, 10), Rec."Line No."); TurnsText := AITTestSuiteMgt.GetTurnsAsText(Rec); - ShowTokens := AgentTestContextImpl.ShouldShowTokens(Rec."Test Suite Code"); end; local procedure GetAvg(NumIterations: Integer; TotalNo: Integer): Integer diff --git a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al index 9bf6afd8a5..d158920ce7 100644 --- a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al +++ b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al @@ -223,14 +223,12 @@ page 149031 "AIT Test Suite" } field("Tokens Consumed"; Rec."Tokens Consumed") { - Visible = ShowTokens; } field("Average Tokens Consumed"; AvgTokensConsumed) { Editable = false; Caption = 'Average Tokens Consumed'; ToolTip = 'Specifies the average number of tokens consumed by the evals in the last run.'; - Visible = ShowTokens; } } @@ -420,7 +418,6 @@ page 149031 "AIT Test Suite" var AITTestSuiteMgt: Codeunit "AIT Test Suite Mgt."; - AgentTestContextImpl: Codeunit "Agent Test Context Impl."; AvgTimeDuration: Duration; AvgTokensConsumed: Integer; TotalDuration: Duration; @@ -430,7 +427,6 @@ page 149031 "AIT Test Suite" InputDatasetChangedQst: Label 'You have modified the input dataset.\\Do you want to update the lines?'; YouNeedToOpenAndCloseThePageMsg: Label 'You need to open and close the page for the change to take effect on the UI controls.'; EvaluationSetupTxt: Text; - ShowTokens: Boolean; trigger OnOpenPage() var @@ -454,7 +450,6 @@ page 149031 "AIT Test Suite" Language := AITTestSuiteLanguage.GetLanguageDisplayName(Rec."Run Language ID"); TestRunnerDisplayName := TestSuiteMgt.GetTestRunnerDisplayName(Rec."Test Runner Id"); EvaluationSetupTxt := AITTestSuiteMgt.GetEvaluationSetupText(Rec.Code, 0); - ShowTokens := AgentTestContextImpl.ShouldShowTokens(Rec.Code); end; local procedure UpdateTotalDuration() From deaa57e6ca31fb6fffc9fc8fc0b0933d21e1c11f Mon Sep 17 00:00:00 2001 From: Nikola Kukrika Date: Fri, 27 Feb 2026 10:38:06 +0100 Subject: [PATCH 09/17] Removing the dynamic visibility and a fix on typing the agent --- src/Tools/AI Test Toolkit/src/Agent/AgentTestSuite.PageExt.al | 2 ++ src/Tools/AI Test Toolkit/src/Logs/AITLogEntry.Table.al | 2 +- src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Page.al | 4 ++-- src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Table.al | 4 ++-- .../src/Logs/AITTestMethodLinesCompare.Page.al | 2 +- .../AI Test Toolkit/src/Logs/AITTestSuiteCompare.Page.al | 2 +- .../AI Test Toolkit/src/TestSuite/AITTestMethodLine.Table.al | 4 ++-- src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al | 2 +- src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Table.al | 2 +- 9 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/Tools/AI Test Toolkit/src/Agent/AgentTestSuite.PageExt.al b/src/Tools/AI Test Toolkit/src/Agent/AgentTestSuite.PageExt.al index 5bfd848df1..a610e711fc 100644 --- a/src/Tools/AI Test Toolkit/src/Agent/AgentTestSuite.PageExt.al +++ b/src/Tools/AI Test Toolkit/src/Agent/AgentTestSuite.PageExt.al @@ -97,6 +97,7 @@ pageextension 149034 "Agent Test Suite" extends "AIT Test Suite" local procedure ValidateAgentName() var AgentSetup: Codeunit "Agent Setup"; + Agent: Codeunit Agent; begin if AgentUserName = '' then begin Clear(Rec."Agent User Security ID"); @@ -107,6 +108,7 @@ pageextension 149034 "Agent Test Suite" extends "AIT Test Suite" if not AgentSetup.FindAgentByUserName(AgentUserName, Rec."Agent User Security ID") then Error(AgentWithNameNotFoundErr, AgentUserName); + AgentUserName := Agent.GetUserName(Rec."Agent User Security ID"); Rec.Modify(); end; diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITLogEntry.Table.al b/src/Tools/AI Test Toolkit/src/Logs/AITLogEntry.Table.al index ead956f417..5aa2599c3a 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITLogEntry.Table.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITLogEntry.Table.al @@ -179,7 +179,7 @@ table 149034 "AIT Log Entry" field(50; "Tokens Consumed"; Integer) { Caption = 'Total Tokens Consumed'; - ToolTip = 'Specifies the aggregated number of tokens consumed by the eval. This is applicable only when using Microsoft AI Module.'; + ToolTip = 'Specifies the aggregated number of tokens consumed by the eval. This is applicable only when using Microsoft AI Module.Tokens consumed by the agent sessions are not included in this number.'; } } diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Page.al b/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Page.al index 6bbc973b53..91b9b1d2a4 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Page.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Page.al @@ -137,7 +137,7 @@ page 149032 "AIT Run History" { Visible = ViewBy = ViewBy::Version; Caption = 'Total Tokens Consumed'; - ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module.'; + ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module.Tokens consumed by the agent sessions are not included in this number.'; } field("No. of Tests - By Tag"; Rec."No. of Tests Executed - By Tag") { @@ -183,7 +183,7 @@ page 149032 "AIT Run History" { Visible = ViewBy = ViewBy::Tag; Caption = 'Total Tokens Consumed'; - ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module.'; + ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module.Tokens consumed by the agent sessions are not included in this number.'; } } } diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Table.al b/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Table.al index 603df2eb35..040edccf9b 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Table.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Table.al @@ -67,7 +67,7 @@ table 149036 "AIT Run History" field(13; "Tokens Consumed"; Integer) { Caption = 'Total Tokens Consumed'; - ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module.'; + ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module.Tokens consumed by the agent sessions are not included in this number.'; Editable = false; FieldClass = FlowField; CalcFormula = sum("AIT Log Entry"."Tokens Consumed" where("Test Suite Code" = field("Test Suite Code"), Version = field("Version"), "Test Method Line No." = field("Line No. Filter"), Operation = const('Run Procedure'), "Procedure Name" = filter(<> ''))); @@ -108,7 +108,7 @@ table 149036 "AIT Run History" field(23; "Tokens Consumed - By Tag"; Integer) { Caption = 'Total Tokens Consumed'; - ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module.'; + ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module.Tokens consumed by the agent sessions are not included in this number.'; Editable = false; FieldClass = FlowField; CalcFormula = sum("AIT Log Entry"."Tokens Consumed" where("Test Suite Code" = field("Test Suite Code"), "Test Method Line No." = field("Line No. Filter"), Tag = field(Tag), Operation = const('Run Procedure'), "Procedure Name" = filter(<> ''))); diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITTestMethodLinesCompare.Page.al b/src/Tools/AI Test Toolkit/src/Logs/AITTestMethodLinesCompare.Page.al index 8e68da352b..d0f5a91201 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITTestMethodLinesCompare.Page.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITTestMethodLinesCompare.Page.al @@ -81,7 +81,7 @@ page 149035 "AIT Test Method Lines Compare" label(TokensConsumed) { Caption = 'Total Tokens Consumed'; - ToolTip = 'Specifies the aggregated number of tokens consumed by the eval. This is applicable only when using Microsoft AI Module.'; + ToolTip = 'Specifies the aggregated number of tokens consumed by the eval. This is applicable only when using Microsoft AI Module.Tokens consumed by the agent sessions are not included in this number.'; } } group("Latest Version") diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITTestSuiteCompare.Page.al b/src/Tools/AI Test Toolkit/src/Logs/AITTestSuiteCompare.Page.al index b3f46516e6..724df70203 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITTestSuiteCompare.Page.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITTestSuiteCompare.Page.al @@ -82,7 +82,7 @@ page 149036 "AIT Test Suite Compare" label(TokensConsumed) { Caption = 'Total Tokens Consumed'; - ToolTip = 'Specifies the aggregated number of tokens consumed by the eval. This is applicable only when using Microsoft AI Module.'; + ToolTip = 'Specifies the aggregated number of tokens consumed by the eval. This is applicable only when using Microsoft AI Module.Tokens consumed by the agent sessions are not included in this number.'; } } group("Latest Version") diff --git a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLine.Table.al b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLine.Table.al index 34c82f0a89..2fd03c94bd 100644 --- a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLine.Table.al +++ b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLine.Table.al @@ -209,7 +209,7 @@ table 149032 "AIT Test Method Line" field(120; "Tokens Consumed"; Integer) { Caption = 'Total Tokens Consumed'; - ToolTip = 'Specifies the number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module.'; + ToolTip = 'Specifies the number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module.Tokens consumed by the agent sessions are not included in this number.'; Editable = false; FieldClass = FlowField; CalcFormula = sum("AIT Log Entry"."Tokens Consumed" where("Test Suite Code" = field("Test Suite Code"), "Test Method Line No." = field("Line No."), Version = field("Version Filter"), Operation = const('Run Procedure'), "Procedure Name" = filter(<> ''))); @@ -221,7 +221,7 @@ table 149032 "AIT Test Method Line" ObsoleteReason = 'This field is deprecated as it is not used in any page or calculation. It will be removed in future versions.'; ObsoleteTag = '26.0'; Caption = 'Tokens Consumed - Base'; - ToolTip = 'Specifies the number of tokens consumed by the eval in the base version. This is applicable only when using Microsoft AI Module.'; + ToolTip = 'Specifies the number of tokens consumed by the eval in the base version. This is applicable only when using Microsoft AI Module.Tokens consumed by the agent sessions are not included in this number.'; Editable = false; FieldClass = FlowField; CalcFormula = sum("AIT Log Entry"."Tokens Consumed" where("Test Suite Code" = field("Test Suite Code"), "Test Method Line No." = field("Line No."), Version = field("Base Version Filter"), Operation = const('Run Procedure'), "Procedure Name" = filter(<> ''))); diff --git a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al index d158920ce7..10bd7f612f 100644 --- a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al +++ b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al @@ -228,7 +228,7 @@ page 149031 "AIT Test Suite" { Editable = false; Caption = 'Average Tokens Consumed'; - ToolTip = 'Specifies the average number of tokens consumed by the evals in the last run.'; + ToolTip = 'Specifies the average number of tokens consumed by the evals in the last run.Tokens consumed by the agent sessions are not included in this number.'; } } diff --git a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Table.al b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Table.al index c743b39bbc..a0841a66a7 100644 --- a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Table.al +++ b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Table.al @@ -167,7 +167,7 @@ table 149030 "AIT Test Suite" field(24; "Tokens Consumed"; Integer) { Caption = 'Total Tokens Consumed'; - ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module.'; + ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module.Tokens consumed by the agent sessions are not included in this number.'; Editable = false; FieldClass = FlowField; CalcFormula = sum("AIT Log Entry"."Tokens Consumed" where("Test Suite Code" = field("Code"), Version = field("Version"), Operation = const('Run Procedure'), "Procedure Name" = filter(<> ''))); From bfdf7f8c318501b119f4bbb3d099c92ec23fefc6 Mon Sep 17 00:00:00 2001 From: Nikola Kukrika Date: Fri, 27 Feb 2026 12:15:17 +0100 Subject: [PATCH 10/17] Adding count for tasks on the history page --- .../src/Agent/AgentRunHistory.PageExt.al | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/Tools/AI Test Toolkit/src/Agent/AgentRunHistory.PageExt.al b/src/Tools/AI Test Toolkit/src/Agent/AgentRunHistory.PageExt.al index 0f34da3f3c..d115208029 100644 --- a/src/Tools/AI Test Toolkit/src/Agent/AgentRunHistory.PageExt.al +++ b/src/Tools/AI Test Toolkit/src/Agent/AgentRunHistory.PageExt.al @@ -20,12 +20,12 @@ pageextension 149032 "Agent Run History" extends "AIT Run History" ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks in the current version.'; Editable = false; } - field("Agent Task IDs - By Version"; Rec."Agent Task IDs") + field("Agent Task Count - By Version"; AgentTaskCountByVersion) { ApplicationArea = All; Visible = ViewBy = ViewBy::Version; Caption = 'Agent tasks'; - ToolTip = 'Specifies the comma-separated list of Agent Task IDs related to the current version.'; + ToolTip = 'Specifies the number of Agent Tasks related to the current version.'; Editable = false; trigger OnDrillDown() @@ -47,12 +47,12 @@ pageextension 149032 "Agent Run History" extends "AIT Run History" ToolTip = 'Specifies the total Copilot Credits consumed by the Agent Tasks for the tag.'; Editable = false; } - field("Agent Task IDs - By Tag"; Rec."Agent Task IDs - By Tag") + field("Agent Task Count - By Tag"; AgentTaskCountByTag) { ApplicationArea = All; Visible = ViewBy = ViewBy::Tag; Caption = 'Agent tasks'; - ToolTip = 'Specifies the comma-separated list of Agent Task IDs related to the tag.'; + ToolTip = 'Specifies the number of Agent Tasks related to the tag.'; Editable = false; trigger OnDrillDown() @@ -65,5 +65,25 @@ pageextension 149032 "Agent Run History" extends "AIT Run History" } } + var + AgentTestContextImpl: Codeunit "Agent Test Context Impl."; + AgentTaskCountByVersion: Integer; + AgentTaskCountByTag: Integer; + + trigger OnAfterGetRecord() + begin + UpdateAgentTaskCounts(); + end; + + trigger OnAfterGetCurrRecord() + begin + UpdateAgentTaskCounts(); + end; + + local procedure UpdateAgentTaskCounts() + begin + AgentTaskCountByVersion := AgentTestContextImpl.GetAgentTaskCount(Rec."Agent Task IDs"); + AgentTaskCountByTag := AgentTestContextImpl.GetAgentTaskCount(Rec."Agent Task IDs - By Tag"); + end; } From 74e88aa1bf2afe1d44e89f304c456532b92f0d83 Mon Sep 17 00:00:00 2001 From: Nikola Kukrika Date: Fri, 27 Feb 2026 12:27:06 +0100 Subject: [PATCH 11/17] Polishing code --- .../Internal/AgentTaskMsgBuilderImpl.Codeunit.al | 6 +++--- .../App/Agent/Setup/SetupPart/AgentSetup.Codeunit.al | 3 ++- .../AI Test Toolkit/src/Agent/AgentTaskLog.Table.al | 2 +- .../src/Agent/AgentTestContextImpl.Codeunit.al | 9 +-------- .../src/TestSuite/AITTestMethodLine.Table.al | 2 ++ .../src/TestSuite/AITTestSuiteMgt.Codeunit.al | 8 ++------ 6 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/System Application/App/Agent/Interaction/Internal/AgentTaskMsgBuilderImpl.Codeunit.al b/src/System Application/App/Agent/Interaction/Internal/AgentTaskMsgBuilderImpl.Codeunit.al index 960b935ce5..ecd57c9a6a 100644 --- a/src/System Application/App/Agent/Interaction/Internal/AgentTaskMsgBuilderImpl.Codeunit.al +++ b/src/System Application/App/Agent/Interaction/Internal/AgentTaskMsgBuilderImpl.Codeunit.al @@ -152,11 +152,11 @@ codeunit 4311 "Agent Task Msg. Builder Impl." [Scope('OnPrem')] procedure AddAttachment(var AgentTaskFile: Record "Agent Task File"): codeunit "Agent Task Msg. Builder Impl." var - InStream: InStream; + FileInStream: InStream; begin AgentTaskFile.CalcFields(Content); - AgentTaskFile.Content.CreateInStream(InStream); - AddAttachment(AgentTaskFile."File Name", AgentTaskFile."File MIME Type", InStream); + AgentTaskFile.Content.CreateInStream(FileInStream); + AddAttachment(AgentTaskFile."File Name", AgentTaskFile."File MIME Type", FileInStream); exit(this); end; diff --git a/src/System Application/App/Agent/Setup/SetupPart/AgentSetup.Codeunit.al b/src/System Application/App/Agent/Setup/SetupPart/AgentSetup.Codeunit.al index c33d1be78e..a54ce15bd3 100644 --- a/src/System Application/App/Agent/Setup/SetupPart/AgentSetup.Codeunit.al +++ b/src/System Application/App/Agent/Setup/SetupPart/AgentSetup.Codeunit.al @@ -109,7 +109,8 @@ codeunit 4324 "Agent Setup" /// /// Finds the agent user security ID based on the provided user name. - /// The user name to search for. You can provide a partial or full user name. + /// + /// The user name to search for. You can provide a partial or full user name. /// The security ID of the agent user if found, otherwise a null guid. /// True if an agent with the provided user name is found, false otherwise. procedure FindAgentByUserName(AgentUserName: Text; var AgentUserSecurityId: Guid): Boolean diff --git a/src/Tools/AI Test Toolkit/src/Agent/AgentTaskLog.Table.al b/src/Tools/AI Test Toolkit/src/Agent/AgentTaskLog.Table.al index 2c225a06c2..ee36df594c 100644 --- a/src/Tools/AI Test Toolkit/src/Agent/AgentTaskLog.Table.al +++ b/src/Tools/AI Test Toolkit/src/Agent/AgentTaskLog.Table.al @@ -10,7 +10,7 @@ table 149050 "Agent Task Log" Caption = 'AI Agent Task Log'; DataClassification = SystemMetadata; Extensible = true; - Access = Public; + Access = Internal; ReplicateData = false; InherentEntitlements = RIMDX; InherentPermissions = RIMDX; diff --git a/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al b/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al index 1f4ebf45be..e773df1a6c 100644 --- a/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al +++ b/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al @@ -52,14 +52,7 @@ codeunit 149049 "Agent Test Context Impl." Clear(AgentTaskList); end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"AIT Test Suite Mgt.", OnAfterInsertAITLogEntry, '', false, false)] - local procedure InsertAgentTaskLogs(var AITLogEntry: Record "AIT Log Entry") - begin - LogAgentTasks(AITLogEntry); - end; - - local procedure LogAgentTasks(var AITLogEntry: Record "AIT Log Entry") + procedure LogAgentTasks(var AITLogEntry: Record "AIT Log Entry") var AgentTaskId: BigInteger; begin diff --git a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLine.Table.al b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLine.Table.al index 2fd03c94bd..ee6bef4521 100644 --- a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLine.Table.al +++ b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLine.Table.al @@ -215,6 +215,7 @@ table 149032 "AIT Test Method Line" CalcFormula = sum("AIT Log Entry"."Tokens Consumed" where("Test Suite Code" = field("Test Suite Code"), "Test Method Line No." = field("Line No."), Version = field("Version Filter"), Operation = const('Run Procedure'), "Procedure Name" = filter(<> ''))); } #if not CLEAN26 +#pragma warning disable AS0072 field(121; "Tokens Consumed - Base"; Integer) { ObsoleteState = Pending; @@ -226,6 +227,7 @@ table 149032 "AIT Test Method Line" FieldClass = FlowField; CalcFormula = sum("AIT Log Entry"."Tokens Consumed" where("Test Suite Code" = field("Test Suite Code"), "Test Method Line No." = field("Line No."), Version = field("Base Version Filter"), Operation = const('Run Procedure'), "Procedure Name" = filter(<> ''))); } +#pragma warning restore AS0072 #endif } keys diff --git a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuiteMgt.Codeunit.al b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuiteMgt.Codeunit.al index a40d01d6f1..9c2efd3bb1 100644 --- a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuiteMgt.Codeunit.al +++ b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuiteMgt.Codeunit.al @@ -333,6 +333,7 @@ codeunit 149034 "AIT Test Suite Mgt." TestInput: Record "Test Input"; AITTestRunIteration: Codeunit "AIT Test Run Iteration"; // single instance TestSuiteMgt: Codeunit "Test Suite Mgt."; + AgentTestContextImpl: Codeunit "Agent Test Context Impl."; ModifiedOperation: Text; ModifiedExecutionSuccess: Boolean; ModifiedMessage: Text; @@ -399,7 +400,7 @@ codeunit 149034 "AIT Test Suite Mgt." AITLogEntry."No. of Turns Passed" := AITTestRunIteration.GetNumberOfTurnsPassedForLastTestMethodLine(); AITLogEntry."Test Method Line Accuracy" := AITTestRunIteration.GetAccuracyForLastTestMethodLine(); AITLogEntry.Insert(true); - OnAfterInsertAITLogEntry(AITLogEntry); + AgentTestContextImpl.LogAgentTasks(AITLogEntry); Commit(); AITTestRunIteration.AddToNoOfLogEntriesInserted(); @@ -538,11 +539,6 @@ codeunit 149034 "AIT Test Suite Mgt." DownloadFromStream(ResultsInStream, DownloadResultsLbl, '', 'xlsx', FilenameTxt); end; - [InternalEvent(false, false)] - local procedure OnAfterInsertAITLogEntry(var AITLogEntry: Record "AIT Log Entry") - begin - end; - [EventSubscriber(ObjectType::Table, Database::"AIT Test Suite", OnBeforeDeleteEvent, '', false, false)] local procedure DeleteLinesOnDeleteAITTestSuite(var Rec: Record "AIT Test Suite"; RunTrigger: Boolean) var From a35be3f2b2fd7d921146477de42ba680a5a6152a Mon Sep 17 00:00:00 2001 From: Nikola Kukrika Date: Fri, 27 Feb 2026 12:31:50 +0100 Subject: [PATCH 12/17] Polishing code --- .../src/Agent/AgentTestContextImpl.Codeunit.al | 6 ++---- .../AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al | 6 ------ 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al b/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al index e773df1a6c..e90e4788ad 100644 --- a/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al +++ b/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al @@ -15,10 +15,6 @@ codeunit 149049 "Agent Test Context Impl." InherentEntitlements = X; InherentPermissions = X; - var - GlobalAgentUserSecurityID: Guid; - AgentIsNotActiveErr: Label 'Agent %1 set on suite %2 is not active.', Comment = '%1 = Agent ID, %2 = Suite Code'; - procedure GetAgentRecord(var AgentUserSecurityID: Guid) begin AgentUserSecurityID := GlobalAgentUserSecurityID; @@ -244,4 +240,6 @@ codeunit 149049 "Agent Test Context Impl." var AgentTaskList: List of [BigInteger]; + GlobalAgentUserSecurityID: Guid; + AgentIsNotActiveErr: Label 'Agent %1 set on suite %2 is not active.', Comment = '%1 = Agent ID, %2 = Suite Code'; } \ No newline at end of file diff --git a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al index 10bd7f612f..7c51d4ba8d 100644 --- a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al +++ b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al @@ -36,11 +36,6 @@ page 149031 "AIT Test Suite" field(TestType; Rec."Test Type") { Importance = Additional; - trigger OnValidate() - begin - if Rec."Test Type" <> xRec."Test Type" then - Message(YouNeedToOpenAndCloseThePageMsg); - end; } field(Dataset; Rec."Input Dataset") { @@ -425,7 +420,6 @@ page 149031 "AIT Test Suite" TestRunnerDisplayName: Text; Language: Text; InputDatasetChangedQst: Label 'You have modified the input dataset.\\Do you want to update the lines?'; - YouNeedToOpenAndCloseThePageMsg: Label 'You need to open and close the page for the change to take effect on the UI controls.'; EvaluationSetupTxt: Text; trigger OnOpenPage() From d88045921195b5d05d033cb17d3c37aa180194aa Mon Sep 17 00:00:00 2001 From: Nikola Kukrika Date: Fri, 27 Feb 2026 12:33:17 +0100 Subject: [PATCH 13/17] Polishing code --- .../AI Test Toolkit/src/TestSuite/AITTestMethodLines.Page.al | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLines.Page.al b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLines.Page.al index d0530a2d62..c107aa04f2 100644 --- a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLines.Page.al +++ b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLines.Page.al @@ -84,7 +84,7 @@ page 149034 "AIT Test Method Lines" ToolTip = 'Specifies the number of failed evals for the eval line.'; Style = Unfavorable; - trigger OnAssistEdit() + trigger OnDrillDown() var AITTestSuite: Record "AIT Test Suite"; AITLogEntry: Codeunit "AIT Log Entry"; From acea67869090c614d6a1d77ae15ba7dc6f91620f Mon Sep 17 00:00:00 2001 From: Nikola Kukrika Date: Fri, 27 Feb 2026 12:38:49 +0100 Subject: [PATCH 14/17] Polishing code --- .../src/Agent/AgentLogEntries.PageExt.al | 10 +++++----- .../src/Agent/AgentRunHistory.PageExt.al | 11 ++++++----- .../src/Agent/AgentTestMethodLines.PageExt.al | 12 ++++++------ .../AI Test Toolkit/src/Logs/AITLogEntry.Table.al | 2 +- .../AI Test Toolkit/src/Logs/AITRunHistory.Page.al | 4 ++-- .../AI Test Toolkit/src/Logs/AITRunHistory.Table.al | 4 ++-- .../src/Logs/AITTestMethodLinesCompare.Page.al | 2 +- .../src/Logs/AITTestSuiteCompare.Page.al | 2 +- .../src/TestSuite/AITTestMethodLine.Table.al | 4 ++-- .../src/TestSuite/AITTestSuite.Page.al | 2 +- .../src/TestSuite/AITTestSuite.Table.al | 2 +- 11 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/Tools/AI Test Toolkit/src/Agent/AgentLogEntries.PageExt.al b/src/Tools/AI Test Toolkit/src/Agent/AgentLogEntries.PageExt.al index 83ffb0f25f..fe22dba3c8 100644 --- a/src/Tools/AI Test Toolkit/src/Agent/AgentLogEntries.PageExt.al +++ b/src/Tools/AI Test Toolkit/src/Agent/AgentLogEntries.PageExt.al @@ -36,11 +36,6 @@ pageextension 149030 "Agent Log Entries" extends "AIT Log Entries" } } - var - AgentTestContextImpl: Codeunit "Agent Test Context Impl."; - CopilotCredits: Decimal; - AgentTaskIDs: Text; - trigger OnAfterGetRecord() begin UpdateAgentTaskMetrics(); @@ -51,4 +46,9 @@ pageextension 149030 "Agent Log Entries" extends "AIT Log Entries" CopilotCredits := AgentTestContextImpl.GetCopilotCreditsForLogEntry(Rec."Entry No."); AgentTaskIDs := AgentTestContextImpl.GetAgentTaskIDsForLogEntry(Rec."Entry No."); end; + + var + AgentTestContextImpl: Codeunit "Agent Test Context Impl."; + CopilotCredits: Decimal; + AgentTaskIDs: Text; } diff --git a/src/Tools/AI Test Toolkit/src/Agent/AgentRunHistory.PageExt.al b/src/Tools/AI Test Toolkit/src/Agent/AgentRunHistory.PageExt.al index d115208029..d29f3128b7 100644 --- a/src/Tools/AI Test Toolkit/src/Agent/AgentRunHistory.PageExt.al +++ b/src/Tools/AI Test Toolkit/src/Agent/AgentRunHistory.PageExt.al @@ -65,11 +65,6 @@ pageextension 149032 "Agent Run History" extends "AIT Run History" } } - var - AgentTestContextImpl: Codeunit "Agent Test Context Impl."; - AgentTaskCountByVersion: Integer; - AgentTaskCountByTag: Integer; - trigger OnAfterGetRecord() begin UpdateAgentTaskCounts(); @@ -85,5 +80,11 @@ pageextension 149032 "Agent Run History" extends "AIT Run History" AgentTaskCountByVersion := AgentTestContextImpl.GetAgentTaskCount(Rec."Agent Task IDs"); AgentTaskCountByTag := AgentTestContextImpl.GetAgentTaskCount(Rec."Agent Task IDs - By Tag"); end; + + var + AgentTestContextImpl: Codeunit "Agent Test Context Impl."; + AgentTaskCountByVersion: Integer; + AgentTaskCountByTag: Integer; + } diff --git a/src/Tools/AI Test Toolkit/src/Agent/AgentTestMethodLines.PageExt.al b/src/Tools/AI Test Toolkit/src/Agent/AgentTestMethodLines.PageExt.al index 7f6336d7ed..b7b88c7672 100644 --- a/src/Tools/AI Test Toolkit/src/Agent/AgentTestMethodLines.PageExt.al +++ b/src/Tools/AI Test Toolkit/src/Agent/AgentTestMethodLines.PageExt.al @@ -36,12 +36,6 @@ pageextension 149033 "Agent Test Method Lines" extends "AIT Test Method Lines" } } - var - AgentTestContextImpl: Codeunit "Agent Test Context Impl."; - CopilotCredits: Decimal; - AgentTaskIDs: Text; - AgentTaskCount: Integer; - trigger OnAfterGetRecord() begin UpdateAgentTaskMetrics(); @@ -65,4 +59,10 @@ pageextension 149033 "Agent Test Method Lines" extends "AIT Test Method Lines" AgentTaskIDs := AgentTestContextImpl.GetAgentTaskIDs(Rec."Test Suite Code", VersionFilter, '', Rec."Line No."); AgentTaskCount := AgentTestContextImpl.GetAgentTaskCount(AgentTaskIDs); end; + + var + AgentTestContextImpl: Codeunit "Agent Test Context Impl."; + CopilotCredits: Decimal; + AgentTaskIDs: Text; + AgentTaskCount: Integer; } diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITLogEntry.Table.al b/src/Tools/AI Test Toolkit/src/Logs/AITLogEntry.Table.al index 5aa2599c3a..f240af3508 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITLogEntry.Table.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITLogEntry.Table.al @@ -179,7 +179,7 @@ table 149034 "AIT Log Entry" field(50; "Tokens Consumed"; Integer) { Caption = 'Total Tokens Consumed'; - ToolTip = 'Specifies the aggregated number of tokens consumed by the eval. This is applicable only when using Microsoft AI Module.Tokens consumed by the agent sessions are not included in this number.'; + ToolTip = 'Specifies the aggregated number of tokens consumed by the eval. This is applicable only when using Microsoft AI Module.Tokens consumed by agent sessions are not included in this number.'; } } diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Page.al b/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Page.al index 91b9b1d2a4..6cacb9da91 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Page.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Page.al @@ -137,7 +137,7 @@ page 149032 "AIT Run History" { Visible = ViewBy = ViewBy::Version; Caption = 'Total Tokens Consumed'; - ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module.Tokens consumed by the agent sessions are not included in this number.'; + ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module.Tokens consumed by agent sessions are not included in this number.'; } field("No. of Tests - By Tag"; Rec."No. of Tests Executed - By Tag") { @@ -183,7 +183,7 @@ page 149032 "AIT Run History" { Visible = ViewBy = ViewBy::Tag; Caption = 'Total Tokens Consumed'; - ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module.Tokens consumed by the agent sessions are not included in this number.'; + ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module.Tokens consumed by agent sessions are not included in this number.'; } } } diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Table.al b/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Table.al index 040edccf9b..1b3e71efcc 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Table.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Table.al @@ -67,7 +67,7 @@ table 149036 "AIT Run History" field(13; "Tokens Consumed"; Integer) { Caption = 'Total Tokens Consumed'; - ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module.Tokens consumed by the agent sessions are not included in this number.'; + ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module.Tokens consumed by agent sessions are not included in this number.'; Editable = false; FieldClass = FlowField; CalcFormula = sum("AIT Log Entry"."Tokens Consumed" where("Test Suite Code" = field("Test Suite Code"), Version = field("Version"), "Test Method Line No." = field("Line No. Filter"), Operation = const('Run Procedure'), "Procedure Name" = filter(<> ''))); @@ -108,7 +108,7 @@ table 149036 "AIT Run History" field(23; "Tokens Consumed - By Tag"; Integer) { Caption = 'Total Tokens Consumed'; - ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module.Tokens consumed by the agent sessions are not included in this number.'; + ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module.Tokens consumed by agent sessions are not included in this number.'; Editable = false; FieldClass = FlowField; CalcFormula = sum("AIT Log Entry"."Tokens Consumed" where("Test Suite Code" = field("Test Suite Code"), "Test Method Line No." = field("Line No. Filter"), Tag = field(Tag), Operation = const('Run Procedure'), "Procedure Name" = filter(<> ''))); diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITTestMethodLinesCompare.Page.al b/src/Tools/AI Test Toolkit/src/Logs/AITTestMethodLinesCompare.Page.al index d0f5a91201..3cd5673f7f 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITTestMethodLinesCompare.Page.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITTestMethodLinesCompare.Page.al @@ -81,7 +81,7 @@ page 149035 "AIT Test Method Lines Compare" label(TokensConsumed) { Caption = 'Total Tokens Consumed'; - ToolTip = 'Specifies the aggregated number of tokens consumed by the eval. This is applicable only when using Microsoft AI Module.Tokens consumed by the agent sessions are not included in this number.'; + ToolTip = 'Specifies the aggregated number of tokens consumed by the eval. This is applicable only when using Microsoft AI Module.Tokens consumed by agent sessions are not included in this number.'; } } group("Latest Version") diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITTestSuiteCompare.Page.al b/src/Tools/AI Test Toolkit/src/Logs/AITTestSuiteCompare.Page.al index 724df70203..bf548f15c2 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITTestSuiteCompare.Page.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITTestSuiteCompare.Page.al @@ -82,7 +82,7 @@ page 149036 "AIT Test Suite Compare" label(TokensConsumed) { Caption = 'Total Tokens Consumed'; - ToolTip = 'Specifies the aggregated number of tokens consumed by the eval. This is applicable only when using Microsoft AI Module.Tokens consumed by the agent sessions are not included in this number.'; + ToolTip = 'Specifies the aggregated number of tokens consumed by the eval. This is applicable only when using Microsoft AI Module.Tokens consumed by agent sessions are not included in this number.'; } } group("Latest Version") diff --git a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLine.Table.al b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLine.Table.al index ee6bef4521..26e4e844b9 100644 --- a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLine.Table.al +++ b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLine.Table.al @@ -209,7 +209,7 @@ table 149032 "AIT Test Method Line" field(120; "Tokens Consumed"; Integer) { Caption = 'Total Tokens Consumed'; - ToolTip = 'Specifies the number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module.Tokens consumed by the agent sessions are not included in this number.'; + ToolTip = 'Specifies the number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module.Tokens consumed by agent sessions are not included in this number.'; Editable = false; FieldClass = FlowField; CalcFormula = sum("AIT Log Entry"."Tokens Consumed" where("Test Suite Code" = field("Test Suite Code"), "Test Method Line No." = field("Line No."), Version = field("Version Filter"), Operation = const('Run Procedure'), "Procedure Name" = filter(<> ''))); @@ -222,7 +222,7 @@ table 149032 "AIT Test Method Line" ObsoleteReason = 'This field is deprecated as it is not used in any page or calculation. It will be removed in future versions.'; ObsoleteTag = '26.0'; Caption = 'Tokens Consumed - Base'; - ToolTip = 'Specifies the number of tokens consumed by the eval in the base version. This is applicable only when using Microsoft AI Module.Tokens consumed by the agent sessions are not included in this number.'; + ToolTip = 'Specifies the number of tokens consumed by the eval in the base version. This is applicable only when using Microsoft AI Module.Tokens consumed by agent sessions are not included in this number.'; Editable = false; FieldClass = FlowField; CalcFormula = sum("AIT Log Entry"."Tokens Consumed" where("Test Suite Code" = field("Test Suite Code"), "Test Method Line No." = field("Line No."), Version = field("Base Version Filter"), Operation = const('Run Procedure'), "Procedure Name" = filter(<> ''))); diff --git a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al index 7c51d4ba8d..5a56796922 100644 --- a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al +++ b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al @@ -223,7 +223,7 @@ page 149031 "AIT Test Suite" { Editable = false; Caption = 'Average Tokens Consumed'; - ToolTip = 'Specifies the average number of tokens consumed by the evals in the last run.Tokens consumed by the agent sessions are not included in this number.'; + ToolTip = 'Specifies the average number of tokens consumed by the evals in the last run.Tokens consumed by agent sessions are not included in this number.'; } } diff --git a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Table.al b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Table.al index a0841a66a7..94da6d329e 100644 --- a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Table.al +++ b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Table.al @@ -167,7 +167,7 @@ table 149030 "AIT Test Suite" field(24; "Tokens Consumed"; Integer) { Caption = 'Total Tokens Consumed'; - ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module.Tokens consumed by the agent sessions are not included in this number.'; + ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module.Tokens consumed by agent sessions are not included in this number.'; Editable = false; FieldClass = FlowField; CalcFormula = sum("AIT Log Entry"."Tokens Consumed" where("Test Suite Code" = field("Code"), Version = field("Version"), Operation = const('Run Procedure'), "Procedure Name" = filter(<> ''))); From 69250bf02f0f0cf9384b719c1a8ac2e5d4faeb80 Mon Sep 17 00:00:00 2001 From: Nikola Kukrika Date: Fri, 27 Feb 2026 13:37:50 +0100 Subject: [PATCH 15/17] Code review feedback --- .../Agent/AgentTestContextImpl.Codeunit.al | 44 +++++++++---------- .../src/Agent/AgentTestSuite.PageExt.al | 2 +- .../src/Logs/AITLogEntry.Table.al | 2 +- .../src/Logs/AITRunHistory.Page.al | 4 +- .../src/Logs/AITRunHistory.Table.al | 4 +- .../Logs/AITTestMethodLinesCompare.Page.al | 2 +- .../src/Logs/AITTestSuiteCompare.Page.al | 2 +- .../src/TestSuite/AITTestMethodLine.Table.al | 4 +- .../src/TestSuite/AITTestSuite.Page.al | 2 +- .../src/TestSuite/AITTestSuite.Table.al | 2 +- 10 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al b/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al index e90e4788ad..7cead5e220 100644 --- a/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al +++ b/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al @@ -20,23 +20,6 @@ codeunit 149049 "Agent Test Context Impl." AgentUserSecurityID := GlobalAgentUserSecurityID; end; - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Test Runner - Mgt", OnRunTestSuite, '', false, false)] - local procedure OnRunTestSuite(var TestMethodLine: Record "Test Method Line") - var - AITTestSuite: Record "AIT Test Suite"; - Agent: Codeunit Agent; - AITTestContext: Codeunit "AIT Test Context"; - begin - AITTestContext.GetAITTestSuite(AITTestSuite); - - if IsNullGuid(AITTestSuite."Agent User Security ID") then - exit; - - GlobalAgentUserSecurityID := AITTestSuite."Agent User Security ID"; - if not Agent.IsActive(GlobalAgentUserSecurityID) then - Error(AgentIsNotActiveErr, AITTestSuite.Code, AITTestSuite."Agent User Security ID"); - end; - procedure AddTaskToLog(AgentTaskId: BigInteger) begin if not AgentTaskList.Contains(AgentTaskId) then @@ -97,7 +80,7 @@ codeunit 149049 "Agent Test Context Impl." AgentTaskLog.SetRange(Tag, Tag); if VersionFilter <> '' then AgentTaskLog.SetFilter(Version, VersionFilter); - if TestMethodLineNo <> 0 then + if TestMethodLineNo > 0 then AgentTaskLog.SetRange("Test Method Line No.", TestMethodLineNo); exit(GetAgentTaskIDs(AgentTaskLog)); @@ -199,9 +182,9 @@ codeunit 149049 "Agent Test Context Impl." local procedure ConvertCommaSeparatedToFilter(CommaSeparatedValues: Text): Text var + FilterTextBuilder: TextBuilder; Values: List of [Text]; CurrentValue: Text; - FilterText: Text; IsFirst: Boolean; begin if CommaSeparatedValues = '' then @@ -213,12 +196,12 @@ codeunit 149049 "Agent Test Context Impl." CurrentValue := CurrentValue.Trim(); if CurrentValue <> '' then if IsFirst then begin - FilterText := CurrentValue; + FilterTextBuilder.Append(CurrentValue); IsFirst := false; end else - FilterText += '|' + CurrentValue; + FilterTextBuilder.Append('|' + CurrentValue); end; - exit(FilterText); + exit(FilterTextBuilder.ToText()); end; local procedure ConcatenateList(TextList: List of [Text]; Separator: Text): Text @@ -238,6 +221,23 @@ codeunit 149049 "Agent Test Context Impl." exit(Result); end; + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Test Runner - Mgt", OnRunTestSuite, '', false, false)] + local procedure OnRunTestSuite(var TestMethodLine: Record "Test Method Line") + var + AITTestSuite: Record "AIT Test Suite"; + Agent: Codeunit Agent; + AITTestContext: Codeunit "AIT Test Context"; + begin + AITTestContext.GetAITTestSuite(AITTestSuite); + + if IsNullGuid(AITTestSuite."Agent User Security ID") then + exit; + + GlobalAgentUserSecurityID := AITTestSuite."Agent User Security ID"; + if not Agent.IsActive(GlobalAgentUserSecurityID) then + Error(AgentIsNotActiveErr, AITTestSuite.Code, AITTestSuite."Agent User Security ID"); + end; + var AgentTaskList: List of [BigInteger]; GlobalAgentUserSecurityID: Guid; diff --git a/src/Tools/AI Test Toolkit/src/Agent/AgentTestSuite.PageExt.al b/src/Tools/AI Test Toolkit/src/Agent/AgentTestSuite.PageExt.al index a610e711fc..db589ca600 100644 --- a/src/Tools/AI Test Toolkit/src/Agent/AgentTestSuite.PageExt.al +++ b/src/Tools/AI Test Toolkit/src/Agent/AgentTestSuite.PageExt.al @@ -18,7 +18,7 @@ pageextension 149034 "Agent Test Suite" extends "AIT Test Suite" { ApplicationArea = All; Caption = 'Agent'; - ToolTip = 'Specifies the agent to be used by the tests.'; + ToolTip = 'Specifies the agent to be used by the tests. You can use this field to test different configurations without changing the code. If you manually configure the agent and set it on the suite, this instance will be used in the eval runs. If you leave it blank, the system will automatically create an agent for each run.'; trigger OnValidate() begin diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITLogEntry.Table.al b/src/Tools/AI Test Toolkit/src/Logs/AITLogEntry.Table.al index f240af3508..487ba8ec3e 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITLogEntry.Table.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITLogEntry.Table.al @@ -179,7 +179,7 @@ table 149034 "AIT Log Entry" field(50; "Tokens Consumed"; Integer) { Caption = 'Total Tokens Consumed'; - ToolTip = 'Specifies the aggregated number of tokens consumed by the eval. This is applicable only when using Microsoft AI Module.Tokens consumed by agent sessions are not included in this number.'; + ToolTip = 'Specifies the aggregated number of tokens consumed by the eval. This is applicable only when using Microsoft AI Module. Tokans consumed by agent sessions are not included in this number.'; } } diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Page.al b/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Page.al index 6cacb9da91..32ae9d9261 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Page.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Page.al @@ -137,7 +137,7 @@ page 149032 "AIT Run History" { Visible = ViewBy = ViewBy::Version; Caption = 'Total Tokens Consumed'; - ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module.Tokens consumed by agent sessions are not included in this number.'; + ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module. Tokans consumed by agent sessions are not included in this number.'; } field("No. of Tests - By Tag"; Rec."No. of Tests Executed - By Tag") { @@ -183,7 +183,7 @@ page 149032 "AIT Run History" { Visible = ViewBy = ViewBy::Tag; Caption = 'Total Tokens Consumed'; - ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module.Tokens consumed by agent sessions are not included in this number.'; + ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module. Tokans consumed by agent sessions are not included in this number.'; } } } diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Table.al b/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Table.al index 1b3e71efcc..ed9bdbc4f2 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Table.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Table.al @@ -67,7 +67,7 @@ table 149036 "AIT Run History" field(13; "Tokens Consumed"; Integer) { Caption = 'Total Tokens Consumed'; - ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module.Tokens consumed by agent sessions are not included in this number.'; + ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module. Tokans consumed by agent sessions are not included in this number.'; Editable = false; FieldClass = FlowField; CalcFormula = sum("AIT Log Entry"."Tokens Consumed" where("Test Suite Code" = field("Test Suite Code"), Version = field("Version"), "Test Method Line No." = field("Line No. Filter"), Operation = const('Run Procedure'), "Procedure Name" = filter(<> ''))); @@ -108,7 +108,7 @@ table 149036 "AIT Run History" field(23; "Tokens Consumed - By Tag"; Integer) { Caption = 'Total Tokens Consumed'; - ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module.Tokens consumed by agent sessions are not included in this number.'; + ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module. Tokans consumed by agent sessions are not included in this number.'; Editable = false; FieldClass = FlowField; CalcFormula = sum("AIT Log Entry"."Tokens Consumed" where("Test Suite Code" = field("Test Suite Code"), "Test Method Line No." = field("Line No. Filter"), Tag = field(Tag), Operation = const('Run Procedure'), "Procedure Name" = filter(<> ''))); diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITTestMethodLinesCompare.Page.al b/src/Tools/AI Test Toolkit/src/Logs/AITTestMethodLinesCompare.Page.al index 3cd5673f7f..8b43e67ef0 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITTestMethodLinesCompare.Page.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITTestMethodLinesCompare.Page.al @@ -81,7 +81,7 @@ page 149035 "AIT Test Method Lines Compare" label(TokensConsumed) { Caption = 'Total Tokens Consumed'; - ToolTip = 'Specifies the aggregated number of tokens consumed by the eval. This is applicable only when using Microsoft AI Module.Tokens consumed by agent sessions are not included in this number.'; + ToolTip = 'Specifies the aggregated number of tokens consumed by the eval. This is applicable only when using Microsoft AI Module. Tokans consumed by agent sessions are not included in this number.'; } } group("Latest Version") diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITTestSuiteCompare.Page.al b/src/Tools/AI Test Toolkit/src/Logs/AITTestSuiteCompare.Page.al index bf548f15c2..bd585d7aa9 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITTestSuiteCompare.Page.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITTestSuiteCompare.Page.al @@ -82,7 +82,7 @@ page 149036 "AIT Test Suite Compare" label(TokensConsumed) { Caption = 'Total Tokens Consumed'; - ToolTip = 'Specifies the aggregated number of tokens consumed by the eval. This is applicable only when using Microsoft AI Module.Tokens consumed by agent sessions are not included in this number.'; + ToolTip = 'Specifies the aggregated number of tokens consumed by the eval. This is applicable only when using Microsoft AI Module. Tokans consumed by agent sessions are not included in this number.'; } } group("Latest Version") diff --git a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLine.Table.al b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLine.Table.al index 26e4e844b9..8d18a91fe7 100644 --- a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLine.Table.al +++ b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLine.Table.al @@ -209,7 +209,7 @@ table 149032 "AIT Test Method Line" field(120; "Tokens Consumed"; Integer) { Caption = 'Total Tokens Consumed'; - ToolTip = 'Specifies the number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module.Tokens consumed by agent sessions are not included in this number.'; + ToolTip = 'Specifies the number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module. Tokans consumed by agent sessions are not included in this number.'; Editable = false; FieldClass = FlowField; CalcFormula = sum("AIT Log Entry"."Tokens Consumed" where("Test Suite Code" = field("Test Suite Code"), "Test Method Line No." = field("Line No."), Version = field("Version Filter"), Operation = const('Run Procedure'), "Procedure Name" = filter(<> ''))); @@ -222,7 +222,7 @@ table 149032 "AIT Test Method Line" ObsoleteReason = 'This field is deprecated as it is not used in any page or calculation. It will be removed in future versions.'; ObsoleteTag = '26.0'; Caption = 'Tokens Consumed - Base'; - ToolTip = 'Specifies the number of tokens consumed by the eval in the base version. This is applicable only when using Microsoft AI Module.Tokens consumed by agent sessions are not included in this number.'; + ToolTip = 'Specifies the number of tokens consumed by the eval in the base version. This is applicable only when using Microsoft AI Module. Tokans consumed by agent sessions are not included in this number.'; Editable = false; FieldClass = FlowField; CalcFormula = sum("AIT Log Entry"."Tokens Consumed" where("Test Suite Code" = field("Test Suite Code"), "Test Method Line No." = field("Line No."), Version = field("Base Version Filter"), Operation = const('Run Procedure'), "Procedure Name" = filter(<> ''))); diff --git a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al index 5a56796922..e9dc7d4dcf 100644 --- a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al +++ b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al @@ -223,7 +223,7 @@ page 149031 "AIT Test Suite" { Editable = false; Caption = 'Average Tokens Consumed'; - ToolTip = 'Specifies the average number of tokens consumed by the evals in the last run.Tokens consumed by agent sessions are not included in this number.'; + ToolTip = 'Specifies the average number of tokens consumed by the evals in the last run. Tokans consumed by agent sessions are not included in this number.'; } } diff --git a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Table.al b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Table.al index 94da6d329e..f36bb05579 100644 --- a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Table.al +++ b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Table.al @@ -167,7 +167,7 @@ table 149030 "AIT Test Suite" field(24; "Tokens Consumed"; Integer) { Caption = 'Total Tokens Consumed'; - ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module.Tokens consumed by agent sessions are not included in this number.'; + ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module. Tokans consumed by agent sessions are not included in this number.'; Editable = false; FieldClass = FlowField; CalcFormula = sum("AIT Log Entry"."Tokens Consumed" where("Test Suite Code" = field("Code"), Version = field("Version"), Operation = const('Run Procedure'), "Procedure Name" = filter(<> ''))); From dc2f4a0bc12a4a1c98d67c204d0219e988a23226 Mon Sep 17 00:00:00 2001 From: Nikola Kukrika Date: Fri, 27 Feb 2026 13:39:11 +0100 Subject: [PATCH 16/17] Fixing typo --- src/Tools/AI Test Toolkit/src/Logs/AITLogEntry.Table.al | 2 +- src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Page.al | 4 ++-- src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Table.al | 4 ++-- .../src/Logs/AITTestMethodLinesCompare.Page.al | 2 +- .../AI Test Toolkit/src/Logs/AITTestSuiteCompare.Page.al | 2 +- .../AI Test Toolkit/src/TestSuite/AITTestMethodLine.Table.al | 4 ++-- src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al | 2 +- src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Table.al | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITLogEntry.Table.al b/src/Tools/AI Test Toolkit/src/Logs/AITLogEntry.Table.al index 487ba8ec3e..162944de18 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITLogEntry.Table.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITLogEntry.Table.al @@ -179,7 +179,7 @@ table 149034 "AIT Log Entry" field(50; "Tokens Consumed"; Integer) { Caption = 'Total Tokens Consumed'; - ToolTip = 'Specifies the aggregated number of tokens consumed by the eval. This is applicable only when using Microsoft AI Module. Tokans consumed by agent sessions are not included in this number.'; + ToolTip = 'Specifies the aggregated number of tokens consumed by the eval. This is applicable only when using Microsoft AI Module. Tokens consumed by agent sessions are not included in this number.'; } } diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Page.al b/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Page.al index 32ae9d9261..1cc83a4de3 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Page.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Page.al @@ -137,7 +137,7 @@ page 149032 "AIT Run History" { Visible = ViewBy = ViewBy::Version; Caption = 'Total Tokens Consumed'; - ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module. Tokans consumed by agent sessions are not included in this number.'; + ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module. Tokens consumed by agent sessions are not included in this number.'; } field("No. of Tests - By Tag"; Rec."No. of Tests Executed - By Tag") { @@ -183,7 +183,7 @@ page 149032 "AIT Run History" { Visible = ViewBy = ViewBy::Tag; Caption = 'Total Tokens Consumed'; - ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module. Tokans consumed by agent sessions are not included in this number.'; + ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module. Tokens consumed by agent sessions are not included in this number.'; } } } diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Table.al b/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Table.al index ed9bdbc4f2..828bf92d63 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Table.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITRunHistory.Table.al @@ -67,7 +67,7 @@ table 149036 "AIT Run History" field(13; "Tokens Consumed"; Integer) { Caption = 'Total Tokens Consumed'; - ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module. Tokans consumed by agent sessions are not included in this number.'; + ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module. Tokens consumed by agent sessions are not included in this number.'; Editable = false; FieldClass = FlowField; CalcFormula = sum("AIT Log Entry"."Tokens Consumed" where("Test Suite Code" = field("Test Suite Code"), Version = field("Version"), "Test Method Line No." = field("Line No. Filter"), Operation = const('Run Procedure'), "Procedure Name" = filter(<> ''))); @@ -108,7 +108,7 @@ table 149036 "AIT Run History" field(23; "Tokens Consumed - By Tag"; Integer) { Caption = 'Total Tokens Consumed'; - ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module. Tokans consumed by agent sessions are not included in this number.'; + ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module. Tokens consumed by agent sessions are not included in this number.'; Editable = false; FieldClass = FlowField; CalcFormula = sum("AIT Log Entry"."Tokens Consumed" where("Test Suite Code" = field("Test Suite Code"), "Test Method Line No." = field("Line No. Filter"), Tag = field(Tag), Operation = const('Run Procedure'), "Procedure Name" = filter(<> ''))); diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITTestMethodLinesCompare.Page.al b/src/Tools/AI Test Toolkit/src/Logs/AITTestMethodLinesCompare.Page.al index 8b43e67ef0..76220b95d3 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITTestMethodLinesCompare.Page.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITTestMethodLinesCompare.Page.al @@ -81,7 +81,7 @@ page 149035 "AIT Test Method Lines Compare" label(TokensConsumed) { Caption = 'Total Tokens Consumed'; - ToolTip = 'Specifies the aggregated number of tokens consumed by the eval. This is applicable only when using Microsoft AI Module. Tokans consumed by agent sessions are not included in this number.'; + ToolTip = 'Specifies the aggregated number of tokens consumed by the eval. This is applicable only when using Microsoft AI Module. Tokens consumed by agent sessions are not included in this number.'; } } group("Latest Version") diff --git a/src/Tools/AI Test Toolkit/src/Logs/AITTestSuiteCompare.Page.al b/src/Tools/AI Test Toolkit/src/Logs/AITTestSuiteCompare.Page.al index bd585d7aa9..effa4c7a8c 100644 --- a/src/Tools/AI Test Toolkit/src/Logs/AITTestSuiteCompare.Page.al +++ b/src/Tools/AI Test Toolkit/src/Logs/AITTestSuiteCompare.Page.al @@ -82,7 +82,7 @@ page 149036 "AIT Test Suite Compare" label(TokensConsumed) { Caption = 'Total Tokens Consumed'; - ToolTip = 'Specifies the aggregated number of tokens consumed by the eval. This is applicable only when using Microsoft AI Module. Tokans consumed by agent sessions are not included in this number.'; + ToolTip = 'Specifies the aggregated number of tokens consumed by the eval. This is applicable only when using Microsoft AI Module. Tokens consumed by agent sessions are not included in this number.'; } } group("Latest Version") diff --git a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLine.Table.al b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLine.Table.al index 8d18a91fe7..aa1e158f09 100644 --- a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLine.Table.al +++ b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestMethodLine.Table.al @@ -209,7 +209,7 @@ table 149032 "AIT Test Method Line" field(120; "Tokens Consumed"; Integer) { Caption = 'Total Tokens Consumed'; - ToolTip = 'Specifies the number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module. Tokans consumed by agent sessions are not included in this number.'; + ToolTip = 'Specifies the number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module. Tokens consumed by agent sessions are not included in this number.'; Editable = false; FieldClass = FlowField; CalcFormula = sum("AIT Log Entry"."Tokens Consumed" where("Test Suite Code" = field("Test Suite Code"), "Test Method Line No." = field("Line No."), Version = field("Version Filter"), Operation = const('Run Procedure'), "Procedure Name" = filter(<> ''))); @@ -222,7 +222,7 @@ table 149032 "AIT Test Method Line" ObsoleteReason = 'This field is deprecated as it is not used in any page or calculation. It will be removed in future versions.'; ObsoleteTag = '26.0'; Caption = 'Tokens Consumed - Base'; - ToolTip = 'Specifies the number of tokens consumed by the eval in the base version. This is applicable only when using Microsoft AI Module. Tokans consumed by agent sessions are not included in this number.'; + ToolTip = 'Specifies the number of tokens consumed by the eval in the base version. This is applicable only when using Microsoft AI Module. Tokens consumed by agent sessions are not included in this number.'; Editable = false; FieldClass = FlowField; CalcFormula = sum("AIT Log Entry"."Tokens Consumed" where("Test Suite Code" = field("Test Suite Code"), "Test Method Line No." = field("Line No."), Version = field("Base Version Filter"), Operation = const('Run Procedure'), "Procedure Name" = filter(<> ''))); diff --git a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al index e9dc7d4dcf..600b7d37df 100644 --- a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al +++ b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al @@ -223,7 +223,7 @@ page 149031 "AIT Test Suite" { Editable = false; Caption = 'Average Tokens Consumed'; - ToolTip = 'Specifies the average number of tokens consumed by the evals in the last run. Tokans consumed by agent sessions are not included in this number.'; + ToolTip = 'Specifies the average number of tokens consumed by the evals in the last run. Tokens consumed by agent sessions are not included in this number.'; } } diff --git a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Table.al b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Table.al index f36bb05579..a358a1079b 100644 --- a/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Table.al +++ b/src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Table.al @@ -167,7 +167,7 @@ table 149030 "AIT Test Suite" field(24; "Tokens Consumed"; Integer) { Caption = 'Total Tokens Consumed'; - ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module. Tokans consumed by agent sessions are not included in this number.'; + ToolTip = 'Specifies the aggregated number of tokens consumed by the eval in the current version. This is applicable only when using Microsoft AI Module. Tokens consumed by agent sessions are not included in this number.'; Editable = false; FieldClass = FlowField; CalcFormula = sum("AIT Log Entry"."Tokens Consumed" where("Test Suite Code" = field("Code"), Version = field("Version"), Operation = const('Run Procedure'), "Procedure Name" = filter(<> ''))); From 05da8d3756975b4347b3f09e9707ede2803a55db Mon Sep 17 00:00:00 2001 From: Nikola Kukrika Date: Fri, 27 Feb 2026 13:50:12 +0100 Subject: [PATCH 17/17] Fixing feedback --- .../AI Test Toolkit/src/Agent/AgentTestContext.Codeunit.al | 6 +++--- .../src/Agent/AgentTestContextImpl.Codeunit.al | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Tools/AI Test Toolkit/src/Agent/AgentTestContext.Codeunit.al b/src/Tools/AI Test Toolkit/src/Agent/AgentTestContext.Codeunit.al index 335815cce4..9aed28fc36 100644 --- a/src/Tools/AI Test Toolkit/src/Agent/AgentTestContext.Codeunit.al +++ b/src/Tools/AI Test Toolkit/src/Agent/AgentTestContext.Codeunit.al @@ -15,12 +15,12 @@ codeunit 149048 "Agent Test Context" InherentPermissions = X; /// - /// Gets the agent that is used by the test suite. + /// Gets the user security ID of the agent that is used by the test suite. /// /// The user security ID of the agent used by the test suite. If no agent is set, a null GUID is returned. - procedure GetAgentRecord(var AgentUserSecurityID: Guid) + procedure GetAgentUserSecurityID(var AgentUserSecurityID: Guid) begin - AgentTestContextImpl.GetAgentRecord(AgentUserSecurityID); + AgentTestContextImpl.GetAgentUserSecurityID(AgentUserSecurityID); end; /// diff --git a/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al b/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al index 7cead5e220..0b130f819b 100644 --- a/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al +++ b/src/Tools/AI Test Toolkit/src/Agent/AgentTestContextImpl.Codeunit.al @@ -15,7 +15,7 @@ codeunit 149049 "Agent Test Context Impl." InherentEntitlements = X; InherentPermissions = X; - procedure GetAgentRecord(var AgentUserSecurityID: Guid) + procedure GetAgentUserSecurityID(var AgentUserSecurityID: Guid) begin AgentUserSecurityID := GlobalAgentUserSecurityID; end;