feat(config): align LLM timeout/retry SLA with FastGPT client (60s/3)
Replaces the unequal SLA (LLM 30s/2 retries vs FastGPT client 60s/3) that made the LangGraph backend look less stable under gray release. - core/fastgpt_client: FASTGPT_TIMEOUT_SECONDS / FASTGPT_MAX_RETRIES module constants (were inline literals in lifespan) - agent/llm: OpenAILLMService defaults 60.0s / 3 retries - core/config: named-profile fallback defaults 60/3 (prefixed and JSON-dict forms) - contract test test/backends/test_sla_alignment.py pins both sides to the same constants so the SLA cannot drift apart again - retry backoff intentionally differs (FastGPT fixed 1s vs LLM exponential) and is documented; aligned parameters are per-call timeout and max retry count Verified: 215 unit tests (3 new SLA contract tests)
This commit is contained in:
@@ -16,6 +16,14 @@ _chat_backend: ChatBackend | None = None
|
||||
_langgraph_graph = None
|
||||
_app_service: AccidentAppService | None = None
|
||||
|
||||
# 后端超时/重试 SLA(两后端对齐;契约测试防止再漂移)。
|
||||
# FastGPT 侧:客户端每次请求总超时 + 重试次数;
|
||||
# LangGraph 侧:LLM 每次调用总超时 + 重试次数(退避为指数式,
|
||||
# 与 FastGPT 固定 1s 不同——总尝试次数与单次超时可比,见
|
||||
# test/backends/test_sla_alignment.py)。
|
||||
FASTGPT_TIMEOUT_SECONDS = 60.0
|
||||
FASTGPT_MAX_RETRIES = 3
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
@@ -39,8 +47,8 @@ async def lifespan(app: FastAPI):
|
||||
_fastgpt_client = AsyncChatClient(
|
||||
api_key=Config.FASTGPT_API_KEY,
|
||||
base_url=Config.FASTGPT_BASE_URL,
|
||||
timeout=60.0,
|
||||
max_retries=3,
|
||||
timeout=FASTGPT_TIMEOUT_SECONDS,
|
||||
max_retries=FASTGPT_MAX_RETRIES,
|
||||
retry_delay=1.0,
|
||||
enable_logging=Config.DEBUG,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user