[GH-ISSUE #15054] ollama cloud kimi-k2.5 cannot recognize the SystemMessage !!!! #9661

Closed
opened 2026-04-12 22:33:07 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @weiyinfu on GitHub (Mar 25, 2026).
Original GitHub issue: https://github.com/ollama/ollama/issues/15054

What is the issue?

The official kimi-k2.5 can recognize the SystemMessage. But ollama cloud kimi k2.5 cannot.
Here is the code:

from datetime import datetime

from deepagents import create_deep_agent
from langchain_core.messages import SystemMessage
from langchain_openai import ChatOpenAI


def get_local_ollama(model_name: str) -> ChatOpenAI:
    # 注意:此处ChatOllama不能放到开头去,因为会触发初始化,在非本地环境中运行的时候会报错
    from langchain_ollama import ChatOllama

    return ChatOllama(
        base_url="http://localhost:11434",  # deepseek 服务地址
        model=model_name,  # 模型名称(需提前下载)
        max_retries=3,
        api_key="",
        callbacks=[],
    )


def get_ollama_kimi() -> ChatOpenAI:
    model_name = "kimi-k2.5:cloud"
    local_ollama = get_local_ollama(model_name)
    return local_ollama


def get_kimi() -> ChatOpenAI:
    # TODO: put the right kimi api key
    api_key = "sk-xxxxx"
    return ChatOpenAI(
        model="kimi-k2.5",
        api_key=api_key,
        base_url="https://api.moonshot.cn/v1",
    )


def test_model_system_prompt(m: ChatOpenAI):
    agent = create_deep_agent(model=m)
    result = agent.invoke(
        {
            "messages": [
                # HumanMessage(content="不调用任何工具,告诉我当前时间"),
                {"role": "user", "content": "不调用任何工具,告诉我当前时间"},
                SystemMessage(content=f"当前时间为{datetime.now()}"),
            ]
        }
    )
    print(result["messages"][-1].content)


for f in [
    get_kimi,
    get_ollama_kimi,
]:
    print(f"正在测试模型{f.__name__}")
    test_model_system_prompt(f())

Relevant log output

python ollama-kimi-issue/mine.py                                          
正在测试模型get_kimi
当前时间是 2026-03-25 16:19:40。
正在测试模型get_ollama_kimi
我无法直接获取当前时间。如果您需要查看当前时间,可以:

1. **在终端中运行**:`date``date "+%Y-%m-%d %H:%M:%S"`
2. **使用 Python**:`python3 -c "import datetime; print(datetime.datetime.now())"`

如果您允许我调用工具,我也可以帮您获取时间。

OS

No response

GPU

No response

CPU

No response

Ollama version

No response

Originally created by @weiyinfu on GitHub (Mar 25, 2026). Original GitHub issue: https://github.com/ollama/ollama/issues/15054 ### What is the issue? The official kimi-k2.5 can recognize the SystemMessage. But ollama cloud kimi k2.5 cannot. Here is the code: ```python from datetime import datetime from deepagents import create_deep_agent from langchain_core.messages import SystemMessage from langchain_openai import ChatOpenAI def get_local_ollama(model_name: str) -> ChatOpenAI: # 注意:此处ChatOllama不能放到开头去,因为会触发初始化,在非本地环境中运行的时候会报错 from langchain_ollama import ChatOllama return ChatOllama( base_url="http://localhost:11434", # deepseek 服务地址 model=model_name, # 模型名称(需提前下载) max_retries=3, api_key="", callbacks=[], ) def get_ollama_kimi() -> ChatOpenAI: model_name = "kimi-k2.5:cloud" local_ollama = get_local_ollama(model_name) return local_ollama def get_kimi() -> ChatOpenAI: # TODO: put the right kimi api key api_key = "sk-xxxxx" return ChatOpenAI( model="kimi-k2.5", api_key=api_key, base_url="https://api.moonshot.cn/v1", ) def test_model_system_prompt(m: ChatOpenAI): agent = create_deep_agent(model=m) result = agent.invoke( { "messages": [ # HumanMessage(content="不调用任何工具,告诉我当前时间"), {"role": "user", "content": "不调用任何工具,告诉我当前时间"}, SystemMessage(content=f"当前时间为{datetime.now()}"), ] } ) print(result["messages"][-1].content) for f in [ get_kimi, get_ollama_kimi, ]: print(f"正在测试模型{f.__name__}") test_model_system_prompt(f()) ``` ### Relevant log output ```shell python ollama-kimi-issue/mine.py 正在测试模型get_kimi 当前时间是 2026-03-25 16:19:40。 正在测试模型get_ollama_kimi 我无法直接获取当前时间。如果您需要查看当前时间,可以: 1. **在终端中运行**:`date` 或 `date "+%Y-%m-%d %H:%M:%S"` 2. **使用 Python**:`python3 -c "import datetime; print(datetime.datetime.now())"` 如果您允许我调用工具,我也可以帮您获取时间。 ``` ### OS _No response_ ### GPU _No response_ ### CPU _No response_ ### Ollama version _No response_
GiteaMirror added the bug label 2026-04-12 22:33:07 -05:00
Author
Owner

@rick-github commented on GitHub (Mar 25, 2026):

$ curl -s localhost:11434/v1/chat/completions -d '{
  "model":"kimi-k2.5:cloud",
  "messages":[
    {"role":"system","content":"当前时间为 '"$(date)"'"},
    {"role":"user","content":"不调用  何工具,告诉我当前时间"}
  ],"stream":false}' | jq -r '.choices[0].message.content'
