Agents in Business Central – part 5 – Creating agent from code
This post explains how to create, configure, and register agents programmatically in Business Central using AL code instead of relying solely on configuration. It covers agent interfaces, capability registration, setup pages, and KPI tracking needed for production-ready, ALM-compatible agent solutions.

post Discover Microsoft Business Central - The wonderful world of Business Central
Key points
- Register the agent as a Copilot capability by extending the Copilot Capability enum and registering it on install
- Implement IAgentFactory to control agent creation, setup experience, and access; implement IAgentMetadata to control runtime display and UI
- Use IAgentTaskExecution to annotate agent messages, offer user intervention suggestions, and set page context such as currency and language
- Create setup pages using PageType ConfigurationDialog with a temporary source table that has a User Security ID field
- Build KPI pages as CardPart pages with cuegroups and a User Security ID field, assigned via the IAgentMetadata implementation
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.
- enum “Copilot Capability”
- codeunit 4321 “Agent”
- interface “IAgentFactory”
- interface “IAgentMetadata”
- interface “IAgentExperimental”
- interface “IAgentTaskExecution”
Not found in BC28-30: enum “Copilot Capability”, interface “IAgentFactory”, interface “IAgentMetadata”, interface “IAgentExperimental”, interface “IAgentTaskExecution”.
Possibly related
No source states these links: they share an object, a model read them, or a person found the same subject.
- Configure agents programmatically (preview) — possibly related: names Codeunit 4321 “Agent”
- Convert an agent to AL code (preview) — possibly related: names Codeunit 4321 “Agent”
- Dynamics 365 Business Central: new model choice in Agent definition. — possibly related: both name Codeunit 4321 “Agent”
- Microsoft presents: Building and shipping agents in Business Central — possibly related: both name Codeunit 4321 “Agent”
- Weekly Review: Business Central AL Development – May 31–June 6, 2026 — possibly related: both name Codeunit 4321 “Agent”
Heads up
- warning: “You cannot implement this because it is internal.” (about interface IAgentExperimental)
Context
- Features: agent creation from code, capability registration, agent factory interface, agent metadata interface, task execution interface, setup pages, KPI pages, user intervention suggestions
Source: Discover MS BC - Bert Verbeek, community blog. Summary, key points and quotes are derived (CONTENT-NOTICE.md); read the original for the full text.