fix(weknora): drop 120s client total timeout so long agent streams are not cut
The weknora HTTP client used a hardcoded 120s total-duration timeout, which kills any smart-reasoning agent stream that legitimately runs longer (22 tool rounds measured in prod) and the failure branch then overwrote the already streamed card with the error text. Pass 0 and keep Go's default (no timeout).
This commit is contained in:
+4
-1
@@ -71,7 +71,10 @@ func main() {
|
||||
if strings.TrimSpace(settingsRuntime.clientID) == "" || strings.TrimSpace(settingsRuntime.secret) == "" {
|
||||
log.Fatal("DingTalk credentials are required; configure DINGTALK_CLIENT_ID and DINGTALK_CLIENT_SECRET in the protected runtime environment")
|
||||
}
|
||||
client, err := weknora.NewClient(os.Getenv("WEKNORA_BASE_URL"), os.Getenv("WEKNORA_API_KEY"), 120*time.Second)
|
||||
// 0 = no client-side total timeout. WeKnora's smart-reasoning agent can run
|
||||
// 20+ tool rounds and stream far longer than 120s; the total-time cap cut the
|
||||
// SSE mid-answer and the failure branch overwrote the streamed card.
|
||||
client, err := weknora.NewClient(os.Getenv("WEKNORA_BASE_URL"), os.Getenv("WEKNORA_API_KEY"), 0)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -86,9 +86,8 @@ func NewClient(baseURL, apiKey string, timeout time.Duration) (*Client, error) {
|
||||
if strings.TrimSpace(apiKey) == "" {
|
||||
return nil, errors.New("WEKNORA_API_KEY is required")
|
||||
}
|
||||
if timeout <= 0 {
|
||||
timeout = 120 * time.Second
|
||||
}
|
||||
// timeout <= 0 keeps Go's default: no client-side total timeout on the HTTP
|
||||
// client, so long-lived agent SSE streams are never cut by a duration cap.
|
||||
return &Client{baseURL: parsed.String(), apiKey: apiKey, http: &http.Client{Timeout: timeout}}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user