{"record":{"id":"ac2bcc8229f6de84","repo":"github/copilot-sdk","slug":"failed-to-set-auto-tier-w","errorCode":null,"errorMessage":"failed to set auto tier: %w","messagePattern":"failed to set auto tier: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/session.go","lineNumber":2041,"sourceCode":"// Only the most recent request survives: issuing a new request replaces any earlier one\n// that has not yet been claimed by a turn.\n//\n// Pass nil to return to the provider's default Auto routing.\n//\n// Experimental: SetAutoTier is part of an experimental Auto routing surface and\n// may change or be removed.\n//\n// Example:\n//\n//\ttier := copilot.AutoTierIntelligence\n//\tresult, err := session.SetAutoTier(context.Background(), &tier)\n//\tif err != nil {\n//\t    log.Printf(\"Failed to set auto tier: %v\", err)\n//\t}\nfunc (s *Session) SetAutoTier(ctx context.Context, autoTier *AutoTier) (*rpc.ModelSwitchAutoTierResult, error) {\n\tresult, err := s.RPC.Model.SwitchAutoTier(ctx, &rpc.ModelSwitchAutoTierRequest{AutoTier: autoTier})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to set auto tier: %w\", err)\n\t}\n\n\treturn result, nil\n}\n\ntype LogOptions struct {\n\t// Level sets the log severity. Valid values are [rpc.SessionLogLevelInfo] (default),\n\t// [rpc.SessionLogLevelWarning], and [rpc.SessionLogLevelError].\n\tLevel rpc.SessionLogLevel\n\t// Ephemeral marks the message as transient so it is not persisted\n\t// to the session event log on disk. When nil the server decides the\n\t// default; set to a non-nil value to explicitly control persistence.\n\tEphemeral *bool\n}\n\n// Log sends a log message to the session timeline.\n// The message appears in the session event stream and is visible to SDK consumers\n// and (for non-ephemeral messages) persisted to the session event log on disk.","sourceCodeStart":2023,"sourceCodeEnd":2059,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/go/session.go#L2023-L2059","documentation":"Session.SetAutoTier changes the Auto routing preference via s.RPC.Model.SwitchAutoTier without switching models. This error wraps any failure of that RPC — an invalid AutoTier value, a runtime that doesn't support auto-tier routing, or a transport failure.","triggerScenarios":"Calling Session.SetAutoTier(ctx, autoTier) when `Model.SwitchAutoTier` rejects the request (unsupported tier value, feature unavailable in the running runtime) or the transport fails.","commonSituations":"Passing an AutoTier constant not recognized by an older runtime; invoking auto-tier on a deployment where the routing feature is disabled; stale session after reconnect.","solutions":["Confirm the AutoTier value is one supported by the running runtime version","Inspect the wrapped error for the runtime's rejection reason","Upgrade the runtime/CLI if auto-tier support was added later","Fall back to SetModel with an explicit model when auto-tier is unavailable"],"exampleFix":"// before\nresult, err := session.SetAutoTier(ctx, &AutoTierHigh)\n// after\nresult, err := session.SetAutoTier(ctx, &AutoTierHigh)\nif err != nil {\n    log.Printf(\"set auto tier failed, falling back to explicit model: %v\", err)\n    err = session.SetModel(ctx, defaultModel, defaultProvider)\n}","handlingStrategy":"fallback","validationCode":"if autoTier != nil && *autoTier != \"high\" && *autoTier != \"low\" {\n    return errors.New(\"unsupported auto tier value\")\n}","typeGuard":null,"tryCatchPattern":"result, err := session.SetAutoTier(ctx, tier)\nif err != nil {\n    log.Printf(\"auto tier unavailable: %v — using explicit model\", err)\n    return session.SetModel(ctx, fallbackModel, fallbackProvider)\n}","preventionTips":["Only use AutoTier values the target runtime understands","Provide an explicit-model fallback path","Gate auto-tier usage on runtime version detection"],"tags":["go","model","auto-tier","rpc"],"backgroundTag":"api-request-failed","analyzedSha":"cd8cf15dc3f9e762615790aaed0a771a0f392755","analyzedAt":"2026-09-09T18:32:31.973Z","contentChangedAt":"2026-09-09T18:32:31.973Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}