[GH-ISSUE #2568] /set system in CLI still append to System Prompt after ollama#2542 #1507

Closed
opened 2026-04-12 11:25:10 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @hyjwei on GitHub (Feb 17, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/2568

Originally assigned to: @pdevine on GitHub.

This is a follow-up for #2492 . Thanks for fixing that issue. However, /set system in CLI still append to System Prompt after PR ollama#2542 .

In the second scenario of #2492, when I load a model, then use /set system to specify a custom System Prompt, it does replace the old one.

However, if I load a model, start a chat with the old System Prompt at first, then use /set system to specify a custom System Prompt, it will append to the old one instead of replacing that.

How to replicate

Start a new server by ollama serve with OLLAMA_DEBUG=1
Run client with any model, for example, ollama run phi
Start a chat (for example, user prompt hello), and you can find the prompt debug info on server side looks like (and this is expected):

time=2024-02-17T16:34:41.346-05:00 level=DEBUG source=routes.go:1165 msg="chat handler" prompt="System: A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful answers to the user's questions.\nUser: hello\nAssistant:"

Then, set system prompt by /set system

/set system I want you to speak French only.

And input user prompt hello again, and you can find prompt debug info:

time=2024-02-17T16:35:05.369-05:00 level=DEBUG source=routes.go:1165 msg="chat handler" prompt="System: A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful answers to the user's questions.\nUser: hello\nAssistant: Hello! How can I assist you today?\nSystem: I want you to speak French only.\nUser: hello\nAssistant:"

This time, you can find that the new System Prompt is appended to the chat, which includes the old System Prompt and User/Assistant conversation.
From this point, the new system prompt by /set system will also append to the old prompts, even if I don't give any new user prompt. Thus multiple /set system (no user prompt in between) will make prompt look like:

time=2024-02-17T16:42:31.942-05:00 level=DEBUG source=routes.go:1165 msg="chat handler" prompt="System: A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful answers to the user's questions.\nUser: hello\nAssistant: Hello! How can I assist you today?\nSystem: I want you to speak French only.\nUser: hello\nAssistant: Bonjour! Je parle français. Comment ça va? (Hello! I speak French. How are you?)\nSystem: I want you to speak English only.\nUser: hello\nAssistant: Hello! How can I assist you today?\nSystem: I want you to speak German only.\nUser: \nAssistant:System: I want you to speak Italian only.\nUser: hello\nAssistant:"

You can see that the User Prompt and model response is empty between the last two System Prompts.

My thought on this issue

I am not sure if changing system prompt after user prompt is a valid scenario or not, nor what behavior can be right. But I do believe that at least, if I give /set system twice or more without user prompt, only the last one should take effect.

Originally created by @hyjwei on GitHub (Feb 17, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/2568 Originally assigned to: @pdevine on GitHub. This is a follow-up for #2492 . Thanks for fixing that issue. However, `/set system` in CLI still append to System Prompt after PR ollama#2542 . In the second scenario of #2492, when I load a model, then use `/set system` to specify a custom System Prompt, it does replace the old one. However, if I load a model, start a chat with the old System Prompt at first, then use `/set system` to specify a custom System Prompt, it will append to the old one instead of replacing that. ### How to replicate Start a new server by `ollama serve` with `OLLAMA_DEBUG=1` Run client with any model, for example, `ollama run phi` Start a chat (for example, user prompt `hello`), and you can find the prompt debug info on server side looks like (and this is expected): ``` time=2024-02-17T16:34:41.346-05:00 level=DEBUG source=routes.go:1165 msg="chat handler" prompt="System: A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful answers to the user's questions.\nUser: hello\nAssistant:" ``` Then, set system prompt by `/set system` ``` /set system I want you to speak French only. ``` And input user prompt `hello` again, and you can find prompt debug info: ``` time=2024-02-17T16:35:05.369-05:00 level=DEBUG source=routes.go:1165 msg="chat handler" prompt="System: A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful answers to the user's questions.\nUser: hello\nAssistant: Hello! How can I assist you today?\nSystem: I want you to speak French only.\nUser: hello\nAssistant:" ``` This time, you can find that the new System Prompt is appended to the chat, which includes the old System Prompt and User/Assistant conversation. From this point, the new system prompt by `/set system` will also append to the old prompts, even if I don't give any new user prompt. Thus multiple `/set system` (no user prompt in between) will make prompt look like: ``` time=2024-02-17T16:42:31.942-05:00 level=DEBUG source=routes.go:1165 msg="chat handler" prompt="System: A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful answers to the user's questions.\nUser: hello\nAssistant: Hello! How can I assist you today?\nSystem: I want you to speak French only.\nUser: hello\nAssistant: Bonjour! Je parle français. Comment ça va? (Hello! I speak French. How are you?)\nSystem: I want you to speak English only.\nUser: hello\nAssistant: Hello! How can I assist you today?\nSystem: I want you to speak German only.\nUser: \nAssistant:System: I want you to speak Italian only.\nUser: hello\nAssistant:" ``` You can see that the User Prompt and model response is empty between the last two System Prompts. ## My thought on this issue I am not sure if changing system prompt after user prompt is a valid scenario or not, nor what behavior can be right. But I do believe that at least, if I give `/set system` twice or more without user prompt, only the last one should take effect.
GiteaMirror added the bug label 2026-04-12 11:25:10 -05:00
Author
Owner

@pdevine commented on GitHub (Dec 20, 2024):

This has been working for a while, but the issue got lost. Going to go ahead and close it.

<!-- gh-comment-id:2557889932 --> @pdevine commented on GitHub (Dec 20, 2024): This has been working for a while, but the issue got lost. Going to go ahead and close it.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#1507