MCPcopy Index your code
hub / github.com/coder/coder / chainBrokenClassification

Function chainBrokenClassification

coderd/x/chatd/chaterror/classify.go:375–398  ·  view source on GitHub ↗

chainBrokenClassification recognizes the OpenAI error "Previous response with id ... not found" returned when a chained turn references a previous_response_id the provider no longer recognizes.

(
	lowerMessage string,
	provider string,
	statusCode int,
	structured providerErrorDetails,
)

Source from the content-addressed store, hash-verified

373// chained turn references a previous_response_id the provider no
374// longer recognizes.
375func chainBrokenClassification(
376 lowerMessage string,
377 provider string,
378 statusCode int,
379 structured providerErrorDetails,
380) (ClassifiedError, bool) {
381 if !(strings.Contains(lowerMessage, "previous response with id") &&
382 strings.Contains(lowerMessage, "not found")) {
383 return ClassifiedError{}, false
384 }
385 // This class of error has so far only been observed with OpenAI.
386 if provider == "" {
387 provider = "openai"
388 }
389 return normalizeClassification(ClassifiedError{
390 Detail: structured.detail,
391 Kind: codersdk.ChatErrorKindGeneric,
392 Provider: provider,
393 Retryable: true,
394 StatusCode: statusCode,
395 RetryAfter: structured.retryAfter,
396 ChainBroken: true,
397 }), true
398}
399
400func responsesAPIDiagnostic(lowerMessage, detail string) (string, bool) {
401 lowerDetail := strings.ToLower(detail)

Callers 1

ClassifyFunction · 0.85

Calls 2

normalizeClassificationFunction · 0.85
ContainsMethod · 0.45

Tested by

no test coverage detected