fix(providers): validate stream idle timeout config

This commit is contained in:
yu-xin-c
2026-06-17 00:47:44 +08:00
committed by Xubin Ren
parent 7bec0f6e01
commit 846410f936
6 changed files with 190 additions and 10 deletions
+7 -3
View File
@@ -5,7 +5,6 @@ from __future__ import annotations
import asyncio
import hashlib
import json
import os
from collections.abc import Awaitable, Callable
from typing import Any
@@ -13,7 +12,12 @@ import httpx
from loguru import logger
from oauth_cli_kit import get_token as get_codex_token
from nanobot.providers.base import LLMProvider, LLMResponse, ToolCallRequest
from nanobot.providers.base import (
LLMProvider,
LLMResponse,
ToolCallRequest,
resolve_stream_idle_timeout_s,
)
from nanobot.providers.openai_responses import (
consume_sse_with_reasoning,
convert_messages,
@@ -199,7 +203,7 @@ async def _request_codex(
on_thinking_delta: Callable[[str], Awaitable[None]] | None = None,
on_tool_call_delta: Callable[[dict[str, Any]], Awaitable[None]] | None = None,
) -> tuple[str, list[ToolCallRequest], str, dict[str, int], str | None]:
idle_timeout_s = int(os.environ.get("NANOBOT_STREAM_IDLE_TIMEOUT_S", "90"))
idle_timeout_s = resolve_stream_idle_timeout_s()
async with httpx.AsyncClient(timeout=idle_timeout_s, verify=verify) as client:
async with client.stream("POST", url, headers=headers, json=body) as response:
if response.status_code != 200: