IM 渠道(企微等)的消息处理走 KnowledgeQA 管道,该管道的 LLM 调用此前 未设置任何超时,依赖 context cancellation 控制。然而 QA 管道传入的 context 本身无 deadline,一旦上游 LLM API(如 mimo-v2.5-pro)的网络请求 hang 在 TCP 层面(连接未断但无数据返回),worker goroutine 会永久阻塞在 CreateChatCompletion / CreateChatCompletionStream 上。 随着时间推移,多个 worker 陆续卡死,队列中所有 worker 耗尽后机器人对任何 消息都不再回复。 本提交在 RemoteAPIChat.Chat 和 RemoteAPIChat.ChatStream 两个入口方法中 统一添加 context.WithTimeout: - 非流式调用(Chat):120s 超时 - 流式调用(ChatStream):300s 超时 如果上层调用方已设置更短的 deadline,WithTimeout 自动遵循更短的那个, 不会覆盖已有的合理超时设置。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| chat.go | ||
| chat_provider_spec.go | ||
| config_from_model_test.go | ||
| image_resolve.go | ||
| json_field_extractor.go | ||
| json_field_extractor_test.go | ||
| langfuse_wrapper.go | ||
| llm_debug.go | ||
| llm_debug_wrapper.go | ||
| ollama.go | ||
| remote_api.go | ||
| remote_api_test.go | ||
| sse_reader.go | ||