From cf09dd36d88a9ce1b8d1a9a8a670e3e9ca736651 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=AC=E6=98=8E?= <83812544+Ed1s0nZ@users.noreply.github.com> Date: Wed, 27 May 2026 19:01:30 +0800 Subject: [PATCH] Add files via upload --- internal/handler/robot.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/handler/robot.go b/internal/handler/robot.go index 9797e95a..aff4052d 100644 --- a/internal/handler/robot.go +++ b/internal/handler/robot.go @@ -234,7 +234,7 @@ func (h *RobotHandler) HandleMessage(platform, userID, text string) (reply strin _ = h.db.UpdateConversationTitle(convID, newTitle) } } - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) + ctx, cancel := context.WithTimeout(context.Background(), h.robotMessageTimeout()) sk := h.sessionKey(platform, userID) h.cancelMu.Lock() h.runningCancels[sk] = cancel @@ -252,6 +252,9 @@ func (h *RobotHandler) HandleMessage(platform, userID, text string) (reply strin if errors.Is(err, context.Canceled) { return "任务已取消。" } + if errors.Is(err, context.DeadlineExceeded) { + return "任务执行超时,请稍后重试或精简本次请求范围。" + } return "处理失败: " + err.Error() } if newConvID != convID { @@ -260,6 +263,11 @@ func (h *RobotHandler) HandleMessage(platform, userID, text string) (reply strin return resp } +func (h *RobotHandler) robotMessageTimeout() time.Duration { + // 机器人整次消息处理超时(与单次工具超时 agent.tool_timeout_minutes 解耦)。 + return 10 * time.Hour +} + func (h *RobotHandler) cmdHelp() string { return "**【CyberStrikeAI 机器人命令】**\n\n" + "- `帮助` `help` — 显示本帮助 | Show this help\n" +