mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-04 16:13:47 +00:00
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
28 lines
604 B
Go
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)
|
|
}
|
|
})
|
|
}
|
|
}
|