Skip to content

Deprecate Text Completion API in AI SDK (work item 621038) - #10205

Open
martinsrui-msft wants to merge 4 commits into
mainfrom
private/martinsrui/deprecate-text-completion
Open

Deprecate Text Completion API in AI SDK (work item 621038)#10205
martinsrui-msft wants to merge 4 commits into
mainfrom
private/martinsrui/deprecate-text-completion

Conversation

@martinsrui-msft

@martinsrui-msft martinsrui-msft commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Text completion (davinci) models are retired by Azure OpenAI. Deprecate the Text Completion surface of the System Application AI module using the repo's #if not CLEANxx + [Obsolete('...', '29.0')] convention:

  • AzureOpenAI (7771): mark the 4 public GenerateTextCompletion overloads [Obsolete] and guard with #if not CLEAN29.
  • AzureOpenAIImpl (7772): guard the 4 internal GenerateTextCompletion overloads, the GetTextMetaprompt / CheckTextCompletionMetaprompt helpers and the text-completion-only labels with #if not CLEAN29.
  • AOAI Text Completion Params (7765) and AOAI TextCompletionParams Impl (7766): guard the whole objects with #if not CLEAN29.
  • Guard the text-completion unit and partner tests with #if not CLEAN29.

The "AOAI Model Type"::"Text Completions" enum value and the shared authorization / SendRequest plumbing are intentionally retained to avoid AL0432 cascades from the generic multi-model methods; obsoleting the enum value is left as a follow-up.

Verified: System Application compiles in both Default and Clean (CLEAN25-29) modes with no new errors attributable to this change; the remaining compile errors are environmental (missing platform .NET assemblies) and require a BC platform/container. Runtime behaviour when AL calls the Text Completion API must be verified on a devbox with CAPI access.

Cerified on a devbox. The agent created and published a disposable AL extension to a local NAV NST configured to use the standalone Copilot Service connected to CAPI.
The extension executed  Azure OpenAI.GenerateTextCompletion  from an AL background session, exercising the complete path:
 AL → NAV NST → Copilot Service → CAPI 
The request returned  200 OK  with the expected completion. This confirms that the deprecated API remains runtime-compatible before  CLEAN29 , while the  [Obsolete]  annotation warns consumers to migrate and the  CLEAN29  build removes the API

What & why

Linked work

AB#620033

Fixes #

How I validated this

  • I read the full diff and it contains only changes I intended.
  • I built the affected app(s) locally with no new analyzer warnings.
  • I ran the change in Business Central and confirmed it behaves as expected.
  • I added or updated tests for the new behavior, or explained below why none are needed.

What I tested and the outcome (required — be specific: scenarios, commands, screenshots for UI changes)

Risk & compatibility

Text completion (davinci) models are retired by Azure OpenAI. Deprecate the
Text Completion surface of the System Application AI module using the repo's
#if not CLEANxx + [Obsolete('...', '29.0')] convention:

- AzureOpenAI (7771): mark the 4 public GenerateTextCompletion overloads
  [Obsolete] and guard with #if not CLEAN29.
- AzureOpenAIImpl (7772): guard the 4 internal GenerateTextCompletion
  overloads, the GetTextMetaprompt / CheckTextCompletionMetaprompt helpers
  and the text-completion-only labels with #if not CLEAN29.
- AOAI Text Completion Params (7765) and AOAI TextCompletionParams Impl
  (7766): guard the whole objects with #if not CLEAN29.
- Guard the text-completion unit and partner tests with #if not CLEAN29.

The "AOAI Model Type"::"Text Completions" enum value and the shared
authorization / SendRequest plumbing are intentionally retained to avoid
AL0432 cascades from the generic multi-model methods; obsoleting the enum
value is left as a follow-up.

Verified: System Application compiles in both Default and Clean
(CLEAN25-29) modes with no new errors attributable to this change; the
remaining compile errors are environmental (missing platform .NET
assemblies) and require a BC platform/container. Runtime behaviour when AL
calls the Text Completion API must be verified on a devbox with CAPI access.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@martinsrui-msft
martinsrui-msft requested review from a team August 12, 2026 14:07
@github-actions github-actions Bot added AL: System Application Integration GitHub request for Integration area labels Aug 12, 2026
@github-actions github-actions Bot added this to the Version 29.0 milestone Aug 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

$\textbf{🟠\ High\ Severity\ —\ Breaking\ Changes}$

Codeunit 7765 "AOAI Text Completion Params" (and its internal implementation codeunit 7766 "AOAI TextCompletionParams Impl") is being fully retired behind #if not CLEAN29 ... #endif with no ObsoleteState/ObsoleteReason/ObsoleteTag on the object itself. Unlike the GenerateTextCompletion procedures in codeunit 7771, which correctly receive [Obsolete('...', '29.0')] attributes giving consumers a compiler warning ahead of removal, this public codeunit disappears silently and completely once CLEAN29 is enabled — any extension referencing "AOAI Text Completion Params" directly gets no deprecation warning at all before compilation breaks. The object should be marked ObsoleteState = Pending with a matching ObsoleteReason and ObsoleteTag = '29.0' (consistent with the procedure-level attributes) before or instead of wrapping the whole type in conditional compilation.

Suggested fix (apply manually — could not be anchored as a one-click suggestion):

