From e2ce61337192e091450c11749c423bc7b6268357 Mon Sep 17 00:00:00 2001 From: Dmitrii Balabanov Date: Tue, 31 Mar 2026 22:23:28 +0300 Subject: [PATCH] refactor: rename continueResponse back to Continue, remove wrapper continueResponse was an unnecessary rename of the existing public Continue. Merge them back into one function returning agentResponse; the Run loop calls Continue directly. Remove the thin string-adapter wrapper. --- pkg/agent/loop.go | 6 +++--- pkg/agent/steering.go | 16 ++-------------- pkg/agent/steering_test.go | 14 +++++++------- 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/pkg/agent/loop.go b/pkg/agent/loop.go index ecabf0ee5..6c33535ff 100644 --- a/pkg/agent/loop.go +++ b/pkg/agent/loop.go @@ -102,7 +102,7 @@ type processOptions struct { SendResponse bool // Whether to send response via bus SuppressToolFeedback bool // Whether to suppress inline tool feedback messages NoHistory bool // If true, don't load session history (for heartbeat) - SkipInitialSteeringPoll bool // If true, skip the steering poll at loop start (used by continueResponse) + SkipInitialSteeringPoll bool // If true, skip the steering poll at loop start (used by Continue) Sender *providers.MessageSender // Author identity (nil for system/automated messages) } @@ -605,7 +605,7 @@ func (al *AgentLoop) Run(ctx context.Context) error { "queue_depth": al.pendingSteeringCountForScope(target.SessionKey), }) - continued, continueErr := al.continueResponse( + continued, continueErr := al.Continue( ctx, target.SessionKey, target.Channel, @@ -637,7 +637,7 @@ func (al *AgentLoop) Run(ctx context.Context) error { "queue_depth": al.pendingSteeringCountForScope(target.SessionKey), }) - continued, continueErr := al.continueResponse( + continued, continueErr := al.Continue( ctx, target.SessionKey, target.Channel, diff --git a/pkg/agent/steering.go b/pkg/agent/steering.go index c10ad7b3e..6e6b6dd13 100644 --- a/pkg/agent/steering.go +++ b/pkg/agent/steering.go @@ -319,10 +319,10 @@ func (al *AgentLoop) agentForSession(sessionKey string) *AgentInstance { return registry.GetDefaultAgent() } -// continueResponse dequeues pending steering messages and runs them through the agent loop. +// Continue dequeues pending steering messages and runs them through the agent loop. // Returns an agentResponse with OnDelivered set for delayed session persistence. // If no steering messages are pending, returns an empty agentResponse. -func (al *AgentLoop) continueResponse( +func (al *AgentLoop) Continue( ctx context.Context, sessionKey, channel, chatID string, ) (agentResponse, error) { @@ -355,18 +355,6 @@ func (al *AgentLoop) continueResponse( return al.continueWithSteeringMessages(ctx, agent, sessionKey, channel, chatID, steeringMsgs) } -// Continue is the public API for resuming an idle agent from external callers. -// It dequeues pending steering messages and runs them through the agent loop, -// returning the assistant reply content on success. -// If no steering messages are pending, it returns an empty string. -func (al *AgentLoop) Continue(ctx context.Context, sessionKey, channel, chatID string) (string, error) { - resp, err := al.continueResponse(ctx, sessionKey, channel, chatID) - if err != nil { - return "", err - } - return resp.Content, nil -} - func (al *AgentLoop) InterruptGraceful(hint string) error { ts := al.getAnyActiveTurnState() if ts == nil { diff --git a/pkg/agent/steering_test.go b/pkg/agent/steering_test.go index 31b03eb63..f98d4a177 100644 --- a/pkg/agent/steering_test.go +++ b/pkg/agent/steering_test.go @@ -298,7 +298,7 @@ func TestAgentLoop_Continue_NoMessages(t *testing.T) { t.Fatal("expected provider to be initialized") } - resp, err := al.continueResponse(context.Background(), "test-session", "test", "chat1") + resp, err := al.Continue(context.Background(), "test-session", "test", "chat1") if err != nil { t.Fatalf("unexpected error: %v", err) } @@ -331,7 +331,7 @@ func TestAgentLoop_Continue_WithMessages(t *testing.T) { al.Steer(providers.Message{Role: "user", Content: "new direction"}) - resp, err := al.continueResponse(context.Background(), "test-session", "test", "chat1") + resp, err := al.Continue(context.Background(), "test-session", "test", "chat1") if err != nil { t.Fatalf("unexpected error: %v", err) } @@ -1073,9 +1073,9 @@ func TestAgentLoop_Continue_PreservesSteeringMedia(t *testing.T) { t.Fatalf("Steer failed: %v", err) } - resp, err := al.continueResponse(context.Background(), sessionKey, "test", "chat1") + resp, err := al.Continue(context.Background(), sessionKey, "test", "chat1") if err != nil { - t.Fatalf("continueResponse failed: %v", err) + t.Fatalf("Continue failed: %v", err) } if resp.Content != "ack" { t.Fatalf("expected ack, got %q", resp.Content) @@ -1587,7 +1587,7 @@ func (w *wrappingProvider) GetDefaultModel() string { // a steering continuation sees the previous assistant reply in its LLM context // even when OnDelivered has not fired yet (reply not yet in session history). // The pending reply is injected via pendingDeliveries/injectPendingDelivery, -// not via EphemeralPrefix. +// not via a separate injection mechanism. // // 1. The steering continuation's LLM call sees the previous assistant reply. // 2. Session history does not contain the assistant reply (OnDelivered not called). @@ -1672,9 +1672,9 @@ func TestContinueResponse_PendingDeliveryVisibleBeforePersistence(t *testing.T) t.Fatalf("pushScope: %v", pushErr) } - continued, err := al.continueResponse(ctx, sessionKey, channel, chatID) + continued, err := al.Continue(ctx, sessionKey, channel, chatID) if err != nil { - t.Fatalf("continueResponse: %v", err) + t.Fatalf("Continue: %v", err) } if continued.Content != continuationReply { t.Fatalf("continuation reply = %q, want %q", continued.Content, continuationReply)