Roo-Code/packages/types
Hannes Rudolph 3949621cf1 feat(openai-native): background mode + auto-resume and poll fallback
Enable OpenAI Responses background mode with resilient streaming for GPT‑5 Pro and any model flagged via metadata.

Key changes:

- Background mode enablement

  • Auto-enable for models with info.backgroundMode === true (e.g., gpt-5-pro-2025-10-06) defined in [packages/types/src/providers/openai.ts](packages/types/src/providers/openai.ts).

  • Also respects manual override (openAiNativeBackgroundMode) from ProviderSettings/ApiHandlerOptions.

- Request shape (Responses API)

  • background:true, stream:true, store:true set in [OpenAiNativeHandler.buildRequestBody()](src/api/providers/openai-native.ts:224).

- Streaming UX and status events

  • New ApiStreamStatusChunk in [src/api/transform/stream.ts](src/api/transform/stream.ts) with statuses: queued, in_progress, completed, failed, canceled, reconnecting, polling.

  • Provider emits status chunks in SDK + SSE paths via [OpenAiNativeHandler.processEvent()](src/api/providers/openai-native.ts:1100) and [OpenAiNativeHandler.handleStreamResponse()](src/api/providers/openai-native.ts:651).

  • UI spinner shows background lifecycle labels in [webview-ui/src/components/chat/ChatRow.tsx](webview-ui/src/components/chat/ChatRow.tsx) using [webview-ui/src/utils/backgroundStatus.ts](webview-ui/src/utils/backgroundStatus.ts).

- Resilience: auto-resume + poll fallback

  • On stream drop for background tasks, attempt SSE resume using response.id and last sequence_number with exponential backoff in [OpenAiNativeHandler.attemptResumeOrPoll()](src/api/providers/openai-native.ts:1215).

  • If resume fails, poll GET /v1/responses/{id} every 2s until terminal and synthesize final output/usage.

  • Deduplicate resumed events via resumeCutoffSequence in [handleStreamResponse()](src/api/providers/openai-native.ts:737).

- Settings (no new UI switch)

  • Added optional provider settings and ApiHandlerOptions: autoResume, resumeMaxRetries, resumeBaseDelayMs, pollIntervalMs, pollMaxMinutes in [packages/types/src/provider-settings.ts](packages/types/src/provider-settings.ts) and [src/shared/api.ts](src/shared/api.ts).

- Cleanup

  • Removed VS Code contributes toggle for background mode; behavior now model-driven + programmatic override.

- Tests

  • Provider: coverage for background status emission, auto-resume success, resume→poll fallback, non-background negative in [src/api/providers/__tests__/openai-native.spec.ts](src/api/providers/__tests__/openai-native.spec.ts).

  • Usage parity unchanged validated in [src/api/providers/__tests__/openai-native-usage.spec.ts](src/api/providers/__tests__/openai-native-usage.spec.ts).

  • UI: label mapping tests for background statuses in [webview-ui/src/utils/__tests__/backgroundStatus.spec.ts](webview-ui/src/utils/__tests__/backgroundStatus.spec.ts).

Notes:

- Aligns with TEMP_OPENAI_BACKGROUND_TASK_DOCS.DM: background requires store=true; supports streaming resume via response.id + sequence_number.

- Default behavior unchanged for non-background models; no breaking changes.
2025-12-09 18:38:13 -07:00
..
npm chore: bump version to v1.89.0 (#9718) 2025-12-01 14:25:48 -08:00
scripts Fix publish-npm script (#7093) 2025-08-14 03:17:56 -07:00
src feat(openai-native): background mode + auto-resume and poll fallback 2025-12-09 18:38:13 -07:00
.gitignore Task metadata (#7092) 2025-08-14 03:14:17 -07:00
eslint.config.mjs Task metadata (#7092) 2025-08-14 03:14:17 -07:00
package.json Task metadata (#7092) 2025-08-14 03:14:17 -07:00
tsconfig.json Task metadata (#7092) 2025-08-14 03:14:17 -07:00
tsup.config.ts Bump @roo-code/types to v1.42.0 (#6610) 2025-08-02 13:27:59 -07:00
vitest.config.ts Convert jest tests to vitest and disable default watch mode for vitest (#4568) 2025-06-11 14:48:01 -07:00