community postCopilot & Agentscommunity - not Microsoftreviewed - checked by Opus

Step-by-Step Guide: Create Agents in AL Code

Building agents in Business Central AL involves creating setup tables, pages, codeunits, and enums to enable autonomous multi-step operations. The guide walks through creating a Cash Flow Review Agent that can accept tasks, interact with the user during execution, and display KPI results.

Humanoid robot in a suit reviewing a folder labeled CONFIDENTIAL in an office.

post Aardvark Labs

Marcel Chabot · 2026-04-03 · 2,696 words · about 12 min

"An agent operates slightly differently; an Agent strings several tasks together to complete a more complex overreaching operation."

Key points

  • Agents chain multiple tasks together for complex operations, unlike single-task copilots that require review and acceptance
  • Required components include setup tables with User Security ID, metadata codeunits implementing IAgentFactory and IAgentMetadata interfaces, and KPI tracking tables
  • Custom Agent capability must be enabled in Business Central with appropriate permissions (Agent Admin and Agent Diagnostics) configured in a sandbox environment
  • Agent instructions are embedded as resources and delivered via the Agent.SetInstructions method using user security identifiers
  • Tasks are created using AgentTaskBuilder to initialize agents with titles and messages, triggering autonomous execution that may pause for user interaction

Quotes

  • “An agent operates slightly differently; an Agent strings several tasks together to complete a more complex overreaching operation.” (Clarifies the core distinction between agents and single-task copilots, defining what agents do)
  • “There is a security hole in this implementation.” (Highlights a critical concern developers must address when building agents with elevated permissions)

AL objects mentioned

As named in the post. A name that matches one object page by exact type and name links to it; the others stay as named.

  • table “ARD_CashflowAgentSetup”
  • table “ARD_CashFlowAgentKPI”
  • codeunit “ARD_CashFlowAgentSetup”
  • codeunit “ARD_CashFlowAgentFactory”
  • codeunit “ARD_CashFlowAgentMetadata”
  • codeunit “ARD_CashFlowAgentKPILogging”
  • codeunit “ARD_CashFlowAgentInstall”
  • page “ARD_Cash Flow Agent Setup”
  • page “ARD_Cash Flow Agent KPI”
  • enum “ARD_CashFlowAgentCapability”
  • enum “ARD_CashFlowAgentMDProvider”

Not found in BC28-30: table “ARD_CashflowAgentSetup”, table “ARD_CashFlowAgentKPI”, codeunit “ARD_CashFlowAgentSetup”, codeunit “ARD_CashFlowAgentFactory”, codeunit “ARD_CashFlowAgentMetadata”, codeunit “ARD_CashFlowAgentKPILogging”, codeunit “ARD_CashFlowAgentInstall”, page “ARD_Cash Flow Agent Setup”, page “ARD_Cash Flow Agent KPI”, enum “ARD_CashFlowAgentCapability”, enum “ARD_CashFlowAgentMDProvider”.

Context

  • Features: Custom Agent capability, Agent Task Builder, Agent metadata provider, KPI tracking, Agent instructions from resources, Agent activation and task creation, User interaction during agent execution

Source: Aardvark Labs, community blog. Summary, key points and quotes are derived (CONTENT-NOTICE.md); read the original for the full text.