fix(ai,coding-agent): omit undefined provider request options closes #3627
This commit is contained in:
@@ -2,6 +2,10 @@
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed OpenAI/Azure/Anthropic provider request option forwarding to omit undefined `timeout`/`maxRetries`, avoiding SDK validation errors such as `timeout must be an integer` when provider controls are not set ([#3627](https://github.com/badlogic/pi-mono/issues/3627))
|
||||
|
||||
## [0.70.1] - 2026-04-24
|
||||
|
||||
### Added
|
||||
|
||||
@@ -456,16 +456,12 @@ export const streamAnthropic: StreamFunction<"anthropic-messages", AnthropicOpti
|
||||
if (nextParams !== undefined) {
|
||||
params = nextParams as MessageCreateParamsStreaming;
|
||||
}
|
||||
const response = await client.messages
|
||||
.create(
|
||||
{ ...params, stream: true },
|
||||
{
|
||||
signal: options?.signal,
|
||||
timeout: options?.timeoutMs,
|
||||
maxRetries: options?.maxRetries,
|
||||
},
|
||||
)
|
||||
.asResponse();
|
||||
const requestOptions = {
|
||||
...(options?.signal ? { signal: options.signal } : {}),
|
||||
...(options?.timeoutMs !== undefined ? { timeout: options.timeoutMs } : {}),
|
||||
...(options?.maxRetries !== undefined ? { maxRetries: options.maxRetries } : {}),
|
||||
};
|
||||
const response = await client.messages.create({ ...params, stream: true }, requestOptions).asResponse();
|
||||
await options?.onResponse?.({ status: response.status, headers: headersToRecord(response.headers) }, model);
|
||||
stream.push({ type: "start", partial: output });
|
||||
|
||||
|
||||
@@ -91,13 +91,12 @@ export const streamAzureOpenAIResponses: StreamFunction<"azure-openai-responses"
|
||||
if (nextParams !== undefined) {
|
||||
params = nextParams as ResponseCreateParamsStreaming;
|
||||
}
|
||||
const { data: openaiStream, response } = await client.responses
|
||||
.create(params, {
|
||||
signal: options?.signal,
|
||||
timeout: options?.timeoutMs,
|
||||
maxRetries: options?.maxRetries,
|
||||
})
|
||||
.withResponse();
|
||||
const requestOptions = {
|
||||
...(options?.signal ? { signal: options.signal } : {}),
|
||||
...(options?.timeoutMs !== undefined ? { timeout: options.timeoutMs } : {}),
|
||||
...(options?.maxRetries !== undefined ? { maxRetries: options.maxRetries } : {}),
|
||||
};
|
||||
const { data: openaiStream, response } = await client.responses.create(params, requestOptions).withResponse();
|
||||
await options?.onResponse?.({ status: response.status, headers: headersToRecord(response.headers) }, model);
|
||||
stream.push({ type: "start", partial: output });
|
||||
|
||||
|
||||
@@ -144,12 +144,13 @@ export const streamOpenAICompletions: StreamFunction<"openai-completions", OpenA
|
||||
if (nextParams !== undefined) {
|
||||
params = nextParams as OpenAI.Chat.Completions.ChatCompletionCreateParamsStreaming;
|
||||
}
|
||||
const requestOptions = {
|
||||
...(options?.signal ? { signal: options.signal } : {}),
|
||||
...(options?.timeoutMs !== undefined ? { timeout: options.timeoutMs } : {}),
|
||||
...(options?.maxRetries !== undefined ? { maxRetries: options.maxRetries } : {}),
|
||||
};
|
||||
const { data: openaiStream, response } = await client.chat.completions
|
||||
.create(params, {
|
||||
signal: options?.signal,
|
||||
timeout: options?.timeoutMs,
|
||||
maxRetries: options?.maxRetries,
|
||||
})
|
||||
.create(params, requestOptions)
|
||||
.withResponse();
|
||||
await options?.onResponse?.({ status: response.status, headers: headersToRecord(response.headers) }, model);
|
||||
stream.push({ type: "start", partial: output });
|
||||
|
||||
@@ -98,13 +98,12 @@ export const streamOpenAIResponses: StreamFunction<"openai-responses", OpenAIRes
|
||||
if (nextParams !== undefined) {
|
||||
params = nextParams as ResponseCreateParamsStreaming;
|
||||
}
|
||||
const { data: openaiStream, response } = await client.responses
|
||||
.create(params, {
|
||||
signal: options?.signal,
|
||||
timeout: options?.timeoutMs,
|
||||
maxRetries: options?.maxRetries,
|
||||
})
|
||||
.withResponse();
|
||||
const requestOptions = {
|
||||
...(options?.signal ? { signal: options.signal } : {}),
|
||||
...(options?.timeoutMs !== undefined ? { timeout: options.timeoutMs } : {}),
|
||||
...(options?.maxRetries !== undefined ? { maxRetries: options.maxRetries } : {}),
|
||||
};
|
||||
const { data: openaiStream, response } = await client.responses.create(params, requestOptions).withResponse();
|
||||
await options?.onResponse?.({ status: response.status, headers: headersToRecord(response.headers) }, model);
|
||||
stream.push({ type: "start", partial: output });
|
||||
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed provider retry/timeout forwarding to omit undefined provider request controls, avoiding downstream SDK validation errors such as `timeout must be an integer` when `retry.provider.timeoutMs` is not configured ([#3627](https://github.com/badlogic/pi-mono/issues/3627))
|
||||
|
||||
## [0.70.1] - 2026-04-24
|
||||
|
||||
### New Features
|
||||
|
||||
Reference in New Issue
Block a user