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
25 lines
713 B
Go
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
|
|
}
|