Skip to content

fix(openai-adapters): convert requestOptions.timeout from seconds to ms#12521

Open
devYRPauli wants to merge 1 commit into
continuedev:mainfrom
devYRPauli:fix/openai-adapter-timeout-seconds
Open

fix(openai-adapters): convert requestOptions.timeout from seconds to ms#12521
devYRPauli wants to merge 1 commit into
continuedev:mainfrom
devYRPauli:fix/openai-adapter-timeout-seconds

Conversation

@devYRPauli
Copy link
Copy Markdown

@devYRPauli devYRPauli commented May 29, 2026

Description

requestOptions.timeout is expressed in seconds throughout Continue (e.g. packages/fetch getAgentOptions: (timeout ?? 7200) * 1000 // ms), but packages/openai-adapters/src/apis/OpenAI.ts passed the raw value to the OpenAI JS SDK, which interprets timeout as milliseconds. So timeout: 300 (intended as 5 min) became 300ms — ~2000× too short — causing immediate "Connection error" failures, especially with local models. This multiplies by 1000 before passing to the SDK. Fixes #12450 (likely a root cause behind #11818 / #11954).

Checklist

  • I've read the contributing guide
  • The relevant tests, if any, have been updated or created

Tests

Added src/apis/OpenAI.test.ts: asserts the OpenAI client gets 300000 ms when requestOptions.timeout is 300, and the SDK default (600000) is preserved when unset. Full openai-adapters suite passes (147 tests); tsc + Prettier clean.


Summary by cubic

Fix timeout unit mismatch in packages/openai-adapters: convert requestOptions.timeout (seconds) to milliseconds before creating the OpenAI SDK client. Prevents 300s configs being treated as 300ms and avoids instant connection errors, especially with local models.

  • Bug Fixes
    • Multiply requestOptions.timeout by 1000 in OpenAIApi; preserve SDK default when unset (10m).
    • Add tests in packages/openai-adapters/src/apis/OpenAI.test.ts to verify conversion and default behavior.

Written for commit 572fe40. Summary will update on new commits.

Review in cubic

requestOptions.timeout is expressed in seconds throughout Continue (packages/fetch
getAgentOptions multiplies by 1000), but the OpenAI SDK client received the raw
value, which it treats as milliseconds. A user setting timeout: 300 got 300ms
instead of 300s, causing immediate "Connection error" failures (especially with
local models). Multiply by 1000 before passing to the SDK. Fixes continuedev#12450.
@devYRPauli devYRPauli requested a review from a team as a code owner May 29, 2026 17:57
@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label May 29, 2026
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 29, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@devYRPauli
Copy link
Copy Markdown
Author

devYRPauli commented May 29, 2026

I have read the CLA Document and I hereby sign the CLA

@devYRPauli
Copy link
Copy Markdown
Author

recheck

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

Re-trigger cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

OpenAI adapter passes timeout to SDK without unit conversion (seconds vs milliseconds)

1 participant