github/copilot-sdk · error · IllegalArgumentException
setModel cannot combine an explicit autoTier with…
Error message
setModel cannot combine an explicit autoTier with resetAutoTier; choose one
What it means
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.
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.
Example fix
// before
session.setModel(new SetModelOptions().setModel("gpt-5").setAutoTier("high").setResetAutoTier(true));
// after
var opts = new SetModelOptions().setModel("gpt-5");
if (resetRequested) {
opts.setResetAutoTier(true);
} else {
opts.setAutoTier("high");
}
session.setModel(opts); Defensive patterns
Strategy: validation
Validate before calling
if (options.getAutoTier() != null && options.isResetAutoTier()) {
throw new IllegalArgumentException("choose either autoTier or resetAutoTier, not both");
} Type guard
boolean optionsConsistent(com.github.copilot.rpc.SetModelOptions o) { return !(o.getAutoTier() != null && o.isResetAutoTier()); } Try / catch
try {
session.setModel(options);
} catch (IllegalArgumentException e) {
LOG.warning("conflicting auto-tier options: " + e.getMessage());
} Prevention
- 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.
When it happens
Trigger: Calling session.setModel with options where getAutoTier() != null and isResetAutoTier() is true simultaneously (CopilotSession.java:2243).
Common situations: 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.
Related errors
- options must not be null
- options must specify a model
- required=true cannot be combined with a non-empty…
- schema cannot be combined with defaultValue — express…
- sessionFs.initialCwd is required
AI-assisted analysis of github/copilot-sdk@cd8cf15dc3 (2026-09-09).
Data as JSON: /api/errors/77e46e0a3149dc62.
Report an issue: GitHub.
Appendix: source
Thrown at java/sdk/src/main/java/com/github/copilot/CopilotSession.java:2243
* @return a future that completes when the model switch is acknowledged
* @throws IllegalArgumentException
* if {@code options} is {@code null}, if it carries no model ID, or
* if it requests both an explicit Auto tier and a return to
* provider-default Auto routing
* @throws IllegalStateException
* if this session has been terminated
* @since 1.6.0
*/
public CompletableFuture<Void> setModel(com.github.copilot.rpc.SetModelOptions options) {
ensureNotTerminated();
if (options == null) {
throw new IllegalArgumentException("options must not be null");
}
if (options.getModel() == null) {
throw new IllegalArgumentException("options must specify a model");
}
if (options.getAutoTier() != null && options.isResetAutoTier()) {
throw new IllegalArgumentException(
"setModel cannot combine an explicit autoTier with resetAutoTier; choose one");
}
var generatedReasoningSummary = options.getReasoningSummary() == null
? null
: com.github.copilot.generated.rpc.ReasoningSummary.fromValue(options.getReasoningSummary());
var params = new SessionModelSwitchToParams(sessionId, options.getModel(),
toGeneratedAutoTier(options.getAutoTier()), options.getReasoningEffort(), generatedReasoningSummary,
null, toGeneratedCapabilities(options.getModelCapabilities()), null, null, null, null, null, null, null,
null, null);
if (!options.isResetAutoTier()) {
return getRpc().model.switchTo(params).thenApply(r -> null);
}
// The generated params record omits null properties, but returning to
// provider-default Auto routing requires sending an explicit null tier, so
// build the payload directly and reinstate the null.
ObjectNode payload = MAPPER.valueToTree(params);
payload.putNull("autoTier");
return rpc.invoke("session.model.switchTo", payload, Void.class);View on GitHub (pinned to cd8cf15dc3)