Skip to content

Add chat OpenAI timeouts, stream disconnect cancellation, and worker isolation - #1844

Merged
Paul Lizer (paullizer) merged 1 commit into
paullizer-react-v2-uifrom
paullizer-chat-openai-timeout-stream-handling
Oct 27, 2026
Merged

Paul Lizer (paullizer) merged 1 commit into
paullizer-react-v2-uifrom
paullizer-chat-openai-timeout-stream-handling

Conversation

@paullizer

Copy link
Copy Markdown
Contributor

Summary

  • Prevents stalled Azure OpenAI / model endpoint requests and multi-window document actions from hanging for 18-72+ minutes and exhausting web/background worker threads by introducing granular httpx.Timeout (connect=10s, read=120s default, write=30s, pool=10s) and max_retries=1 defaults across AzureOpenAI, OpenAI, AsyncOpenAI, and Anthropic model clients, plus 30s fail-open timeouts on auxiliary history calls.
  • Enforces a configurable overall wall-clock deadline (document_action_timeout_seconds, default 300s / 5 minutes) with remaining-deadline per-call bounds and 50ms cancellation polling across execute_document_action_chat_request() and _execute_document_action_workflow(), while preserving completed durable analysis window checkpoints on timeout.
  • Ensures /api/chat/stream closes sync OpenAI streams inside a finally: block on exit/cancellation and automatically cancels detached_running stream sessions after stream_disconnect_grace_seconds (default 60s) if no client reattaches, while isolating chat stream workers onto a dedicated chat_stream_executor pool (CHAT_STREAM_EXECUTOR_MAX_WORKERS = 32) and raising default GUNICORN_THREADS from 8 to 16.
  • Adds a new Request & Stream Timeouts card (request-stream-timeouts-section) under Scale > Redis & Caching in both V1 and V2 Admin Settings with range sliders (model_stream_read_timeout_seconds, document_action_timeout_seconds, stream_disconnect_grace_seconds, and model_call_max_retries) and worker-capacity guidance.

Linked issue

N/A

Release Notes & Latest Features

  • New Feature
  • Bug Fix
  • UI Enhancement
  • Breaking Change
  • Internal only

Is this visible to end users?

  • Yes
  • No

Is this admin-facing (Admin Settings, governance, deployment, config)?

  • Yes
  • No

Should this become a Latest Feature card?

  • Yes
  • No
  • Already added

Screenshot needed for the card?

  • Yes
  • No
  • Attached

Version bump

  • application/single_app/config.py VERSION third segment bumped, or not needed because this is docs-only
  • deployers/version.txt bumped, or not needed because deployers/ was not changed

Testing / validation

  • python .\functional_tests\test_chat_openai_timeout_and_stream_resilience.py - passed (4/4 tests)
  • python .\functional_tests\test_v2_admin_scale_parity.py - passed (17/17 tests)
  • python .\functional_tests\test_v2_admin_scale_normalization.py - passed (13/13 tests)
  • python .\functional_tests\test_admin_settings_fields_registry_integrity.py - passed (5/5 tests)
  • python .\functional_tests\test_chat_content_streaming.py - passed (9/9 tests)
  • python .\functional_tests\test_docs_app_surface_coverage.py - passed (7/7 checks)
  • python .\functional_tests\test_docs_site_quality.py - passed (6/6 checks)
  • python .\functional_tests\route_tests\test_route_blueprint_policy_inventory.py - passed (15/15 tests)
  • python .\functional_tests\route_tests\test_route_unauthenticated_policy_contract.py - passed (10/10 tests)
  • python .\functional_tests\route_tests\test_route_policy_test_coverage.py - passed (3/3 tests)
  • python .\scripts\check_cosmos_response_boundaries.py - passed (1081 owners, 421 doubles, 0 review gaps)
  • node --check .\application\single_app\static\js\admin\admin_settings.js - passed
  • git -c core.whitespace=blank-at-eol,blank-at-eof,space-before-tab,cr-at-eol diff --check - passed

Documentation

  • Release notes updated, or not needed
  • Feature documentation updated, or not needed
  • Fix documentation updated, or not needed

Security checklist

  • New Flask routes include @swagger_route(security=get_auth_security())
  • Settings sent to non-admin frontends use sanitize_settings_for_user()
  • Browser JavaScript is served from local SimpleChat static assets only; no CDN-hosted JS
  • No secrets, keys, connection strings, or local-only artifacts are included

…isolation

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Comment thread application/single_app/functions_search_service.py
Comment thread application/single_app/model_endpoint_clients.py
Comment thread functional_tests/test_chat_openai_timeout_and_stream_resilience.py
@paullizer
Paul Lizer (paullizer) merged commit 11daaaa into paullizer-react-v2-ui Oct 27, 2026
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants