Make agent suspend tests release on the suspend signal

The single- and multi-level suspend/restore tests gated their slow
leaf tool on a manual release channel closed 50ms after cancel().
That sleep was a guess at how long the suspend signal takes to reach
the running sub-agent, so the post-tool turn boundary could observe
the release before cancellation and complete the run instead of
checkpointing, making the assertions timing-dependent.

Expose the per-run suspend signal through SuspendSignalFrom in an
export_test shim and have the leaf tools block on it directly. The
tool now returns only once the graceful-suspend signal has actually
propagated to its agent, so suspension is observed deterministically
without sleeps or release channels.

Signed-off-by: Bryan Frimin <bryan@probo.com>
This commit is contained in:
Bryan Frimin
2026-06-07 12:15:00 +02:00
parent a8d4da3916
commit 5a8654969e
3 changed files with 45 additions and 13 deletions

View File

@@ -109,9 +109,12 @@ func withSuspendableToolContext(ctx context.Context, tool Tool) (context.Context
}
execCtx, cancel := context.WithCancelCause(ctx)
stop := context.AfterFunc(signal, func() {
cancel(context.Cause(signal))
})
stop := context.AfterFunc(
signal,
func() {
cancel(context.Cause(signal))
},
)
return execCtx, func() {
stop()