fix(agents): dismiss subagent topic feedback
This commit is contained in:
parent
ce13b13617
commit
aea466b2b9
3 changed files with 44 additions and 8 deletions
|
|
@ -453,7 +453,7 @@ func spawnSubTurn(
|
||||||
dismissCtx,
|
dismissCtx,
|
||||||
childTS.channel,
|
childTS.channel,
|
||||||
childTS.chatID,
|
childTS.chatID,
|
||||||
childTS.opts.InboundContext,
|
childTS.opts.Dispatch.InboundContext,
|
||||||
childID,
|
childID,
|
||||||
)
|
)
|
||||||
dismissCancel()
|
dismissCancel()
|
||||||
|
|
|
||||||
|
|
@ -218,17 +218,23 @@ func dismissTrackedToolFeedbackMessageForSession(
|
||||||
dismissTrackedToolFeedbackMessage(ctx, ch, chatID, outboundCtx)
|
dismissTrackedToolFeedbackMessage(ctx, ch, chatID, outboundCtx)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
trackedChatID := resolveOutboundChatID(ch, chatID, outboundCtx)
|
resolvedChatID := resolveOutboundChatID(ch, chatID, outboundCtx)
|
||||||
if trackedChatID == "" {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
trackedChatID += "#session:" + sessionKey
|
|
||||||
if cleaner, ok := ch.(toolFeedbackMessageCleaner); ok {
|
if cleaner, ok := ch.(toolFeedbackMessageCleaner); ok {
|
||||||
cleaner.DismissToolFeedbackMessage(ctx, trackedChatID)
|
for _, candidate := range candidateChatIDs(chatID, resolvedChatID) {
|
||||||
|
if candidate == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
cleaner.DismissToolFeedbackMessage(ctx, candidate+"#session:"+sessionKey)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if tracker, ok := ch.(toolFeedbackMessageTracker); ok {
|
if tracker, ok := ch.(toolFeedbackMessageTracker); ok {
|
||||||
tracker.ClearToolFeedbackMessage(trackedChatID)
|
for _, candidate := range candidateChatIDs(chatID, resolvedChatID) {
|
||||||
|
if candidate == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
tracker.ClearToolFeedbackMessage(candidate + "#session:" + sessionKey)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -898,6 +898,7 @@ type mockMessageEditor struct {
|
||||||
recordedContent string
|
recordedContent string
|
||||||
clearedChatID string
|
clearedChatID string
|
||||||
dismissedChatID string
|
dismissedChatID string
|
||||||
|
dismissedChatIDs []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockMessageEditor) EditMessage(ctx context.Context, chatID, messageID, content string) error {
|
func (m *mockMessageEditor) EditMessage(ctx context.Context, chatID, messageID, content string) error {
|
||||||
|
|
@ -916,6 +917,7 @@ func (m *mockMessageEditor) ClearToolFeedbackMessage(chatID string) {
|
||||||
|
|
||||||
func (m *mockMessageEditor) DismissToolFeedbackMessage(_ context.Context, chatID string) {
|
func (m *mockMessageEditor) DismissToolFeedbackMessage(_ context.Context, chatID string) {
|
||||||
m.dismissedChatID = chatID
|
m.dismissedChatID = chatID
|
||||||
|
m.dismissedChatIDs = append(m.dismissedChatIDs, chatID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockMessageEditor) FinalizeToolFeedbackMessage(
|
func (m *mockMessageEditor) FinalizeToolFeedbackMessage(
|
||||||
|
|
@ -958,6 +960,34 @@ func (m *mockResolvedToolFeedbackEditor) ToolFeedbackMessageChatID(
|
||||||
return chatID
|
return chatID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDismissToolFeedbackForSession_UsesResolvedTopicScopedKey(t *testing.T) {
|
||||||
|
m := newTestManager()
|
||||||
|
ch := &mockResolvedToolFeedbackEditor{
|
||||||
|
resolveChatIDFn: func(chatID string, outboundCtx *bus.InboundContext) string {
|
||||||
|
if chatID != "-100123" {
|
||||||
|
t.Fatalf("chatID = %q, want -100123", chatID)
|
||||||
|
}
|
||||||
|
if outboundCtx == nil || outboundCtx.TopicID != "6" {
|
||||||
|
t.Fatalf("unexpected outbound context: %+v", outboundCtx)
|
||||||
|
}
|
||||||
|
return "-100123/6"
|
||||||
|
},
|
||||||
|
}
|
||||||
|
m.channels["telegram"] = ch
|
||||||
|
|
||||||
|
m.DismissToolFeedbackForSession(
|
||||||
|
context.Background(),
|
||||||
|
"telegram",
|
||||||
|
"-100123",
|
||||||
|
&bus.InboundContext{Channel: "telegram", ChatID: "-100123", TopicID: "6"},
|
||||||
|
"subturn-1",
|
||||||
|
)
|
||||||
|
|
||||||
|
if len(ch.dismissedChatIDs) == 0 || ch.dismissedChatIDs[0] != "-100123/6#session:subturn-1" {
|
||||||
|
t.Fatalf("dismissed chatIDs = %v, want topic-scoped session key first", ch.dismissedChatIDs)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type mockPreparedToolFeedbackEditor struct {
|
type mockPreparedToolFeedbackEditor struct {
|
||||||
mockMessageEditor
|
mockMessageEditor
|
||||||
prepareFn func(content string) string
|
prepareFn func(content string) string
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue