Skip to content

fix(openai-adapters): convert requestOptions.timeout from seconds to milliseconds#12563

Open
chatman-media wants to merge 1 commit into
continuedev:mainfrom
chatman-media:fix/openai-timeout-seconds-to-ms
Open

fix(openai-adapters): convert requestOptions.timeout from seconds to milliseconds#12563
chatman-media wants to merge 1 commit into
continuedev:mainfrom
chatman-media:fix/openai-timeout-seconds-to-ms

Conversation

@chatman-media

@chatman-media chatman-media commented Jun 5, 2026

Copy link
Copy Markdown

Closes #12450.

requestOptions.timeout is specified in seconds throughout Continue — getAgentOptions in @continuedev/fetch does (requestOptions?.timeout ?? TIMEOUT) * 1000; // measured in ms. But packages/openai-adapters/src/apis/OpenAI.ts passed the value straight to the OpenAI SDK constructor, which expects milliseconds.

So a user setting timeout: 300 (intending 5 minutes) got a 300 ms timeout — ~2000× too short — causing immediate "Connection error" failures, especially with local models that need time to load and process prompts. This matches the reports referenced in #11818 / #11954.

Fix: multiply by 1000 to convert seconds → ms, consistent with getAgentOptions. When timeout is unset, undefined is passed so the OpenAI SDK keeps its own default (600000 ms).

🤖 Generated with Claude Code


Summary by cubic

Fixes the OpenAI adapter timeout by converting requestOptions.timeout from seconds to milliseconds before passing it to the SDK. Prevents premature connection errors (300s no longer becomes 300ms); 0/undefined are treated as unset so the SDK default applies.

  • Bug Fixes
    • Added timeoutSecondsToMs utility with unit tests and used it when setting the SDK timeout.

Written for commit c57f33a. Summary will update on new commits.

Review in cubic

@chatman-media chatman-media requested a review from a team as a code owner June 5, 2026 13:49
@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jun 5, 2026
@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

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

@cubic-dev-ai cubic-dev-ai Bot 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.

No issues found across 1 file

Re-trigger cubic

@chatman-media chatman-media force-pushed the fix/openai-timeout-seconds-to-ms branch from c671741 to c9bbec2 Compare June 5, 2026 13:57
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Jun 5, 2026
…milliseconds

requestOptions.timeout is specified in seconds across Continue (see getAgentOptions
in @continuedev/fetch, which does `(requestOptions?.timeout ?? TIMEOUT) * 1000`,
commented "measured in ms"), but the OpenAI adapter passed it straight to the OpenAI
SDK constructor, which expects milliseconds. A user setting `timeout: 300` therefore
got a 300ms timeout instead of 300s, causing immediate "Connection error" failures
(common with local models). Multiply by 1000 to convert.

Closes continuedev#12450
@chatman-media chatman-media force-pushed the fix/openai-timeout-seconds-to-ms branch from c9bbec2 to c57f33a Compare June 5, 2026 14:20
@chatman-media

chatman-media commented Jun 5, 2026

Copy link
Copy Markdown
Author

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

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

Labels

size:S This PR changes 10-29 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