diff --git a/model/renderers/deepseek3.go b/model/renderers/deepseek3.go
index c52b08049..74794bac1 100644
--- a/model/renderers/deepseek3.go
+++ b/model/renderers/deepseek3.go
@@ -71,20 +71,17 @@ func (r *DeepSeekRenderer) Render(messages []api.Message, tools []api.Tool, thin
sb.WriteString("<|tool▁calls▁end|><|end▁of▁sentence|>")
} else {
if isLastUser {
- sb.WriteString("<|Assistant|>")
- if enableThinking {
- sb.WriteString("")
- } else {
- sb.WriteString("")
- }
+ sb.WriteString("<|Assistant|>")
}
isLastUser = false
content := message.Content
+
if isToolContext {
sb.WriteString(content + "<|end▁of▁sentence|>")
isToolContext = false
} else {
+ // Remove any existing tags from content (matching Jinja behavior)
if strings.Contains(content, "") {
parts := strings.SplitN(content, "", 2)
if len(parts) > 1 {
diff --git a/model/renderers/deepseek3_test.go b/model/renderers/deepseek3_test.go
index f389881c7..74ae86e9e 100644
--- a/model/renderers/deepseek3_test.go
+++ b/model/renderers/deepseek3_test.go
@@ -16,6 +16,45 @@ func TestDeepSeekRenderer(t *testing.T) {
thinkValue *api.ThinkValue
expected string
}{
+ {
+ name: "debug multi-turn conversation",
+ messages: []api.Message{
+ {Role: "user", Content: "hey!"},
+ {Role: "assistant", Content: "Hey there! 👋 How's it going?"},
+ {Role: "user", Content: "how are you?"},
+ },
+ thinkValue: &api.ThinkValue{Value: true},
+ expected: `<|begin▁of▁sentence|><|User|>hey!<|Assistant|>Hey there! 👋 How's it going?<|end▁of▁sentence|><|User|>how are you?<|Assistant|>`,
+ },
+ {
+ name: "historical message with thinking field",
+ messages: []api.Message{
+ {Role: "user", Content: "hello"},
+ {
+ Role: "assistant",
+ Thinking: "The user is greeting me, I should respond politely.",
+ Content: "Hello! How can I help you today?",
+ },
+ {Role: "user", Content: "thanks"},
+ },
+ thinkValue: &api.ThinkValue{Value: false},
+ expected: `<|begin▁of▁sentence|><|User|>hello<|Assistant|>Hello! How can I help you today?<|end▁of▁sentence|><|User|>thanks<|Assistant|>`,
+ },
+ {
+ name: "conversation with thinking enabled",
+ messages: []api.Message{
+ {Role: "user", Content: "hey!"},
+ {
+ Role: "assistant",
+ Content: `Hey there! 😊 How's your day going? What can I help you with today - whether it's answering
+questions, brainstorming ideas, or just having a chat?!`,
+ },
+ {Role: "user", Content: "chat"},
+ },
+ thinkValue: &api.ThinkValue{Value: true},
+ expected: `<|begin▁of▁sentence|><|User|>hey!<|Assistant|>Hey there! 😊 How's your day going? What can I help you with today - whether it's answering
+questions, brainstorming ideas, or just having a chat?!<|end▁of▁sentence|><|User|>chat<|Assistant|>`,
+ },
{
name: "basic user message",
messages: []api.Message{
@@ -280,6 +319,9 @@ Second instruction<|User|>Hello<|Assistant|>`,
if err != nil {
t.Fatalf("Render() error = %v", err)
}
+ if tt.name == "debug multi-turn conversation" {
+ t.Logf("Actual rendered output: %q", rendered)
+ }
if diff := cmp.Diff(tt.expected, rendered); diff != "" {
t.Errorf("Render() mismatch (-want +got):\n%s", diff)
}