Erik's ToolBox Documentation
Index

AL AI Services App

AL AI Services is the Hougaard app that provides the agent infrastructure used by Erik's ToolBox and by other Hougaard apps. It owns the AI Providers page, the chat panel, the conversation store, and the connection to the twelve AI providers. The ToolBox contributes the two agents, their tools, and their instructions on top of it. This page describes the app for administrators and, briefly, for developers who want to add an agent of their own to another app.


Facts

Name / publisher AL AI Services, Hougaard
App ID 9095ed8c-5bff-4b5f-84db-c487250959b3
Object ID range 72214575 to 72214674
Depends on AL Compiler and Interpreter
Depended on by Erik's ToolBox and other Hougaard apps that host agents (for example Advanced Spreadsheets and Reporting)
Makes HTTP calls to The AI provider endpoints entered on the AI Providers page. Allow HttpClient Requests must be enabled for this extension
Installed Automatically with the ToolBox from AppSource; on-premises, publish it after the AL Compiler and Interpreter and before the ToolBox

What the App Provides

AI Providers

The AI Providers page (page 72214577) and the AI Provider table (table 72214576) hold one row per provider: Provider, Endpoint, Access Key, and Model. The list is shared: every app that hosts an agent adds its own toggle column (the ToolBox adds ToolBox Agent) and uses the row where its toggle is on. Several agents from different apps can therefore run on different providers and models while administrators maintain one list. See Setup.

The Agent Panel

The Agent card part (page 72214578) is the chat panel embedded as a FactBox on the Interactive Code page and the SQL Workbench. It renders Markdown replies, shows tool indicators, accepts file attachments by button or drag and drop, supports interrupting, and provides the New Conversation and Resume Conversation actions. When the host page has not configured a provider, it shows the "missing setup" message instead of a chat. See Using the Agent Panel.

Conversation Store

The AI Conversation table (table 72214575) and the AI Conversations list (page 72214576) store every conversation per user, stamped with the app and the agent scope that created it. Conversations are saved after each completed reply and resumed with the provider they were created with. See Conversations.

The Provider Client

The ALAI Mgt. codeunit (codeunit 72214575) builds each request in the provider's own format, adds the right authentication header, sends it, parses the reply, runs tool calls through events, feeds tool results back, and repeats until the model gives a final answer. It also:

  • retries on HTTP 429 up to ten times with a ten-second pause and waits up to five minutes per call;
  • converts image and PDF attachments into each provider's format and drops types the provider does not accept;
  • translates the tool definitions from one common shape into the OpenAI, Gemini, or Anthropic format;
  • marks the instructions, the tool definitions, and the conversation prefix for Anthropic prompt caching;
  • estimates tokens and records prompt sizes and cache hits from the provider's usage data;
  • serialises and restores conversations, including attachments, for the conversation store.

Tools Available

The Tools Available page (page 72214575) lists every tool currently registered for a tool group with name, description, and providing app. It is a diagnostic page without a menu entry; open it with ?page=72214575 in the Business Central URL.


Supported Providers

The AI Provider enum (enum 72214576) defines the providers. Every one of them supports tool calling.

Enum value Caption Wire format
AzureOpenAI Azure Open AI OpenAI chat completions
ChatGPTOpenAI ChatGPT Open AI OpenAI chat completions
Anthropic Anthropic (Claude) Anthropic messages
LMStudio LM Studio OpenAI chat completions
Gemini Google Gemini Gemini generateContent
Grok xAI Grok OpenAI chat completions
Mistral Mistral OpenAI chat completions
DeepSeek DeepSeek OpenAI chat completions
Kimi Moonshot Kimi OpenAI chat completions
Qwen Alibaba Qwen OpenAI chat completions
GLM Zhipu GLM OpenAI chat completions
MiniMax MiniMax OpenAI chat completions

Endpoints, default models, and key consoles are listed on the Setup page.


Permissions

The app ships the assignable permission set AL AI Services (ALAI Services Hgd), which grants read, insert, modify, and delete on the AI Provider and AI Conversation tables and execute on the codeunit and the four pages.

The Erik's ToolBox permission set includes the same permissions, so ToolBox users need nothing extra. Assign the AL AI Services set on its own only to users who should reach the AI Providers or AI Conversations pages from another app without being ToolBox users.

Note that both sets grant read access to the AI Provider table and therefore to the Access Keys. Keep the sets on the people who may know the keys.


For Developers: Adding an Agent to Your Own App

Any AL app can host an agent with the same panel, provider setup, and conversation store. The pattern the ToolBox uses for its two agents is the one to follow. In outline:

  1. Depend on AL AI Services in app.json (the AL Compiler and Interpreter dependency is resolved transitively; both .app files must be in .alpackages).
  2. Add a toggle to the AI Provider table with a table extension and show it on the AI Providers page with a page extension. Your host page finds the first row with your toggle on.
  3. Host the panel: put part(Agent; "ALAI Agent Part Hgd") in the FactBoxes area of your page and call its Setup(...) procedure in OnOpenPage with the provider row's values, an intro title, subtitle, and hints, your tool group name, and your system prompt. A second overload takes an explicit conversation scope; without it the first segment of the tool group is the scope.
  4. Contribute tools from a SingleInstance codeunit that subscribes to three events of codeunit "ALAI Mgt. Hgd": OnToolProviderRollCall (announce your app), OnGetTools (add your tools as name, description, input_schema objects when the tool group contains your group name), and OnToolCall (dispatch calls with your tool names to an implementation codeunit, leave others untouched). Validation failures raise error(); the text becomes the tool result the model reads.
  5. Share live page state with the tools codeunit by registering it on page open (tool calls run in the same session inside the panel's timer trigger), and poll for changes from the page, because a part cannot call its host: the ToolBox's editor control raises a sync event every two seconds and applies what the tools changed.
  6. Write the system prompt with identity and situation, the domain model, the working method (understand, discover, write, verify, explain), and safety rules.
  7. Add permissions for your new objects.

The complete guide, with the event signatures, JSON schema helpers, parameter helpers, the polling pattern, an optional skill library, and a minimal full template, is the file ALAI-Agent-Implementation-Guide.md in the Implementation Guides folder of the documentation source. The ToolBox's own implementation is in the ToolBox app's src/Agent folder: MCP Tools.al and MCP Impl.al for the coding agent, SQL MCP Tools.al and SQL MCP Impl.al for the SQL Agent, and AI Provider Ext.al for the toggle.

Rules that follow from how the framework works:

  • Tool names must be unique across all installed apps; every subscriber sees every call.
  • OnGetTools is raised on every round trip; keep it cheap and its order stable so prompt caching pays off.
  • Use only the JSON Schema vocabulary all providers accept (object, string, integer, number, boolean, array, properties, required, description, items).
  • Cap tool output; results are re-sent with every later round trip of the conversation.
  • Conversations are stamped with your app ID and scope, so your agent only resumes its own.