From ec84c4dd70fb88b83ca98d8ee46727720feb53ca Mon Sep 17 00:00:00 2001 From: Dmitrii Balabanov Date: Mon, 23 Mar 2026 11:20:37 +0200 Subject: [PATCH] fix(lint): remove unused funcs, fix formatting after Send refactor - Remove unused messageThreadAnnotation (superseded by messageHistoryAnnotation) - Remove unused publishResponseIfNeeded (superseded by publishAgentResponseIfNeeded) - Reformat fakeChannel method alignment broken by Send signature change - Wrap long line in steering_test.go --- pkg/agent/context.go | 10 ---------- pkg/agent/loop.go | 37 ------------------------------------- pkg/agent/loop_test.go | 14 +++++++------- pkg/agent/steering_test.go | 7 ++++--- 4 files changed, 11 insertions(+), 57 deletions(-) diff --git a/pkg/agent/context.go b/pkg/agent/context.go index e0f460f19..1ccf32611 100644 --- a/pkg/agent/context.go +++ b/pkg/agent/context.go @@ -910,16 +910,6 @@ func messageSenderAnnotation(sender *providers.MessageSender) string { } } -// messageThreadAnnotation returns the thread annotation prefix for a message, -// e.g. "[msg:#5, reply_to:#3] " or "" if the message has no threading IDs. -func messageThreadAnnotation(msg providers.Message) string { - body := messageThreadAnnotationBody(msg) - if body == "" { - return "" - } - return fmt.Sprintf("[%s] ", body) -} - func messageThreadAnnotationBody(msg providers.Message) string { msgIDs := msg.MessageIDs formattedIDs := strings.Join(msgIDs, ",#") diff --git a/pkg/agent/loop.go b/pkg/agent/loop.go index 704377ede..14c6a16f6 100644 --- a/pkg/agent/loop.go +++ b/pkg/agent/loop.go @@ -657,43 +657,6 @@ func (al *AgentLoop) Stop() { al.running.Store(false) } -func (al *AgentLoop) publishResponseIfNeeded(ctx context.Context, channel, chatID, response string) { - if response == "" { - return - } - - alreadySent := false - defaultAgent := al.GetRegistry().GetDefaultAgent() - if defaultAgent != nil { - if tool, ok := defaultAgent.Tools.Get("message"); ok { - if mt, ok := tool.(*tools.MessageTool); ok { - alreadySent = mt.HasSentInRound() - } - } - } - - if alreadySent { - logger.DebugCF( - "agent", - "Skipped outbound (message tool already sent)", - map[string]any{"channel": channel}, - ) - return - } - - al.bus.PublishOutbound(ctx, bus.OutboundMessage{ - Channel: channel, - ChatID: chatID, - Content: response, - }) - logger.InfoCF("agent", "Published outbound response", - map[string]any{ - "channel": channel, - "chat_id": chatID, - "content_len": len(response), - }) -} - func (al *AgentLoop) publishAgentResponseIfNeeded( ctx context.Context, response agentResponse, diff --git a/pkg/agent/loop_test.go b/pkg/agent/loop_test.go index 5dfc1cd96..f477e9c38 100644 --- a/pkg/agent/loop_test.go +++ b/pkg/agent/loop_test.go @@ -25,16 +25,16 @@ import ( type fakeChannel struct{ id string } -func (f *fakeChannel) Name() string { return "fake" } -func (f *fakeChannel) Start(ctx context.Context) error { return nil } -func (f *fakeChannel) Stop(ctx context.Context) error { return nil } +func (f *fakeChannel) Name() string { return "fake" } +func (f *fakeChannel) Start(ctx context.Context) error { return nil } +func (f *fakeChannel) Stop(ctx context.Context) error { return nil } func (f *fakeChannel) Send(ctx context.Context, msg bus.OutboundMessage) ([]string, error) { return nil, nil } -func (f *fakeChannel) IsRunning() bool { return true } -func (f *fakeChannel) IsAllowed(string) bool { return true } -func (f *fakeChannel) IsAllowedSender(sender bus.SenderInfo) bool { return true } -func (f *fakeChannel) ReasoningChannelID() string { return f.id } +func (f *fakeChannel) IsRunning() bool { return true } +func (f *fakeChannel) IsAllowed(string) bool { return true } +func (f *fakeChannel) IsAllowedSender(sender bus.SenderInfo) bool { return true } +func (f *fakeChannel) ReasoningChannelID() string { return f.id } type fakeMediaChannel struct { fakeChannel diff --git a/pkg/agent/steering_test.go b/pkg/agent/steering_test.go index 1cca44ca7..227a52e76 100644 --- a/pkg/agent/steering_test.go +++ b/pkg/agent/steering_test.go @@ -522,9 +522,10 @@ func TestContinueWithSteeringMessages_ReturnsTrackedAssistantDelivery(t *testing } sessionKey := "agent:test-continue-delivery" - response, err := al.continueWithSteeringMessages(context.Background(), defaultAgent, sessionKey, "test", "chat1", []providers.Message{ - {Role: "user", Content: "new direction"}, - }) + response, err := al.continueWithSteeringMessages( + context.Background(), defaultAgent, sessionKey, "test", "chat1", + []providers.Message{{Role: "user", Content: "new direction"}}, + ) if err != nil { t.Fatalf("continueWithSteeringMessages failed: %v", err) }