From 1c11690a6544b077bfbd3f5ea804b707ef038032 Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 24 Nov 2025 12:15:14 +0800 Subject: [PATCH] Enhance interrupt test clarity by specifying empty messages for force interrupts - Updated the test case for force interrupts to clarify that empty messages indicate pure cancellation. - Improved log messages to reflect the change in behavior, ensuring better understanding of context cancellation during tests. --- agent/context/interrupt_test.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/agent/context/interrupt_test.go b/agent/context/interrupt_test.go index 92df85bb..8cf17ff6 100644 --- a/agent/context/interrupt_test.go +++ b/agent/context/interrupt_test.go @@ -520,10 +520,11 @@ func TestInterruptContext(t *testing.T) { // Get context before interrupt interruptCtx := ctx.Interrupt.Context() - // Send force interrupt + // Send force interrupt with empty messages (pure cancellation) + // This is the pattern for stopping streaming without appending messages signal := &InterruptSignal{ Type: InterruptForce, - Messages: []Message{{Role: RoleUser, Content: "force stop"}}, + Messages: []Message{}, // Empty messages = pure cancellation Timestamp: time.Now().UnixMilli(), } err := SendInterrupt(ctx.ID, signal) @@ -536,9 +537,9 @@ func TestInterruptContext(t *testing.T) { // The OLD context should be cancelled select { case <-interruptCtx.Done(): - t.Log("✓ Force interrupt cancelled the old context") + t.Log("✓ Force interrupt with empty messages cancelled the old context") case <-time.After(200 * time.Millisecond): - t.Error("Old context was not cancelled after force interrupt") + t.Error("Old context was not cancelled after force interrupt with empty messages") } // Note: IsInterrupted() checks the NEW context (which was recreated)