From 4b08d1b38acbe2b33fd2ca6ab25de87043c9a05a Mon Sep 17 00:00:00 2001 From: 1bcMax Date: Thu, 25 Jun 2026 20:41:43 -0700 Subject: [PATCH] =?UTF-8?q?fix(timeout):=20AnthropicClient=20default=20120?= =?UTF-8?q?=E2=86=92600=20+=20black-format=20solana=5Fclient?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow-up to #14, which raised the OpenAI-compat chat default to an env-configurable 600s but left AnthropicClient — the native opus-4.8 /v1/messages path, exactly the reasoning case that needs 200–300s — hardcoded at 120s. Mirror the same BLOCKRUN_CHAT_TIMEOUT env default, fix stale 'default: 120' docstrings in client.py + anthropic_client.py, and black-format solana_client.py (the lint that failed #14's CI). --- blockrun_llm/anthropic_client.py | 10 ++++++++-- blockrun_llm/client.py | 4 ++-- blockrun_llm/solana_client.py | 4 +++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/blockrun_llm/anthropic_client.py b/blockrun_llm/anthropic_client.py index dbbf523..b0b418b 100644 --- a/blockrun_llm/anthropic_client.py +++ b/blockrun_llm/anthropic_client.py @@ -29,6 +29,11 @@ load_dotenv() +# Default chat HTTP timeout (seconds). Was 120; reasoning models (opus-4.8) think +# 200–300s+, which the old default cut off mid-generation. Override via the +# BLOCKRUN_CHAT_TIMEOUT env var. Mirrors client.py / solana_client.py. +DEFAULT_CHAT_TIMEOUT = float(os.environ.get("BLOCKRUN_CHAT_TIMEOUT", "600")) + class _BlockRunX402Transport(httpx.BaseTransport): """Custom httpx transport that intercepts 402 responses and signs x402 payments.""" @@ -123,7 +128,7 @@ def __init__( self, private_key: Optional[str] = None, api_url: Optional[str] = None, - timeout: float = 120.0, + timeout: float = DEFAULT_CHAT_TIMEOUT, **kwargs, ): """ @@ -133,7 +138,8 @@ def __init__( private_key: Base chain wallet private key (or set BLOCKRUN_WALLET_KEY env var). Key is used for LOCAL signing only — never transmitted. api_url: BlockRun API endpoint (default: https://blockrun.ai/api). - timeout: Request timeout in seconds (default: 120). + timeout: Request timeout in seconds (default: 600, override via + BLOCKRUN_CHAT_TIMEOUT env). Reasoning models need 200–300s+. **kwargs: Additional keyword arguments passed to anthropic.Anthropic. Raises: diff --git a/blockrun_llm/client.py b/blockrun_llm/client.py index d158c2d..621b723 100644 --- a/blockrun_llm/client.py +++ b/blockrun_llm/client.py @@ -239,7 +239,7 @@ def __init__( private_key: Base chain wallet private key (or set BLOCKRUN_WALLET_KEY env var) NOTE: Key is used for LOCAL signing only - never transmitted api_url: API endpoint URL (default: https://blockrun.ai/api) - timeout: Request timeout in seconds (default: 120). Used for regular chat requests. + timeout: Request timeout in seconds (default: 600, override via BLOCKRUN_CHAT_TIMEOUT env). Used for regular chat requests. search_timeout: Timeout for xAI Live Search requests (default: 300 = 5 minutes). Live Search can be slow as it searches X, web, and news sources. Auto-detected when search_parameters or search=True is passed. @@ -2202,7 +2202,7 @@ def __init__( Args: private_key: Base chain wallet private key (or set BLOCKRUN_WALLET_KEY env var) api_url: API endpoint URL (default: https://blockrun.ai/api) - timeout: Request timeout in seconds (default: 120). Used for regular chat requests. + timeout: Request timeout in seconds (default: 600, override via BLOCKRUN_CHAT_TIMEOUT env). Used for regular chat requests. search_timeout: Timeout for xAI Live Search requests (default: 300 = 5 minutes). Auto-detected when search_parameters or search=True is passed. transaction_log: Same opt-in per-call log as ``LLMClient``. ``True`` → diff --git a/blockrun_llm/solana_client.py b/blockrun_llm/solana_client.py index 66fdd47..0992de1 100644 --- a/blockrun_llm/solana_client.py +++ b/blockrun_llm/solana_client.py @@ -86,7 +86,9 @@ def _create_signer(private_key: str) -> KeypairSigner: # # Public callers can also override per-call via ``timeout=`` on # ``chat_completion`` / ``image`` / ``image_edit`` / ``search``. -DEFAULT_CHAT_TIMEOUT = float(os.environ.get("BLOCKRUN_CHAT_TIMEOUT", "600")) # was 120; reasoning models need 200–300s+ +DEFAULT_CHAT_TIMEOUT = float( + os.environ.get("BLOCKRUN_CHAT_TIMEOUT", "600") +) # was 120; reasoning models need 200–300s+ DEFAULT_IMAGE_TIMEOUT = 200.0 DEFAULT_SEARCH_TIMEOUT = 300.0 DEFAULT_FAST_TIMEOUT = 30.0 # pyth / x_user_info / quick lookups