siyuan-note/siyuan · error

model request timeout

Error message

model request timeout

What it means

errModelRequestTimeout is a sentinel error indicating the HTTP request to the model provider exceeded the configured request timeout. createStreamWithRetry maps a timer expiration onto this sentinel (optionally overriding the transport error) and classifyRetry labels it "timeout" so the retry logic can back off and retry.

Solutions

  1. Increase the model request timeout configuration
  2. Check provider status/network connectivity and proxy settings
  3. Retry — the built-in retry loop already classifies this as retryable ("timeout")
  4. Reduce prompt size so the request completes within the timeout
  5. Verify maxRetries is not 0 if automatic retries are desired
Defensive patterns

Strategy: retry

Try / catch

if errors.Is(err, errModelRequestTimeout) {
    // back off and retry; also consider raising the request timeout
}

Prevention

When it happens

Trigger: In createStreamWithRetry/createProtocolStreamWithRetry, the per-request context timer fires before the stream is established (requestTimedOut is true), so err is replaced with errModelRequestTimeout; also returned by createResponseCompaction and covered by TestCreateStreamRequestTimeoutAndZeroRetries.

Common situations: Slow or overloaded model provider endpoints; requestTimeout configured too aggressively low; network latency/proxy delays; very large prompts taking longer than the timeout to be accepted.

Understand the failure class

Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11). Data as JSON: /api/errors/e704236803979d36. Report an issue: GitHub.

Appendix: source

Thrown at kernel/agent/agent.go:2444

			}
			e := SessionEntry{
				ID:                   id,
				Type:                 "assistant",
				Content:              m.Content,
				ReasoningCont:        m.ReasoningContent,
				ResponseOutput:       util.CloneOpenAIResponseOutput(m.ResponseOutput),
				ResponseOutputTokens: m.ResponseOutputTokens,
				RoundID:              m.RoundID,
				ToolCalls:            m.ToolCalls,
			}
			entries = append(entries, e)
		}
	}
	return entries
}

var (
	errModelRequestTimeout    = errors.New("model request timeout")
	errModelStreamIdleTimeout = errors.New("model stream idle timeout")
)

func createStreamWithRetry(ctx context.Context, client *openai.Client, req openai.ChatCompletionRequest, maxRetries int,
	requestTimeout, streamIdleTimeout time.Duration, retryDelay func(string, int) time.Duration,
	ch chan<- AgentEvent) (*util.OpenAICompletionStream, openai.ChatCompletionStreamResponse, context.CancelFunc, error) {
	return createProtocolStreamWithRetry(ctx, client, util.OpenAIProtocolChatCompletions, req, nil, maxRetries,
		requestTimeout, streamIdleTimeout, retryDelay, ch)
}

func createProtocolStreamWithRetry(ctx context.Context, client *openai.Client, protocol string,
	req openai.ChatCompletionRequest, responseInput []any, maxRetries int, requestTimeout, streamIdleTimeout time.Duration,
	retryDelay func(string, int) time.Duration,
	ch chan<- AgentEvent) (*util.OpenAICompletionStream, openai.ChatCompletionStreamResponse, context.CancelFunc, error) {
	if maxRetries < 0 {
		maxRetries = 0
	}

View on GitHub (pinned to 8641553a1f)