test(agent): wait out a held final observation, not a slow seal

TestFinalObservationIsBoundedAfterACompletedAnswer gave Run one second
after cancel (three after the deadline) to come back. Run still seals the
contract and the bundle after its context ends, because the first lock
attempt does not wait; locally that takes about 18ms, but on a loaded
windows-latest runner it overran the window and the test reported a held
observation that was not there (studio runs 40110025629, 40064086851).

The observation the test holds never returns until it is released, so any
finite wait catches the regression; use testenv.Budget for both waits.
This commit is contained in:
xxoingr committed 2026-10-25 02:16:00 +08:00
1 parent cf93de51be
commit 5230537980
1 file changed
+6 -4
@@ -12,6 +12,7 @@ import (
"time"
"reasonix/internal/base/filelock"
"reasonix/internal/base/testenv"
"reasonix/internal/contract/event"
"reasonix/internal/contract/provider"
"reasonix/internal/contract/tool"
@@ -83,7 +84,9 @@ func TestFinalObservationIsBoundedAfterACompletedAnswer(t *testing.T) {
ctx, cancel := context.WithCancel(t.Context())
defer cancel()
var want error
wait := time.Second
// Run still seals the bundle once its context ends, so the wait
// only catches an observation holding the turn, never latency.
wait := testenv.Budget(t)
if end == "cancel" {
want = context.Canceled
}
@@ -91,16 +94,15 @@ func TestFinalObservationIsBoundedAfterACompletedAnswer(t *testing.T) {
ctx, cancel = context.WithTimeout(t.Context(), 2*time.Second)
defer cancel()
want = context.DeadlineExceeded
wait = 3 * time.Second
}
if end == "observation_budget" {
wait = snapshotWait + 3*time.Second
wait += snapshotWait
}
done := make(chan error, 1)
go func() { done <- a.Run(ctx, "Answer the question.") }()
select {
case <-store.blocked:
case <-time.After(5 * time.Second):
case <-time.After(testenv.Budget(t)):
t.Fatal("final workspace observation was not reached")
}
msgs := sess.Snapshot()