From 92da6a323d57e2b6ac328f80ee7c95dfc87f458b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=A8=E8=8B=92?= <16112591+chen-ran@users.noreply.github.com> Date: Sat, 7 Nov 2026 16:23:26 +0800 Subject: [PATCH] =?UTF-8?q?fix(agent):=20=E9=87=8D=E5=90=AF=E5=90=8E?= =?UTF-8?q?=E8=A2=AB=E6=8E=A5=E7=AE=A1=E7=9A=84=E5=BE=85=E5=86=B3=E7=AD=96?= =?UTF-8?q?=20run=20=E6=81=A2=E5=A4=8D=E5=86=B3=E7=AD=96=E5=8D=A1=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #1724 把 DBService.GetVisibleHistoryTurnRequestMessageIDByTurn 当作无调用方 删除,但 ParkedRunMessages 通过类型断言调用它。断言静默失败后,重启后被接管 的 waiting_decision run 在运行快照里没有消息:重新打开会话只显示“Working on your request”,看不到决策卡片,用户无法作答。 恢复该方法,并在编译期把消息服务固定到 parkedRunRequestResolver,避免它再被 当作死代码删除。 Co-Authored-By: Claude Opus 5.5 --- .../agent/application/runtime_decision.go | 15 ++++++++++--- internal/chat/message/service.go | 22 +++++++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/internal/agent/application/runtime_decision.go b/internal/agent/application/runtime_decision.go index 056a8d881f..1495518091 100644 --- a/internal/agent/application/runtime_decision.go +++ b/internal/agent/application/runtime_decision.go @@ -21,6 +21,7 @@ import ( sessionruntime "github.com/felinics/memoh/internal/agent/runtime/session" "github.com/felinics/memoh/internal/agent/runtime/session/ledger" chatview "github.com/felinics/memoh/internal/agent/view" + messagepkg "github.com/felinics/memoh/internal/chat/message" "github.com/felinics/memoh/internal/db" dbsqlc "github.com/felinics/memoh/internal/db/postgres/sqlc" ) @@ -625,6 +626,16 @@ func runtimeDecisionTerminal(ctx context.Context, cause error) RunOutcome { return RunOutcome{} } +// parkedRunRequestResolver finds the request message a parked run's view +// starts from. It is reached through a type assertion, so the production +// message service is pinned to it at compile time: without it a recovered +// waiting-decision run would show no decision card. +type parkedRunRequestResolver interface { + GetVisibleHistoryTurnRequestMessageIDByTurn(context.Context, string, string) (string, error) +} + +var _ parkedRunRequestResolver = (*messagepkg.DBService)(nil) + // ParkedRunMessages rebuilds the assistant messages a parked run persisted, from // its request turn on, with each decision card as the history page shows it. A // recovered run is shown from them when the live backend kept no view of it. @@ -634,9 +645,7 @@ func (s *Service) ParkedRunMessages(ctx context.Context, run ledger.Run) ([]chat if s == nil || s.messageService == nil || s.sessionService == nil { return nil, nil } - resolver, ok := s.messageService.(interface { - GetVisibleHistoryTurnRequestMessageIDByTurn(context.Context, string, string) (string, error) - }) + resolver, ok := s.messageService.(parkedRunRequestResolver) if !ok { return nil, nil } diff --git a/internal/chat/message/service.go b/internal/chat/message/service.go index e37b19390a..b676b817ec 100644 --- a/internal/chat/message/service.go +++ b/internal/chat/message/service.go @@ -1305,6 +1305,28 @@ func (s *DBService) ListVisibleFromBySession(ctx context.Context, sessionID stri return msgs, nil } +// GetVisibleHistoryTurnRequestMessageIDByTurn returns the request message of +// a session turn. Waiting-decision recovery rebuilds a parked run's view from +// it (application.Service.ParkedRunMessages). +func (s *DBService) GetVisibleHistoryTurnRequestMessageIDByTurn(ctx context.Context, sessionID string, turnID string) (string, error) { + pgSessionID, err := dbpkg.ParseUUID(sessionID) + if err != nil { + return "", err + } + pgTurnID, err := dbpkg.ParseUUID(turnID) + if err != nil { + return "", err + } + turn, err := s.queries.GetHistoryTurnByID(ctx, sqlc.GetHistoryTurnByIDParams{ + SessionID: pgSessionID, + OldTurnID: pgTurnID, + }) + if err != nil { + return "", err + } + return uuidString(turn.RequestMessageID), nil +} + func (s *DBService) GetVisibleTurnByMessage(ctx context.Context, sessionID string, messageID string) (HistoryTurn, error) { pgSessionID, err := dbpkg.ParseUUID(sessionID) if err != nil {