mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-14 04:16:06 +00:00
fix(teams): propagate local_key in team task completion/fail broadcasts (#877)
Forum topic routing (Telegram supergroup threads) relies on local_key carried through team task events to pick the correct thread for notifications. Four broadcast sites dropped local_key by relying on WithContextInfo(ctx) alone — but the member agent's isolated context does not carry the originating local_key. Read task.Metadata[TaskMetaLocalKey] explicitly and pass via WithLocalKey() to match the already-correct pattern in team_tool_dispatch.go and team_tasks_blocker.go. Covered sites: - team_tasks_lifecycle.executeComplete → EventTeamTaskCompleted - gateway_consumer_post_turn agent-error → EventTeamTaskFailed - gateway_consumer_post_turn loop-kill → EventTeamTaskFailed - gateway_consumer_post_turn auto-complete → EventTeamTaskCompleted
This commit is contained in:
1 parent
564997cfae
commit
497849f746
2 files changed
+18
-3
No files matched your search
@@ -98,6 +98,7 @@ func resolveTeamTaskOutcome(
|
||||
taskChannel := meta.Channel
|
||||
taskChatID := meta.ChatID
|
||||
taskPeerKind := meta.PeerKind
|
||||
var taskLocalKey string
|
||||
|
||||
// Enrich with live task data if available.
|
||||
if currentTask != nil {
|
||||
@@ -113,9 +114,15 @@ 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
|
||||
if currentTask.Metadata != nil {
|
||||
if taskPeerKind == "" {
|
||||
if pk, ok := currentTask.Metadata[tools.TaskMetaPeerKind].(string); ok && pk != "" {
|
||||
taskPeerKind = pk
|
||||
}
|
||||
}
|
||||
// local_key is required for forum topic routing (e.g. Telegram supergroup threads).
|
||||
if lk, ok := currentTask.Metadata[tools.TaskMetaLocalKey].(string); ok {
|
||||
taskLocalKey = lk
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -137,6 +144,7 @@ func resolveTeamTaskOutcome(
|
||||
tools.WithChannel(taskChannel),
|
||||
tools.WithChatID(taskChatID),
|
||||
tools.WithPeerKind(taskPeerKind),
|
||||
tools.WithLocalKey(taskLocalKey),
|
||||
tools.WithTimestamp(now),
|
||||
))
|
||||
}
|
||||
@@ -171,6 +179,7 @@ func resolveTeamTaskOutcome(
|
||||
tools.WithChannel(taskChannel),
|
||||
tools.WithChatID(taskChatID),
|
||||
tools.WithPeerKind(taskPeerKind),
|
||||
tools.WithLocalKey(taskLocalKey),
|
||||
tools.WithTimestamp(now),
|
||||
))
|
||||
}
|
||||
@@ -205,6 +214,7 @@ func resolveTeamTaskOutcome(
|
||||
tools.WithChannel(taskChannel),
|
||||
tools.WithChatID(taskChatID),
|
||||
tools.WithPeerKind(taskPeerKind),
|
||||
tools.WithLocalKey(taskLocalKey),
|
||||
tools.WithTimestamp(now),
|
||||
))
|
||||
}
|
||||
|
||||
@@ -88,9 +88,13 @@ func (t *TeamTasksTool) executeComplete(ctx context.Context, args map[string]any
|
||||
completedTask, _ := t.manager.Store().GetTask(ctx, taskID)
|
||||
var taskNumber int
|
||||
var taskSubject string
|
||||
var taskLocalKey string
|
||||
if completedTask != nil {
|
||||
taskNumber = completedTask.TaskNumber
|
||||
taskSubject = completedTask.Subject
|
||||
if lk, ok := completedTask.Metadata[TaskMetaLocalKey].(string); ok {
|
||||
taskLocalKey = lk
|
||||
}
|
||||
}
|
||||
t.manager.BroadcastTeamEvent(ctx, protocol.EventTeamTaskCompleted, BuildTaskEventPayload(
|
||||
team.ID.String(), taskID.String(),
|
||||
@@ -99,6 +103,7 @@ func (t *TeamTasksTool) executeComplete(ctx context.Context, args map[string]any
|
||||
WithTaskInfo(taskNumber, taskSubject),
|
||||
WithOwner(ownerKey, t.manager.AgentDisplayName(ctx, ownerKey)),
|
||||
WithContextInfo(ctx),
|
||||
WithLocalKey(taskLocalKey),
|
||||
))
|
||||
|
||||
// Dependent tasks are dispatched by the consumer after this agent's turn ends
|
||||
|
||||
Reference in new issue
Block a user