{"record":{"id":"77e46e0a3149dc62","repo":"github/copilot-sdk","slug":"setmodel-cannot-combine-an-explicit-autotier-with","errorCode":null,"errorMessage":"setModel cannot combine an explicit autoTier with resetAutoTier; choose one","messagePattern":"setModel cannot combine an explicit autoTier with resetAutoTier; choose one","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"java/sdk/src/main/java/com/github/copilot/CopilotSession.java","lineNumber":2243,"sourceCode":"     * @return a future that completes when the model switch is acknowledged\n     * @throws IllegalArgumentException\n     *             if {@code options} is {@code null}, if it carries no model ID, or\n     *             if it requests both an explicit Auto tier and a return to\n     *             provider-default Auto routing\n     * @throws IllegalStateException\n     *             if this session has been terminated\n     * @since 1.6.0\n     */\n    public CompletableFuture<Void> setModel(com.github.copilot.rpc.SetModelOptions options) {\n        ensureNotTerminated();\n        if (options == null) {\n            throw new IllegalArgumentException(\"options must not be null\");\n        }\n        if (options.getModel() == null) {\n            throw new IllegalArgumentException(\"options must specify a model\");\n        }\n        if (options.getAutoTier() != null && options.isResetAutoTier()) {\n            throw new IllegalArgumentException(\n                    \"setModel cannot combine an explicit autoTier with resetAutoTier; choose one\");\n        }\n        var generatedReasoningSummary = options.getReasoningSummary() == null\n                ? null\n                : com.github.copilot.generated.rpc.ReasoningSummary.fromValue(options.getReasoningSummary());\n        var params = new SessionModelSwitchToParams(sessionId, options.getModel(),\n                toGeneratedAutoTier(options.getAutoTier()), options.getReasoningEffort(), generatedReasoningSummary,\n                null, toGeneratedCapabilities(options.getModelCapabilities()), null, null, null, null, null, null, null,\n                null, null);\n        if (!options.isResetAutoTier()) {\n            return getRpc().model.switchTo(params).thenApply(r -> null);\n        }\n        // The generated params record omits null properties, but returning to\n        // provider-default Auto routing requires sending an explicit null tier, so\n        // build the payload directly and reinstate the null.\n        ObjectNode payload = MAPPER.valueToTree(params);\n        payload.putNull(\"autoTier\");\n        return rpc.invoke(\"session.model.switchTo\", payload, Void.class);","sourceCodeStart":2225,"sourceCodeEnd":2261,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/java/sdk/src/main/java/com/github/copilot/CopilotSession.java#L2225-L2261","documentation":"CopilotSession.setModel rejects logically conflicting input: specifying an explicit autoTier while also requesting resetAutoTier=true is contradictory, so it throws IllegalArgumentException('setModel cannot combine an explicit autoTier with resetAutoTier; choose one'). You must choose either a concrete tier or a reset to automatic behavior, never both.","triggerScenarios":"Calling session.setModel with options where getAutoTier() != null and isResetAutoTier() is true simultaneously (CopilotSession.java:2243).","commonSituations":"Config merging bugs: one source sets autoTier (e.g. 'high') while another flag sets resetAutoTier, and both are copied into the same options object without conflict resolution.","solutions":["Decide intent: keep the explicit autoTier and drop the resetAutoTier flag, or reset and clear autoTier.","Sanitize options at construction: if resetAutoTier is set, null out autoTier (or vice versa).","Fail fast in your own config loader when both fields are present so users get a clear message."],"exampleFix":"// before\nsession.setModel(new SetModelOptions().setModel(\"gpt-5\").setAutoTier(\"high\").setResetAutoTier(true));\n// after\nvar opts = new SetModelOptions().setModel(\"gpt-5\");\nif (resetRequested) {\n    opts.setResetAutoTier(true);\n} else {\n    opts.setAutoTier(\"high\");\n}\nsession.setModel(opts);","handlingStrategy":"validation","validationCode":"if (options.getAutoTier() != null && options.isResetAutoTier()) {\n    throw new IllegalArgumentException(\"choose either autoTier or resetAutoTier, not both\");\n}","typeGuard":"boolean optionsConsistent(com.github.copilot.rpc.SetModelOptions o) { return !(o.getAutoTier() != null && o.isResetAutoTier()); }","tryCatchPattern":"try {\n    session.setModel(options);\n} catch (IllegalArgumentException e) {\n    LOG.warning(\"conflicting auto-tier options: \" + e.getMessage());\n}","preventionTips":["Resolve config conflicts at merge time: if resetAutoTier is requested, clear autoTier.","Use a single builder function that enforces the mutual exclusion.","Surface conflicting settings to users at config load, not at call time."],"tags":["validation","conflicting-options","set-model"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"cd8cf15dc3f9e762615790aaed0a771a0f392755","analyzedAt":"2026-09-09T18:32:31.973Z","contentChangedAt":"2026-09-09T18:32:31.973Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}