[Agent Archiving] Payables and Expense agent implementation for IAgentArchiving - #10460
[Agent Archiving] Payables and Expense agent implementation for IAgentArchiving#10460krupybalu wants to merge 6 commits into
Conversation
…gent-archiving-opt-out
83116b9
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9724257d-43d1-468b-9f97-1fb863d2fdd1
| if IsNullGuid(Agent."User Security ID") then | ||
| exit(false); | ||
|
|
||
| AgentArchiving := Agent."Agent Metadata Provider"; |
There was a problem hiding this comment.
AgentImpl.IsArchivingSupported(Agent) (local overload) does AgentArchiving := Agent."Agent Metadata Provider"; exit(AgentArchiving.IsArchivingSupported());, which requires every enum value of "Agent Metadata Provider" to implement IAgentArchiving. Confirmed by inspecting the current enum extensions: the default "SDK Mock Agent" value (MockAgentMetaProv.EnumExt.al), "SO Agent" (SOAMetadataProvider.EnumExt.al) and "Custom Agent" (CustomAgentMetadataProvider.EnumExt.al) do NOT declare an IAgentArchiving implementation. Casting such a value to the IAgentArchiving interface variable raises an unhandled AL runtime error ("enum value does not implement interface") instead of returning a Boolean. This directly contradicts the new test assertion added in the same PR, Assert.IsTrue(Agent.IsArchivingSupported(AgentId), 'Archiving should be supported for a type that does not opt out') in AgentTest.Codeunit.al (ArchiveDisabledAgentSetsArchived, ~line 997), which calls IsArchivingSupported on an agent created via GetOrCreateDefaultAgent — i.e. an "SDK Mock Agent" — and expects true, but the call will error instead. The same crash risk applies in production to the AgentCard/AgentList archive actions for SO Agent and Custom Agent users. Add an explicit guard (e.g. check whether the interface is implemented, or default to a Boolean via a safe pattern) so agent types that have not opted into IAgentArchiving return a sane default instead of throwing.
Agent judgement — not directly backed by a BCQuality knowledge article.
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4
|
The changed file Knowledge: Line mapping was unavailable, so this was posted as an issue comment. 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4 |
| // [WHEN] Archiving the agent | ||
| // [THEN] An error is raised and the agent is not archived | ||
| asserterror Agent.Archive(AgentId); | ||
| Assert.ExpectedError(ArchivingNotSupportedErr); |
There was a problem hiding this comment.
This negative test follows asserterror with Assert.ExpectedError, but it only matches the generic substring is not supported. That is broad enough that an unrelated failure with the same wording could still make the test pass without proving the unsupported-archiving guard fired. Assert a more specific invariant fragment of the message (and the error code if known).
Knowledge:
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4
What & why
Honours the new
IAgentArchivinginterface, and opts Payables Agent and Expense Agent out of archiving.The Archive action is disabled on the Agent List and Agent Card for agent types that do not support archiving, and
Agent.Archiveblocks it programmatically so the guard cannot be bypassed. The check runs off the record the pages already hold, so it costs no extra read and cannot fail on an unsaved record.Payables and Expense opt out via their own
PA Agent Archiving/EA Agent Archivingcodeunits, mirroring how each app already registersIAgentTaskExecution, so they can be removed cleanly once each agent supports archiving. Both are single-instance: the setup record enforcing that is left behind by archiving, which would block creating a replacement.Behaviour is unchanged for every agent type that does not opt out.
Linked work
AB#647379
Related PRs
Cross-repo change - merge in this order: