wavetermdev/waveterm · error
cannot continue with a different model, model:%q, cont-model
Error message
cannot continue with a different model, model:%q, cont-model:%q
What it means
RunOpenAIChatStep validates a provided continuation (cont *uctypes.WaveContinueResponse) at openai-backend.go:500: if uctypes.AreModelsCompatible(chat.APIType, chatOpts.Config.Model, cont.Model) is false, it returns "cannot continue with a different model". A continuation response must have been produced by the same (compatible) model as the request being made.
Source
Thrown at pkg/aiusechat/openai/openai-backend.go:500
}
if !uctypes.AreModelsCompatible(chat.APIType, chat.Model, chatOpts.Config.Model) {
return nil, nil, nil, fmt.Errorf("model mismatch: chat has %s, chatOpts has %s", chat.Model, chatOpts.Config.Model)
}
if chat.APIVersion != chatOpts.Config.APIVersion {
return nil, nil, nil, fmt.Errorf("API version mismatch: chat has %s, chatOpts has %s", chat.APIVersion, chatOpts.Config.APIVersion)
}
// Context with timeout if provided.
if chatOpts.Config.TimeoutMs > 0 {
var cancel context.CancelFunc
ctx, cancel = context.WithTimeout(ctx, time.Duration(chatOpts.Config.TimeoutMs)*time.Millisecond)
defer cancel()
}
// Validate continuation if provided
if cont != nil {
if !uctypes.AreModelsCompatible(chat.APIType, chatOpts.Config.Model, cont.Model) {
return nil, nil, nil, fmt.Errorf("cannot continue with a different model, model:%q, cont-model:%q", chatOpts.Config.Model, cont.Model)
}
}
// Convert GenAIMessages to input objects (OpenAIMessage or OpenAIFunctionCallInput)
var inputs []any
for _, genMsg := range chat.NativeMessages {
// Cast to OpenAIChatMessage
chatMsg, ok := genMsg.(*OpenAIChatMessage)
if !ok {
return nil, nil, nil, fmt.Errorf("expected OpenAIChatMessage, got %T", genMsg)
}
// Convert to appropriate input type based on what's populated
if chatMsg.Message != nil {
// Clean message to remove preview URLs
cleanedMsg := chatMsg.Message.cleanAndCopy()
inputs = append(inputs, *cleanedMsg)
} else if chatMsg.FunctionCall != nil {View on GitHub (pinned to a4447c1563)
Solutions
- Drop the cont argument (pass nil) and start a fresh step with the new model
- Align chatOpts.Config.Model with cont.Model (if that's the model you intend to continue with)
- Re-generate the continuation under the current model instead of reusing the old one
- Check AreModelsCompatible: if the models should be compatible, fix the model strings (aliases/version suffixes) rather than the logic
Example fix
// before
cont := loadSavedContinuation() // cont.Model = "gpt-4o"
chatOpts.Config.Model = "gpt-4.1"
RunOpenAIChatStep(ctx, sse, chatOpts, cont) // mismatch
// after
if cont != nil && cont.Model != chatOpts.Config.Model {
cont = nil // discard stale continuation
}
RunOpenAIChatStep(ctx, sse, chatOpts, cont) Defensive patterns
Strategy: validation
Validate before calling
if cont != nil {
chat := chatstore.DefaultChatStore.Get(chatOpts.ChatId)
if chat == nil || !uctypes.AreModelsCompatible(chat.APIType, chatOpts.Config.Model, cont.Model) {
cont = nil // discard incompatible continuation
}
} Type guard
func continuationValid(chatOpts uctypes.WaveChatOpts, cont *uctypes.WaveContinueResponse) bool {
if cont == nil {
return true
}
chat := chatstore.DefaultChatStore.Get(chatOpts.ChatId)
return chat != nil && uctypes.AreModelsCompatible(chat.APIType, chatOpts.Config.Model, cont.Model)
} Try / catch
if _, _, _, err := RunOpenAIChatStep(ctx, sse, chatOpts, cont); err != nil {
if strings.Contains(err.Error(), "cannot continue with a different model") {
// retry once with cont = nil
_, _, _, err = RunOpenAIChatStep(ctx, sse, chatOpts, nil)
return err
}
return err
} Prevention
- Store the model alongside any saved continuation and validate before reuse
- Discard continuations when the model setting changes
- Never share continuation objects between chats/models
- Prefer fresh steps over replaying stale continuation handles
When it happens
Trigger: Passing a cont (e.g. a follow-up/next-page response handle) whose cont.Model was produced under a different model than chatOpts.Config.Model — typically after the user switched models between a stopped turn and its continuation.
Common situations: Model changed in settings between the original response and clicking 'continue'; replaying an old saved continuation record against a chat now configured with a newer model; concurrent chats sharing a continuation object by mistake.
Related errors
- model mismatch: chat has %s, chatOpts has %s
- %s
- chat not found: %s
- function call with callId %s not found in chat %s
- API type mismatch: chat has %s, chatOpts has %s
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/cf1068e47a013400.
Report an issue: GitHub.