Skip to content

Commit f47146c

Browse files
Increase LLM timeouts to 3m per turn and 10m per request (#8789)
1 parent 0d78fb7 commit f47146c

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

runtime/ai/ai.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,7 @@ func (s *Session) CallTool(ctx context.Context, role Role, toolName string, out,
10781078
})
10791079
}
10801080

1081-
const llmRequestTimeout = 60 * time.Second
1081+
const llmRequestTimeout = 3 * time.Minute
10821082

10831083
// CompleteOptions provides options for Session.Complete.
10841084
type CompleteOptions struct {
@@ -1249,6 +1249,9 @@ func (s *Session) Complete(ctx context.Context, name string, out any, opts *Comp
12491249

12501250
// Handle LLM completion error
12511251
if err != nil {
1252+
if errors.Is(err, llmCtx.Err()) && errors.Is(err, context.DeadlineExceeded) {
1253+
return nil, fmt.Errorf("LLM request timed out after %s: %w", llmRequestTimeout, err)
1254+
}
12521255
return nil, fmt.Errorf("completion failed: %w", err)
12531256
}
12541257

runtime/server/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ func timeoutSelector(fullMethodName string) time.Duration {
300300
}
301301

302302
if fullMethodName == runtimev1.RuntimeService_Complete_FullMethodName || fullMethodName == runtimev1.RuntimeService_CompleteStreaming_FullMethodName {
303-
return time.Minute * 5
303+
return time.Minute * 10
304304
}
305305

306306
if fullMethodName == runtimev1.RuntimeService_Health_FullMethodName || fullMethodName == runtimev1.RuntimeService_InstanceHealth_FullMethodName {

0 commit comments

Comments
 (0)