codeunit 7765 "AOAI Text Completion Params"
{
    Access = Public;
    InherentEntitlements = X;
    InherentPermissions = X;
    ObsoleteState = Pending;
    ObsoleteReason = 'Text completion (davinci) models are retired by Azure OpenAI. Use GenerateChatCompletion instead.';
    ObsoleteTag = '29.0';

Knowledge:

Line mapping was unavailable, so this was posted as an issue comment.

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.32.4

Comment thread src/System Application/App/AI/src/Azure OpenAI/AzureOpenAI.Codeunit.al Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@martinsrui-msft
martinsrui-msft requested review from Darrick (darjoo) and a lite review from Copilot August 13, 2026 08:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Deprecates the System Application AI module’s Azure OpenAI text-completion (legacy “davinci”/text completions) surface by marking the public API as obsolete and removing it from CLEAN29 builds, while retaining shared multi-model plumbing and the "AOAI Model Type"::"Text Completions" enum value for compatibility.

Changes:

  • Wrapped text-completion public APIs, internal implementation helpers, and parameter objects in #if not CLEAN29 and added [Obsolete(..., '29.0')] / ObsoleteState=Pending metadata.
  • Guarded text-completion unit and partner tests with #if not CLEAN29.
  • Scoped text-completion-only labels and metaprompt helpers behind #if not CLEAN29 in the implementation codeunit.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/System Application/App/AI/src/Azure OpenAI/AzureOpenAI.Codeunit.al Marks the 4 public GenerateTextCompletion overloads as obsolete and removes them in CLEAN29 via #if not CLEAN29.
src/System Application/App/AI/src/Azure OpenAI/AzureOpenAIImpl.Codeunit.al Guards text-completion-only labels, GenerateTextCompletion overloads, and metaprompt helpers behind #if not CLEAN29.
src/System Application/App/AI/src/Azure OpenAI/Text Completion/AOAITextCompletionParams.Codeunit.al Guards the public text-completion params codeunit behind #if not CLEAN29 and marks it ObsoleteState=Pending (29.0).
src/System Application/App/AI/src/Azure OpenAI/Text Completion/AOAITextCompletionParamsImpl.Codeunit.al Guards the internal params implementation codeunit behind #if not CLEAN29 and marks it ObsoleteState=Pending (29.0).
src/System Application/Test/AI/src/AzureOpenAITest.Codeunit.al Wraps text-completion tests in #if not CLEAN29 so CLEAN29 builds don’t reference removed APIs.
src/System Application/Partner Test/AI/src/AzureOpenAITestPartner.Codeunit.al Wraps partner text-completion test in #if not CLEAN29 for CLEAN29 compatibility.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: c254f0ef-9fef-4217-82f2-1de3980c1568
@martinsrui-msft

Copy link
Copy Markdown
Contributor Author

Addressed the automated object-obsoletion review in f90ccb9b4f:

ObsoleteState = Pending;
ObsoleteReason = 'Text completion models are retired by Azure OpenAI. Use GenerateChatCompletion instead.';
ObsoleteTag = '29.0';

Both codeunits 7765 and 7766 now carry the metadata before CLEAN29 removes them.

The initial patch guarded removal without first marking the objects Pending; the feedback follow-up corrected that staging.

Useful detection signal: when a public object is placed behind a new CLEAN guard, verify object-level Pending metadata exists outside the clean-removal behavior so normal builds provide a warning window.

AzureOpenAIImpl.SetAuthorization(ModelType, Deployment);
end;

#if not CLEAN29

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟠\ High\ Severity\ —\ Upgrade}$

GenerateTextCompletion (all four overloads) on codeunit 7771 "Azure OpenAI" is marked [Obsolete('...', '29.0')] (Pending stage) but the entire block is also wrapped in #if not CLEAN29 ... #endif, with the internal AL0432 warning suppressed. Per the obsoletion staging guidance, Pending should keep the element compilable and callable (with only a deprecation warning); the #if not CLEAN<version> removal mechanic belongs to the later Removed stage. As written, defining CLEAN29 removes these public procedures from compilation immediately, giving consumers no working deprecation window despite the Pending marker implying one.

Knowledge:

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.32.4

@@ -1,3 +1,4 @@
#if not CLEAN29

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟠\ High\ Severity\ —\ Upgrade}$

Codeunit 7765 "AOAI Text Completion Params" sets ObsoleteState = Pending (with ObsoleteReason/ObsoleteTag = '29.0') but the entire public codeunit body is also wrapped in #if not CLEAN29 ... #endif. The same pattern is repeated on internal codeunit 7766 "AOAI TextCompletionParams Impl". Per the obsoletion staging guidance, a Pending element must remain present and compilable; using #if not CLEAN<version> to remove the whole object body belongs to the Removed stage, staged in a later release. Combining both in the same PR erases these codeunits entirely once CLEAN29 is defined, with no working Pending window.

Knowledge:

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.32.4

The Text Completion deprecation left the AI test codeunits failing to compile
in CI:

- Clean (CLEAN29 defined): guard the declarations that were only referenced by
  already-guarded code, so they are not flagged as unused:
  - AzureOpenAITest: BillingTypeAuthorizationErr label (AA0137).
  - AzureOpenAITestPartner: using System.TestLibraries.AI (AL0792).
- Default (CLEAN29 not defined): the guarded text-completion tests call the
  newly [Obsolete('...', '29.0')] GenerateTextCompletion overloads, which trips
  AL0432. Wrap those blocks in #pragma warning disable/restore AL0432, mirroring
  the App-side AzureOpenAI / AzureOpenAIImpl pattern.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AL: System Application Integration GitHub request for Integration area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants