---
id: post/aardvarklabs-blog/3097
type: post
title: "Step-by-Step Guide: Create Agents in AL Code"
summary: 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.
tier: community
language: en
tags:
  - agent development
  - al code
  - custom agents
  - interfaces
  - task automation
  - copilot capability
  - agent metadata
system: copilot
review:
  state: reviewed
  by: opus
  at: "2026-10-08T01:55:53.444Z"
  flags: []
generated:
  at: "2026-10-08T01:26:53.141Z"
  pipeline: 0.2.0
  prompts:
    extract-post: 1
  input_hash: 9d3420464b85730977d270c4fa847a8e7908b39993a889588ac16e2e16ac4233
evidence:
  - kind: blog
    url: https://aardvarklabs.blog/2026/04/03/step-by-step-guide-create-agents-in-al-code/
    title: "Step-by-Step Guide: Create Agents in AL Code"
    date: "2026-04-03"
    commit: null
    t: null
    quote: null
  - kind: blog
    url: https://aardvarklabs.blog/2026/04/03/step-by-step-guide-create-agents-in-al-code/
    title: "Step-by-Step Guide: Create Agents in AL Code"
    date: "2026-04-03"
    commit: null
    t: null
    quote: An agent operates slightly differently; an Agent strings several tasks together to complete a more complex overreaching operation.
  - kind: blog
    url: https://aardvarklabs.blog/2026/04/03/step-by-step-guide-create-agents-in-al-code/
    title: "Step-by-Step Guide: Create Agents in AL Code"
    date: "2026-04-03"
    commit: null
    t: null
    quote: There is a security hole in this implementation.
links:
  learn: []
  objects: []
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
post_id: "3097"
source_id: aardvarklabs-blog
source_name: Aardvark Labs
url: https://aardvarklabs.blog/2026/04/03/step-by-step-guide-create-agents-in-al-code/
published_at: "2026-04-03T12:00:00.000Z"
author: Marcel Chabot
full_text: false
words: 2696
quotes:
  - text: An agent operates slightly differently; an Agent strings several tasks together to complete a more complex overreaching operation.
    why_it_matters: Clarifies the core distinction between agents and single-task copilots, defining what agents do
  - text: There is a security hole in this implementation.
    why_it_matters: Highlights a critical concern developers must address when building agents with elevated permissions
code_objects_mentioned:
  - 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
systems:
  - copilot
  - finance
  - development
versions_mentioned: []
preview:
  embeddable: true
  frame_url: https://aardvarklabs.blog/2026/04/03/step-by-step-guide-create-agents-in-al-code/embed/
  image: https://aardvarklabs.blog/wp-content/uploads/2026/03/aardvark-labs-69cc8a13da8fe.png
  image_alt: Humanoid robot in a suit reviewing a folder labeled CONFIDENTIAL in an office.
  image_w: 1024
  image_h: 1024
  site_name: Aardvark Labs
  favicon: https://aardvarklabs.blog/wp-content/uploads/2024/04/design-1.png?w=32
  probed_at: "2026-10-07T11:50:49.180Z"
---

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

[Read the post](https://aardvarklabs.blog/2026/04/03/step-by-step-guide-create-agents-in-al-code/) · Aardvark Labs (Marcel Chabot) · 2026-04-03 · 2696 words · tier community · reviewed (checked by Opus)

> 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.

## 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.
