Update agent tests for the ctx-cancel suspend contract

Rewrite the WithStopSignal-driven test in restore_test.go to use a
cancellable ctx. Update agent_test.go's "context cancellation"
case from asserting "cannot complete" failure to asserting a
SuspendedError. Add cancel_test.go covering both pre-first-turn
cancel (no LLM call, empty checkpoint persisted) and mid-run
cancel from inside a tool (just-completed turn preserved in the
checkpoint, second LLM call suppressed).

Signed-off-by: Aurélien Sibiril <81782+aureliensibiril@users.noreply.github.com>
This commit is contained in:
Aurélien Sibiril
2026-04-27 09:52:02 +02:00
parent 53747733b3
commit 1b62d39a2e
3 changed files with 145 additions and 6 deletions

View File

@@ -476,9 +476,8 @@ func TestRestore(t *testing.T) {
store := newMemoryCheckpointer()
stopCh := make(chan struct{})
close(stopCh)
ctx := agent.WithStopSignal(context.Background(), stopCh)
ctx, cancel := context.WithCancel(context.Background())
cancel()
_, err := ag.Run(
ctx,