[PR #2542] [MERGED] fix: chat system prompting overrides #42175

Closed
opened 2026-04-24 21:57:41 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/2542
Author: @BruceMacD
Created: 2/16/2024
Status: Merged
Merged: 2/16/2024
Merged by: @BruceMacD

Base: mainHead: brucemacd/no-cli-multi-sys


📝 Commits (7)

  • b6f974a fix: do not set multiple system msgs in a row
  • 34e3569 fix: if a system message is specified, do not template model system
  • c2075e3 fix: use requested model template
  • 800a329 move model system set up to caller
  • c132c77 remove state from system setting
  • 48c818f move comment
  • 54ba8ae Update cmd/interactive.go

📊 Changes

4 files changed (+24 additions, -41 deletions)

View changed files

📝 cmd/interactive.go (+9 -2)
📝 server/prompt.go (+1 -6)
📝 server/prompt_test.go (+1 -30)
📝 server/routes.go (+13 -3)

📄 Description

This change fixes two more system message related issues with the CLI and message templates.

  • When /set system ... is run multiple times in the CLI, use only the most recent system message rather than adding multiple system messages to the history.
  • Do not add the model's default message as a first message when a new system message is specified.
  • When a request was made to a model than inherits from the currently loaded model the system and template were not updated in the /chat endpoint. The fix is to use the requested model rather than the loaded one.

Previous behavior, when running a model and setting a new system message:

ollama run phi
>>> /set system you are mario
Set system message.
>>> hi
level=DEBUG source=routes.go:1205 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: \nAssistant:System: you are mario\nUser: hi\nAssistant:"

New behavior:

level=DEBUG source=routes.go:1205 msg="chat handler" prompt="System: you are mario\nUser: hi\nAssistant:"

resolves #2492

Follow up: This keep the "system message history" further testing on model behavior of this is needed, it could be better to just override the system message, and not keep the old system message in the history.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/2542 **Author:** [@BruceMacD](https://github.com/BruceMacD) **Created:** 2/16/2024 **Status:** ✅ Merged **Merged:** 2/16/2024 **Merged by:** [@BruceMacD](https://github.com/BruceMacD) **Base:** `main` ← **Head:** `brucemacd/no-cli-multi-sys` --- ### 📝 Commits (7) - [`b6f974a`](https://github.com/ollama/ollama/commit/b6f974ae8dea50d1d6eb44761f7884a2145b71dd) fix: do not set multiple system msgs in a row - [`34e3569`](https://github.com/ollama/ollama/commit/34e35695d94154273878c258ddff0a779b89c44f) fix: if a system message is specified, do not template model system - [`c2075e3`](https://github.com/ollama/ollama/commit/c2075e3929c0f51eafe6c86aaaf9cfe1710c0a78) fix: use requested model template - [`800a329`](https://github.com/ollama/ollama/commit/800a32950fb468ad80ba473ea3de7c196785c680) move model system set up to caller - [`c132c77`](https://github.com/ollama/ollama/commit/c132c77d9c6db22fb52e55ed88eb91430206f264) remove state from system setting - [`48c818f`](https://github.com/ollama/ollama/commit/48c818fef1ed1249263999cbb90d528137eba9ad) move comment - [`54ba8ae`](https://github.com/ollama/ollama/commit/54ba8ae353ab2fc4d82b5f5cdcefc84ec05304e0) Update cmd/interactive.go ### 📊 Changes **4 files changed** (+24 additions, -41 deletions) <details> <summary>View changed files</summary> 📝 `cmd/interactive.go` (+9 -2) 📝 `server/prompt.go` (+1 -6) 📝 `server/prompt_test.go` (+1 -30) 📝 `server/routes.go` (+13 -3) </details> ### 📄 Description This change fixes two more system message related issues with the CLI and message templates. - When `/set system ...` is run multiple times in the CLI, use only the most recent system message rather than adding multiple system messages to the history. - Do not add the model's default message as a first message when a new system message is specified. - When a request was made to a model than inherits from the currently loaded model the system and template were not updated in the /chat endpoint. The fix is to use the requested model rather than the loaded one. Previous behavior, when running a model and setting a new system message: ``` ollama run phi >>> /set system you are mario Set system message. >>> hi ``` ``` level=DEBUG source=routes.go:1205 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: \nAssistant:System: you are mario\nUser: hi\nAssistant:" ``` New behavior: ``` level=DEBUG source=routes.go:1205 msg="chat handler" prompt="System: you are mario\nUser: hi\nAssistant:" ``` resolves #2492 Follow up: This keep the "system message history" further testing on model behavior of this is needed, it could be better to just override the system message, and not keep the old system message in the history. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-24 21:57:41 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#42175