根据系统信息,当前时间是:

**2026年3月25日(星期三)上午11:02:06**

时区:CET(中欧时间,UTC+1)

换算成北京时间(UTC+8)应为:**2026年3月25日 下午6:02:06**
<!-- gh-comment-id:4125254846 --> @rick-github commented on GitHub (Mar 25, 2026): ```console $ curl -s localhost:11434/v1/chat/completions -d '{ "model":"kimi-k2.5:cloud", "messages":[ {"role":"system","content":"当前时间为 '"$(date)"'"}, {"role":"user","content":"不调用 何工具,告诉我当前时间"} ],"stream":false}' | jq -r '.choices[0].message.content' 根据系统信息,当前时间是: **2026年3月25日(星期三)上午11:02:06** 时区:CET(中欧时间,UTC+1) 换算成北京时间(UTC+8)应为:**2026年3月25日 下午6:02:06** ```
Author
Owner

@weiyinfu commented on GitHub (Mar 25, 2026):

Thank you for your response. You are great !

<!-- gh-comment-id:4126294279 --> @weiyinfu commented on GitHub (Mar 25, 2026): Thank you for your response. You are great !
Author
Owner

@weiyinfu commented on GitHub (Mar 25, 2026):

@rick-github I am using the langchain framework. And I found the root reason. It's still a problem.
The input may have multi messages. The system message must be put in the first . It will ignore other system message after the user message.

curl -s localhost:11434/v1/chat/completions -d '{
"model":"kimi-k2.5:cloud",
"messages":[
{"role":"user","content":"不调用任何工具,告诉我当前时间"},
{"role":"system","content":"当前时间为 '"$(date)"'"}
],"stream":false}' | jq -r '.choices[0].message.content'

<!-- gh-comment-id:4126518584 --> @weiyinfu commented on GitHub (Mar 25, 2026): @rick-github I am using the langchain framework. And I found the root reason. It's still a problem. The input may have multi messages. The system message must be put in the first . It will ignore other system message after the user message. curl -s localhost:11434/v1/chat/completions -d '{ "model":"kimi-k2.5:cloud", "messages":[ {"role":"user","content":"不调用任何工具,告诉我当前时间"}, {"role":"system","content":"当前时间为 '"$(date)"'"} ],"stream":false}' | jq -r '.choices[0].message.content'
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#9661