Prerequisites
Steps to reproduce
When using PowerShell AI Shell with the gpt-4.1 model, everything works as expected.
However, switching the model to o3 or gpt-5 causes the agent to fail with the following error:
ERROR: Agent failed to generate a response: HTTP 400
(invalid_request_error: unsupported_parameter)
Parameter: max_tokens
Unsupported parameter: 'max_tokens' is not supported with this model.
Use 'max_completion_tokens' instead.
It appears that PowerShell AI Shell is still sending the max_tokens parameter,
which is not supported by o3 and gpt-5 models.
Expected behavior
The shell should either:- Automatically use `max_completion_tokens` for models that require it, or- Adapt parameters based on the selected model.
Actual behavior
The request fails with an HTTP 400 error when using o3 or gpt-5.
Error details
ERROR: Agent failed to generate a response: HTTP 400(invalid_request_error: unsupported_parameter)Parameter: max_tokensUnsupported parameter: 'max_tokens' is not supported withthis model. Use 'max_completion_tokens' instead. atOpenAI.ClientPipelineExtensions.ProcessMessageAsync(ClientPipeline pipeline, PipelineMessage message, RequestOptionsoptions) at OpenAI.Chat.ChatClient.CompleteChatAsync(BinaryContentcontent, RequestOptions options) atOpenAI.Chat.ChatClient.<>c__DisplayClass10_0.<<CompleteChatStreamingAsync>b__0>d.MoveNext()--- End of stack trace from previous location --- atOpenAI.AsyncSseUpdateCollection`1.GetRawPagesAsync()+MoveNext() atOpenAI.AsyncSseUpdateCollection`1.GetRawPagesAsync()+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult() atSystem.ClientModel.AsyncCollectionResult`1.GetAsyncEnumerator(CancellationToken cancellationToken)+MoveNext() atSystem.ClientModel.AsyncCollectionResult`1.GetAsyncEnumerator(CancellationToken cancellationToken)+MoveNext() atSystem.ClientModel.AsyncCollectionResult`1.GetAsyncEnumerator(CancellationTokencancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult() atMicrosoft.Extensions.AI.OpenAIChatClient.FromOpenAIStreamingChatCompletionAsync(IAsyncEnumerable`1 updates,CancellationToken cancellationToken)+MoveNext() atMicrosoft.Extensions.AI.OpenAIChatClient.FromOpenAIStreamingChatCompletionAsync(IAsyncEnumerable`1 updates,CancellationToken cancellationToken)+MoveNext() atMicrosoft.Extensions.AI.OpenAIChatClient.FromOpenAIStreamingChatCompletionAsync(IAsyncEnumerable`1 updates,CancellationTokencancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult() atMicrosoft.Extensions.AI.FunctionInvokingChatClient.GetStreamingResponseAsync(IEnumerable`1 messages, ChatOptionsoptions, CancellationToken cancellationToken)+MoveNext() atMicrosoft.Extensions.AI.FunctionInvokingChatClient.GetStreamingResponseAsync(IEnumerable`1 messages, ChatOptionsoptions, CancellationToken cancellationToken)+MoveNext() atMicrosoft.Extensions.AI.FunctionInvokingChatClient.GetStreamingResponseAsync(IEnumerable`1 messages, ChatOptionsoptions, CancellationTokencancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult() atAIShell.OpenAI.Agent.ChatService.GetStreamingChatResponseAsync(String input, IShell shell, CancellationTokencancellationToken) atSpectre.Console.Status.<>c__DisplayClass17_0`1.<<StartAsync>b__0>d.MoveNext() in/_/src/Spectre.Console/Live/Status/Status.cs:line 120--- End of stack trace from previous location --- atSpectre.Console.Progress.<>c__DisplayClass32_0`1.<<StartAsync>b__0>d.MoveNext() in/_/src/Spectre.Console/Live/Progress/Progress.cs:line 138--- End of stack trace from previous location --- atSpectre.Console.Internal.DefaultExclusivityMode.RunAsync[T](Func`1 func) in/_/src/Spectre.Console/Internal/DefaultExclusivityMode.cs:line 40 at Spectre.Console.Progress.StartAsync[T](Func`2 action)in /_/src/Spectre.Console/Live/Progress/Progress.cs:line 121 at Spectre.Console.Status.StartAsync[T](String status,Func`2 func) in/_/src/Spectre.Console/Live/Status/Status.cs:line 117 at AIShell.Kernel.Host.RunWithSpinnerAsync[T](Func`1func, String status, Nullable`1 spinnerKind) at AIShell.OpenAI.Agent.OpenAIAgent.ChatAsync(Stringinput, IShell shell) at AIShell.Kernel.Shell.RunREPLAsync()
Environment data
- PowerShell AI Shell
- Model: o3 / gpt-5
Version
1.0.0-preview.8
Visuals

Prerequisites
Steps to reproduce
When using PowerShell AI Shell with the gpt-4.1 model, everything works as expected.
However, switching the model to o3 or gpt-5 causes the agent to fail with the following error:
ERROR: Agent failed to generate a response: HTTP 400
(invalid_request_error: unsupported_parameter)
Parameter: max_tokens
Unsupported parameter: 'max_tokens' is not supported with this model.
Use 'max_completion_tokens' instead.
It appears that PowerShell AI Shell is still sending the
max_tokensparameter,which is not supported by o3 and gpt-5 models.
Expected behavior
Actual behavior
The request fails with an HTTP 400 error when using o3 or gpt-5.Error details
Environment data
Version
1.0.0-preview.8
Visuals