Skip to content

[Agent Archiving] Payables and Expense agent implementation for IAgentArchiving - #10460

Open
krupybalu wants to merge 6 commits into
mainfrom
private/bkrupinszki/agent-archiving-opt-out
Open

[Agent Archiving] Payables and Expense agent implementation for IAgentArchiving#10460
krupybalu wants to merge 6 commits into
mainfrom
private/bkrupinszki/agent-archiving-opt-out

Conversation

@krupybalu

@krupybalu krupybalu commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

What & why

Honours the new IAgentArchiving interface, 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.Archive blocks 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 Archiving codeunits, mirroring how each app already registers IAgentTaskExecution, 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:

  1. BC-Platform - the interface: https://microsoft.ghe.com/bic/BC-Platform/pull/46005
  2. BCApps - System App honours it, Payables and Expense opt out (this PR): [Agent Archiving] Payables and Expense agent implementation for IAgentArchiving #10460

Note: this PR will not build until 1 is merged and a platform version carrying IAgentArchiving flows through.

@krupybalu
krupybalu requested review from a team August 20, 2026 14:51
@krupybalu
krupybalu requested a review from a team as a code owner August 20, 2026 14:51
@github-actions github-actions Bot added AL: System Application AL: Apps (W1) Add-on apps for W1 Team: Other GitHub request for other area than SCM, Finance or Integration Ownership: Needs Review Ownership is Other, low confidence, or needs manual correction labels Aug 20, 2026
@github-actions github-actions Bot added this to the Version 29.0 milestone Aug 20, 2026
@krupybalu krupybalu changed the title [Agent Archiving] Honour IAgentArchiving and opt Payables Agent out [Agent Archiving] Payables Agent opt-out Aug 20, 2026
Comment thread src/System Application/App/Agent/Setup/AgentImpl.Codeunit.al
@krupybalu krupybalu changed the title [Agent Archiving] Payables Agent opt-out [Agent Archiving] Honour IAgentArchiving and opt Payables and Expense Agent out Aug 20, 2026
@krupybalu krupybalu changed the title [Agent Archiving] Honour IAgentArchiving and opt Payables and Expense Agent out [Agent Archiving] Payables and Expense agent implementation for IAgentArchiving Aug 20, 2026
Comment thread src/System Application/App/Agent/Setup/AgentImpl.Codeunit.al
Comment thread src/System Application/App/Agent/Setup/AgentImpl.Codeunit.al Outdated
Comment thread src/System Application/App/Agent/Setup/AgentImpl.Codeunit.al Outdated
Comment thread src/System Application/App/Agent/Setup/AgentCard.Page.al Outdated
Comment thread src/Apps/W1/PayablesAgent/app/Integration/PAAgentArchiving.Codeunit.al Outdated
Comment thread src/System Application/App/Agent/Setup/AgentImpl.Codeunit.al
Comment thread src/System Application/App/Agent/Setup/AgentCard.Page.al
Comment thread src/System Application/App/Agent/Setup/AgentList.Page.al
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";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Error\ Handling}$

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

@github-actions

Copy link
Copy Markdown
Contributor

$\textbf{🟡\ Medium\ Severity\ —\ Style}$

The changed file src/System Application/Test/Agent/src/Setup/LibraryMockAgent.codeunit.al does not follow the <ObjectName>.<ObjectType>.al convention from the style guidance: the type segment is written as codeunit instead of Codeunit. Rename it to LibraryMockAgent.Codeunit.al so file listings and tooling can map the object name and type reliably.

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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Testing}$

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AL: Apps (W1) Add-on apps for W1 AL: System Application Ownership: Needs Review Ownership is Other, low confidence, or needs manual correction Team: Other GitHub request for other area than SCM, Finance or Integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants