---
id: object/codeunit/7764
type: object
title: Codeunit 7764 "AOAI Chat Messages Impl"
summary: Codeunit 7764 "AOAI Chat Messages Impl" in System Application (System.AI). 25 public procedures. Present since at least BC23, still in BC30, changed in BC24-25, BC27-28.
tier: official
language: en
tags:
  - codeunit
  - system application
versions:
  introduced: null
  last_changed: "28"
  deprecated: null
review:
  state: derived
  by: null
  at: null
  flags: []
generated:
  at: "2026-10-11T00:31:51.816Z"
  pipeline: 0.2.0
  prompts: {}
  input_hash: 60327313b19879da5d67400001d3e6b26a4e21b94893405fd0942ad1fc9d4492
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/System%20Application/App/AI/src/Azure%20OpenAI/Chat%20Completion/AOAIChatMessagesImpl.Codeunit.al
    title: src/System Application/App/AI/src/Azure OpenAI/Chat Completion/AOAIChatMessagesImpl.Codeunit.al (releases/29.x)
    date: null
    commit: ea08af5ef2d6a9b5c5af4a029288abbe2c883220
    t: null
    quote: null
links:
  learn: []
  objects: []
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
  changes:
    - change/bcapps/11375
    - change/bcapps/9910
object_type: codeunit
object_id: 7764
name: AOAI Chat Messages Impl
namespace: System.AI
app: System Application
extends: null
first_version: "23"
last_version: "30"
present_in:
  - "23"
  - "24"
  - "25"
  - "26"
  - "27"
  - "28"
  - "29"
  - "30"
changed_in:
  - "24"
  - "25"
  - "27"
  - "28"
source_major: "29"
obsolete: null
countries: []
ms_search_form_ids: []
counts:
  fields: 0
  procedures: 33
  events: 0
  subscribers: 0
relations:
  out: 0
  referenced_by: 0
  pages: 0
  extended_by: 0
  event_subscribers: 0
  calls: 7
  called_by: 1
  implements: 0
---

# Codeunit 7764 "AOAI Chat Messages Impl"

> Codeunit 7764 "AOAI Chat Messages Impl" in System Application (System.AI). 25 public procedures. Present since at least BC23, still in BC30, changed in BC24-25, BC27-28.

System Application · System.AI · BC23-30 · [source at ea08af5e](https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/System%20Application/App/AI/src/Azure%20OpenAI/Chat%20Completion/AOAIChatMessagesImpl.Codeunit.al) · facts from BC29

## Properties

| Property | Value |
|---|---|
| Access | Internal |

## Procedures

- `SetPrimarySystemMessage(NewPrimaryMessage: SecretText)`
- `AddSystemMessage(NewMessage: Text)`
- `AddUserMessage(NewMessage: Text)`
- `AddUserMessage(NewMessage: Text; NewName: Text[2048])`
- `AddUserMessage(AOAIUserMessage: Codeunit "AOAI User Message")`
- `AddUserMessage(AOAIUserMessage: Codeunit "AOAI User Message"; NewName: Text[2048])`
- `AddAssistantMessage(NewMessage: Text)`
- `AddToolCalls(ToolCalls: JsonArray)`
- `AddToolMessage(ToolCallId: Text; FunctionName: Text; FunctionResult: Text)`
- `ModifyMessage(Id: Integer; NewMessage: Text; NewRole: Enum "AOAI Chat Roles"; NewName: Text[2048])`
- `DeleteMessage(Id: Integer)`
- `GetHistory(): List of [Text]`
- `GetHistoryNames(): List of [Text[2048]]`
- `GetHistoryRoles(): List of [Enum "AOAI Chat Roles"]`
- `GetHistoryToolCallIds(): List of [Text]`
- `GetLastMessage(): Text`
- `GetLastRole(): Enum "AOAI Chat Roles"`
- `GetLastName(): Text[2048]`
- `GetLastToolCalls(): JsonArray`
- `GetLastToolCallId(): Text`
- `SetHistoryLength(NewHistoryLength: Integer)`
- `GetHistoryTokenCount(): Integer`
- `PrepareHistory(var SystemMessageTokenCount: Integer; var MessagesTokenCount: Integer): JsonArray`
- `AddXPIADetectionTags(var Input: Text)`
- `CheckCompatibilityWithModel(Deployment: SecretText)`

Plus 8 local procedures.

## Calls

From the extracted call graph of BC29 (graphify-al on the snapshot checkout): calls whose target is known from a declared type or an `Object::"Name"` argument. Interface dispatch and calls through events are not counted, so the list is not complete.

- [Codeunit 7783 "AOAI User Message"](../codeunit/7783.md) (3 calls: `CheckCompatibilityWithModel → HasFilePart`, `PrepareHistory → GetContentParts`, `PrepareHistory → IsSet`)
- [Codeunit 8711 "Telemetry"](../codeunit/8711.md) (3 calls: `CheckandAddMetaprompt → LogMessage`, `GetChatMetaprompt → LogMessage`, `PrepareMessage → LogMessage`)
- [Codeunit 2200 "Azure Key Vault"](../codeunit/2200.md) (2 calls: `GetChatMetaprompt → GetAzureKeyVaultSecret`, `PrepareMessage → GetAzureKeyVaultSecret`)
- [Codeunit 457 "Environment Information"](../codeunit/457.md) (1 call: `GetChatMetaprompt → IsSaaSInfrastructure`)
- [Codeunit 7759 "AOAI Token"](../codeunit/7759.md) (1 call: `PrepareHistory → GetGPT4TokenCount`)
- [Codeunit 7769 "AOAI Deployments Impl"](../codeunit/7769.md) (1 call: `CheckCompatibilityWithModel → IsFileContentSupported`)
- [Codeunit 7772 "Azure OpenAI Impl"](../codeunit/7772.md) (1 call: `PrepareMessage → RemoveProhibitedCharacters`)

## Called by

- [Codeunit 7763 "AOAI Chat Messages"](../codeunit/7763.md) (20 calls: `AddAssistantMessage → AddAssistantMessage`, `AddSystemMessage → AddSystemMessage`, `AddToolCalls → AddToolCalls`, …)

## Recent changes

- 2026-09-23 [#11375 Obsolete GPT-5.5 chat and add GPT-5.6 Ceres deployments](../../changes/bcapps/11375.md) (main, BC30, obsoletion)
- 2026-08-15 [#9910 [SOA] Move attachment processing to direct model reading](../../changes/bcapps/9910.md) (main, BC30, feature)

## Across versions

- Present in: BC23-30
- Changed (declaration) in: BC24-25, BC27-28

Source: AL metadata extracted from the code (names, ids, signatures, properties); no code bodies (D10).

## Ask your agent

Procedure bodies are not stored here (D10). The call sections above are our own, per object, from the BC29 call graph. For a procedure body or the calls of one procedure, ask bc-code-atlas (external, by Stefan Maron, MIT; default corpus w1-28), which the bc-observatory plugin connects: `bcatlas_resolve_node(object_type: "codeunit", object_name: "AOAI Chat Messages Impl")`, then `bcatlas_get_procedure_body` or `bcatlas_get_neighbors` on the returned id.
