ITADN
simonw/llm/Issues

llm@0.32a2 ignores system prompt when tools are registered

#1478Openniallsmart 创建于 2026-06-08
N
niallsmartcommented
**Issue** The current alpha releases (0.32a) of the llm CLI don't use the system prompt when tools are registered. **Steps To Reproduce** Run `llm` from the terminal using both `-s` and `-T` and observe the system prompt is not followed. For example: ```bash LLM_OPENAI_SHOW_RESPONSES=1 uvx --prerelease allow llm@latest \ --no-stream -s 'speak like a pirate' -T llm_version hi ``` **Why It's Happening** When tools are registered, the LLM CLI uses `#chain` instead of `#prompt` https://github.com/simonw/llm/blob/be27b91aa83142ee080c467976dc47fa4b5fb7ec/llm/cli.py#L883-L884 The various implementations of `chain` use `_BaseConversation#_build_full_chain` to build the message list, and pass it to `Prompt#__init__`, where it's stored as `self._explicit_messages`. However `_build_full_chain` never includes the system prompt, and `Prompt#messages` has an early-return when `self._explicit_messages` is set. As a result `prompt.messages` never contains the system prompt. Since the OpenAI and Anthropic connectors attempt to extract the system prompt from `prompt.messages` (not `prompt.system`) the API level traffic never contains a system prompt.
0 条评论