Files
goclaw/internal/webhooks/timeout.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

25 lines
713 B
Go

package webhooks
import "time"
const (
// DefaultAgentTimeout is the fallback webhook agent-run deadline when config is unset.
DefaultAgentTimeout = 600 * time.Second
// MaxAgentTimeout caps the configurable webhook agent-run deadline (1h) so a config
// typo cannot hold worker/lane slots indefinitely.
MaxAgentTimeout = 3600 * time.Second
)
// ResolveTimeoutSec converts a config value (seconds) into a bounded duration:
// <= 0 → DefaultAgentTimeout; > 3600 → MaxAgentTimeout; otherwise the value.
func ResolveTimeoutSec(sec int) time.Duration {
if sec <= 0 {
return DefaultAgentTimeout
}
d := time.Duration(sec) * time.Second
if d > MaxAgentTimeout {
return MaxAgentTimeout
}
return d
}