fix(agents): preserve feedback target metadata
This commit is contained in:
parent
2efdcb7bec
commit
62654a8cd8
4 changed files with 36 additions and 5 deletions
|
|
@ -258,7 +258,14 @@ func (al *AgentLoop) Run(ctx context.Context) error {
|
|||
return
|
||||
}
|
||||
if continued != "" {
|
||||
al.PublishResponseIfNeeded(ctx, target.Channel, target.ChatID, target.SessionKey, continued)
|
||||
al.publishResponseWithContextIfNeeded(
|
||||
ctx,
|
||||
target.Channel,
|
||||
target.ChatID,
|
||||
target.SessionKey,
|
||||
continued,
|
||||
&m.Context,
|
||||
)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,14 @@ func (al *AgentLoop) publishResponseOrError(
|
|||
}
|
||||
|
||||
func (al *AgentLoop) PublishResponseIfNeeded(ctx context.Context, channel, chatID, sessionKey, response string) {
|
||||
al.publishResponseWithContextIfNeeded(ctx, channel, chatID, sessionKey, response, nil)
|
||||
}
|
||||
|
||||
func (al *AgentLoop) publishResponseWithContextIfNeeded(
|
||||
ctx context.Context,
|
||||
channel, chatID, sessionKey, response string,
|
||||
inboundCtx *bus.InboundContext,
|
||||
) {
|
||||
if response == "" {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,14 @@ func (al *AgentLoop) runTurnWithSteering(ctx context.Context, initialMsg bus.Inb
|
|||
|
||||
// Publish final response
|
||||
if finalResponse != "" {
|
||||
al.PublishResponseIfNeeded(ctx, target.Channel, target.ChatID, target.SessionKey, finalResponse)
|
||||
al.publishResponseWithContextIfNeeded(
|
||||
ctx,
|
||||
target.Channel,
|
||||
target.ChatID,
|
||||
target.SessionKey,
|
||||
finalResponse,
|
||||
&initialMsg.Context,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -187,6 +187,15 @@ func trackedToolFeedbackMessageChatID(ch Channel, chatID string, outboundCtx *bu
|
|||
return strings.TrimSpace(chatID)
|
||||
}
|
||||
|
||||
func candidateToolFeedbackMessageChatIDs(raw, resolved string) []string {
|
||||
raw = strings.TrimSpace(raw)
|
||||
resolved = strings.TrimSpace(resolved)
|
||||
if raw == "" || raw == resolved {
|
||||
return []string{resolved}
|
||||
}
|
||||
return []string{resolved, raw}
|
||||
}
|
||||
|
||||
func dismissTrackedToolFeedbackMessage(
|
||||
ctx context.Context,
|
||||
ch Channel,
|
||||
|
|
@ -218,9 +227,9 @@ func dismissTrackedToolFeedbackMessageForSession(
|
|||
dismissTrackedToolFeedbackMessage(ctx, ch, chatID, outboundCtx)
|
||||
return
|
||||
}
|
||||
resolvedChatID := resolveOutboundChatID(ch, chatID, outboundCtx)
|
||||
resolvedChatID := trackedToolFeedbackMessageChatID(ch, chatID, outboundCtx)
|
||||
if cleaner, ok := ch.(toolFeedbackMessageCleaner); ok {
|
||||
for _, candidate := range candidateChatIDs(chatID, resolvedChatID) {
|
||||
for _, candidate := range candidateToolFeedbackMessageChatIDs(chatID, resolvedChatID) {
|
||||
if candidate == "" {
|
||||
continue
|
||||
}
|
||||
|
|
@ -229,7 +238,7 @@ func dismissTrackedToolFeedbackMessageForSession(
|
|||
return
|
||||
}
|
||||
if tracker, ok := ch.(toolFeedbackMessageTracker); ok {
|
||||
for _, candidate := range candidateChatIDs(chatID, resolvedChatID) {
|
||||
for _, candidate := range candidateToolFeedbackMessageChatIDs(chatID, resolvedChatID) {
|
||||
if candidate == "" {
|
||||
continue
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue