fix(agent): group session unresponsive during team task execution (#266)

Two fixes:

1. Remove assistant prefill from team task reminders. The injected
   [user]+[assistant]+[user] pattern caused LLMs to treat the canned
   ack as "turn complete", returning NO_REPLY for every user message
   in group sessions with active tasks. Reminders are now merged into
   the user message as prefix tags.

2. Add PeerKind propagation to team notification routing. TaskTicker
   and progress notifications were missing PeerKind on InboundMessage,
   causing them to route to phantom DM sessions instead of the correct
   group session. PeerKind is now carried through event payloads,
   notify queue metadata, and all inbound message publications.
This commit is contained in:
viettranx committed 2026-03-30 15:20:01 +07:00
1 parent 24717b0f51
commit 014f74ec15
12 files changed
+66 -20

No files matched your search

+2
View File
@@ -677,6 +677,7 @@ func runGateway() {
ChatID: meta.ChatID,
AgentID: meta.LeadAgent,
UserID: meta.UserID,
PeerKind: meta.PeerKind,
Content: leaderContent,
Metadata: map[string]string{"run_kind": tools.RunKindNotification},
})
@@ -825,6 +826,7 @@ func runGateway() {
ChatID: payload.ChatID,
UserID: payload.UserID,
LeadAgent: leadAgentKey,
PeerKind: payload.PeerKind,
})
})
slog.Info("team progress notification subscriber registered")
+6 -5
View File
@@ -309,11 +309,12 @@ func handleTeammateMessage(
teamID, _ := uuid.Parse(inMeta[tools.MetaTeamID])
if teamTaskID != uuid.Nil {
meta := teammateTaskMeta{
TaskID: teamTaskID,
TeamID: teamID,
ToAgent: inMeta[tools.MetaToAgent],
Channel: inMeta[tools.MetaOriginChannel],
ChatID: inMeta[tools.MetaOriginChatID],
TaskID: teamTaskID,
TeamID: teamID,
ToAgent: inMeta[tools.MetaToAgent],
Channel: inMeta[tools.MetaOriginChannel],
ChatID: inMeta[tools.MetaOriginChatID],
PeerKind: inMeta[tools.MetaOriginPeerKind],
}
cachedTeam = resolveTeamTaskOutcome(ctx, deps, outcome, taskActionFlags, meta)
}
+10
View File
@@ -51,6 +51,7 @@ type teammateTaskMeta struct {
ToAgent string
Channel string
ChatID string
PeerKind string // "group" or "direct" — for correct notification routing (#266)
Subject string
TaskNumber int
}
@@ -96,6 +97,7 @@ func resolveTeamTaskOutcome(
taskNumber := meta.TaskNumber
taskChannel := meta.Channel
taskChatID := meta.ChatID
taskPeerKind := meta.PeerKind
// Enrich with live task data if available.
if currentTask != nil {
@@ -111,6 +113,11 @@ func resolveTeamTaskOutcome(
if currentTask.ChatID != "" {
taskChatID = currentTask.ChatID
}
if taskPeerKind == "" && currentTask.Metadata != nil {
if pk, ok := currentTask.Metadata[tools.TaskMetaPeerKind].(string); ok && pk != "" {
taskPeerKind = pk
}
}
}
// Smart post-turn decision based on action flags.
@@ -129,6 +136,7 @@ func resolveTeamTaskOutcome(
tools.WithReason(outcome.Err.Error()),
tools.WithChannel(taskChannel),
tools.WithChatID(taskChatID),
tools.WithPeerKind(taskPeerKind),
tools.WithTimestamp(now),
))
}
@@ -162,6 +170,7 @@ func resolveTeamTaskOutcome(
tools.WithReason("loop_detector_kill"),
tools.WithChannel(taskChannel),
tools.WithChatID(taskChatID),
tools.WithPeerKind(taskPeerKind),
tools.WithTimestamp(now),
))
}
@@ -195,6 +204,7 @@ func resolveTeamTaskOutcome(
tools.WithOwnerAgentKey(toAgent),
tools.WithChannel(taskChannel),
tools.WithChatID(taskChatID),
tools.WithPeerKind(taskPeerKind),
tools.WithTimestamp(now),
))
}