Files
goclaw/internal/webhooks/timeout_test.go
T
thotam a10464290d feat(webhooks): configurable agent run timeout (default 600s) (#1267)
Replace the hardcoded 30s webhook agent-run deadline with a configurable
timeout (default 600s, cap 3600s) for both the async worker and the
sync/test HTTP handler. Legitimate multi-step runs were dying at 30s
mid-tool-call; the same request over WebSocket completed fine.

- internal/webhooks/timeout.go: ResolveTimeoutSec helper (<=0 → 600s, cap 3600s)
- WorkerConfig.AsyncAgentTimeout (async worker) + WebhookLLMHandler.syncTimeout
  (sync + admin test), wired from config
- config keys gateway.webhook_{async,sync}_timeout_sec, also settable via
  GOCLAW_WEBHOOK_{ASYNC,SYNC}_TIMEOUT_SEC env (env overrides config)
- tests: timeout bounds + config file/env override
2026-06-24 09:22:06 +07:00

28 lines
604 B
Go

package webhooks
import (
"testing"
"time"
)
func TestResolveTimeoutSec(t *testing.T) {
cases := []struct {
name string
in int
want time.Duration
}{
{"zero uses default", 0, 600 * time.Second},
{"negative uses default", -5, 600 * time.Second},
{"passthrough", 120, 120 * time.Second},
{"caps at 3600", 99999, 3600 * time.Second},
{"exactly cap", 3600, 3600 * time.Second},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
if got := ResolveTimeoutSec(c.in); got != c.want {
t.Fatalf("ResolveTimeoutSec(%d) = %v, want %v", c.in, got, c.want)
}
})
}
}