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.
This commit is contained in:
parent
e68e0d3488
commit
e2ce613371
3 changed files with 12 additions and 24 deletions
|
|
@ -102,7 +102,7 @@ type processOptions struct {
|
||||||
SendResponse bool // Whether to send response via bus
|
SendResponse bool // Whether to send response via bus
|
||||||
SuppressToolFeedback bool // Whether to suppress inline tool feedback messages
|
SuppressToolFeedback bool // Whether to suppress inline tool feedback messages
|
||||||
NoHistory bool // If true, don't load session history (for heartbeat)
|
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)
|
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),
|
"queue_depth": al.pendingSteeringCountForScope(target.SessionKey),
|
||||||
})
|
})
|
||||||
|
|
||||||
continued, continueErr := al.continueResponse(
|
continued, continueErr := al.Continue(
|
||||||
ctx,
|
ctx,
|
||||||
target.SessionKey,
|
target.SessionKey,
|
||||||
target.Channel,
|
target.Channel,
|
||||||
|
|
@ -637,7 +637,7 @@ func (al *AgentLoop) Run(ctx context.Context) error {
|
||||||
"queue_depth": al.pendingSteeringCountForScope(target.SessionKey),
|
"queue_depth": al.pendingSteeringCountForScope(target.SessionKey),
|
||||||
})
|
})
|
||||||
|
|
||||||
continued, continueErr := al.continueResponse(
|
continued, continueErr := al.Continue(
|
||||||
ctx,
|
ctx,
|
||||||
target.SessionKey,
|
target.SessionKey,
|
||||||
target.Channel,
|
target.Channel,
|
||||||
|
|
|
||||||
|
|
@ -319,10 +319,10 @@ func (al *AgentLoop) agentForSession(sessionKey string) *AgentInstance {
|
||||||
return registry.GetDefaultAgent()
|
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.
|
// Returns an agentResponse with OnDelivered set for delayed session persistence.
|
||||||
// If no steering messages are pending, returns an empty agentResponse.
|
// If no steering messages are pending, returns an empty agentResponse.
|
||||||
func (al *AgentLoop) continueResponse(
|
func (al *AgentLoop) Continue(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
sessionKey, channel, chatID string,
|
sessionKey, channel, chatID string,
|
||||||
) (agentResponse, error) {
|
) (agentResponse, error) {
|
||||||
|
|
@ -355,18 +355,6 @@ func (al *AgentLoop) continueResponse(
|
||||||
return al.continueWithSteeringMessages(ctx, agent, sessionKey, channel, chatID, steeringMsgs)
|
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 {
|
func (al *AgentLoop) InterruptGraceful(hint string) error {
|
||||||
ts := al.getAnyActiveTurnState()
|
ts := al.getAnyActiveTurnState()
|
||||||
if ts == nil {
|
if ts == nil {
|
||||||
|
|
|
||||||
|
|
@ -298,7 +298,7 @@ func TestAgentLoop_Continue_NoMessages(t *testing.T) {
|
||||||
t.Fatal("expected provider to be initialized")
|
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 {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error: %v", err)
|
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"})
|
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 {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error: %v", err)
|
t.Fatalf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -1073,9 +1073,9 @@ func TestAgentLoop_Continue_PreservesSteeringMedia(t *testing.T) {
|
||||||
t.Fatalf("Steer failed: %v", err)
|
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 {
|
if err != nil {
|
||||||
t.Fatalf("continueResponse failed: %v", err)
|
t.Fatalf("Continue failed: %v", err)
|
||||||
}
|
}
|
||||||
if resp.Content != "ack" {
|
if resp.Content != "ack" {
|
||||||
t.Fatalf("expected ack, got %q", resp.Content)
|
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
|
// 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).
|
// even when OnDelivered has not fired yet (reply not yet in session history).
|
||||||
// The pending reply is injected via pendingDeliveries/injectPendingDelivery,
|
// 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.
|
// 1. The steering continuation's LLM call sees the previous assistant reply.
|
||||||
// 2. Session history does not contain the assistant reply (OnDelivered not called).
|
// 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)
|
t.Fatalf("pushScope: %v", pushErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
continued, err := al.continueResponse(ctx, sessionKey, channel, chatID)
|
continued, err := al.Continue(ctx, sessionKey, channel, chatID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("continueResponse: %v", err)
|
t.Fatalf("Continue: %v", err)
|
||||||
}
|
}
|
||||||
if continued.Content != continuationReply {
|
if continued.Content != continuationReply {
|
||||||
t.Fatalf("continuation reply = %q, want %q", continued.Content, continuationReply)
|
t.Fatalf("continuation reply = %q, want %q", continued.Content, continuationReply)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue