fix: harden responses streaming and tool-call fallback
Ensure /v1/responses streams always terminate with response.completed and normalize Lingma tool_code fallbacks into structured tool calls, including single-argument forms. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,11 @@ import os
|
||||
from dataclasses import dataclass, field
|
||||
|
||||
|
||||
|
||||
def _csv_env(raw: str) -> list[str]:
|
||||
return [item.strip() for item in (raw or "").replace("\n", ",").split(",") if item.strip()]
|
||||
|
||||
|
||||
@dataclass
|
||||
class LingmaAccount:
|
||||
username: str
|
||||
@@ -45,6 +50,7 @@ class Settings:
|
||||
session_cache_max_entries: int = 256
|
||||
session_cache_ttl_sec: float = 1800.0
|
||||
tool_forward_enabled: bool = False
|
||||
tool_allowlist: list[str] = field(default_factory=list)
|
||||
|
||||
|
||||
def _bool_env(name: str, default: bool) -> bool:
|
||||
@@ -177,4 +183,5 @@ def load_settings() -> Settings:
|
||||
session_cache_max_entries=int(os.getenv("SESSION_CACHE_MAX_ENTRIES", "256")),
|
||||
session_cache_ttl_sec=float(os.getenv("SESSION_CACHE_TTL_SEC", "1800")),
|
||||
tool_forward_enabled=_bool_env("TOOL_FORWARD_ENABLED", False),
|
||||
tool_allowlist=_csv_env(os.getenv("TOOL_ALLOWLIST", "")),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user