Deprecate Text Completion API in AI SDK (work item 621038) - #10205
Deprecate Text Completion API in AI SDK (work item 621038)#10205martinsrui-msft wants to merge 4 commits into
Conversation
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>
|
Codeunit 7765 "AOAI Text Completion Params" (and its internal implementation codeunit 7766 "AOAI TextCompletionParams Impl") is being fully retired behind 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 |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
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 CLEAN29and added[Obsolete(..., '29.0')]/ObsoleteState=Pendingmetadata. - Guarded text-completion unit and partner tests with
#if not CLEAN29. - Scoped text-completion-only labels and metaprompt helpers behind
#if not CLEAN29in 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
|
Addressed the automated object-obsoletion review in 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 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 |
There was a problem hiding this comment.
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 | |||
There was a problem hiding this comment.
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>
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:
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
What I tested and the outcome (required — be specific: scenarios, commands, screenshots for UI changes)
Risk & compatibility