Address agent review feedback

This commit is contained in:
Stefano Demiliani 2026-08-27 16:33:40 +02:00
parent 38d341eabb
commit e98fb8ec38
11 changed files with 63 additions and 20 deletions

View file

@ -3,14 +3,29 @@ codeunit 50100 "Sales Review Agent Task"
procedure AnalyzeAgentTaskMessage(AgentTaskMessage: Record "Agent Task Message"; var Annotations: Record "Agent Annotation")
var
AgentMessage: Codeunit "Agent Message";
EmptyMessageMsg: Label 'Message is empty.';
EmptyMessageDetailsTxt: Label 'Provide a sales order task before running the agent.';
NotRelevantMsg: Label 'Message is not a sales order task.';
NotRelevantDetailsTxt: Label 'Provide a message related to sales order review.';
MessageText: Text;
begin
if AgentTaskMessage.Type = AgentTaskMessage.Type::Output then begin
AgentMessage.UpdateText(AgentTaskMessage, AgentMessage.GetText(AgentTaskMessage) + '\n\nWritten with the help of AI');
AgentMessage.UpdateText(AgentTaskMessage, AgentMessage.GetText(AgentTaskMessage) + #13#10 + #13#10 + 'Written with the help of AI');
exit;
end;
if not IsRelevant(AgentMessage.GetText(AgentTaskMessage)) then begin
MessageText := AgentMessage.GetText(AgentTaskMessage);
if MessageText = '' then begin
Clear(Annotations);
Annotations.Code := 'MESSAGE001';
Annotations.Severity := Annotations.Severity::Error;
Annotations.Message := EmptyMessageMsg;
Annotations.Details := EmptyMessageDetailsTxt;
Annotations.Insert();
exit;
end;
if not IsRelevant(MessageText) then begin
Clear(Annotations);
Annotations.Code := 'RELEVANCE001';
Annotations.Severity := Annotations.Severity::Warning;
Annotations.Message := NotRelevantMsg;
@ -21,6 +36,6 @@ codeunit 50100 "Sales Review Agent Task"
local procedure IsRelevant(MessageText: Text): Boolean
begin
exit(MessageText <> '');
exit(StrPos(LowerCase(MessageText), 'sales order') > 0);
end;
}