An app on LM Studio's server gets replies ignoring its system prompt — how does lms log stream show what the model received?
answer
- see the string, not the request
- after the chat template
- model source is the default
- --filter input or output
- live only: attach before sending
basics
~20 slms log stream prints, for each prediction made while it is attached, the model identifier and the exact formatted input string, then the output, so you can see whether the system text survived the request and the chat template.
solid answer
~50 s`lms log stream` subscribes to LM Studio's diagnostic log and, with the default `--source model`, prints every prediction's **input** (the model identifier, the model path and the fully formatted prompt string, after the chat template has been applied) and its **output** once the message completes. `--filter input` narrows it to prompts, `--filter output` to replies, `--json` emits one JSON object per line for tooling, and `--stats` adds prediction stats. It is a **live** stream, so start it in a second terminal before you resend the request. Then read the input: if the system text is missing, the client or a framework dropped it; if it is present but placed oddly, the template is the suspect; if the identifier is not the one you expected, the request hit another model. `--source server` (since LM Studio 0.3.26) streams server logs instead.
go deeper
Remember that lms log stream shows the exact text sent to and received from the model, and that you start it before sending the request you want to see.
Explain the step from messages to one templated string, and use --filter input to tell a client that dropped the system message from a template that misplaced it.
Show a debugging order for prompt-level failures: confirm the target identifier, read the formatted input, then blame the template or the model, and use --json output in integration tests.
Argue for capturing formatted prompts in test runs of local-model features, so template or framework changes that alter the prompt are caught before users see different behaviour.
## The gap between a request and a prompt A client sends LM Studio a structured request: a list of messages with roles, perhaps tools, perhaps sampling settings. A language model does not read JSON. Before inference, LM Studio turns the messages into **one string** using the model's **chat template**, the formatting rules that wrap each role in the special tokens the model was trained on. When a reply "ignores the system prompt", the cause can sit at any step of that chain: 1. the client never sent a system message (a framework default, a bug, a wrong field); 2. the request reached a different model than you think; 3. the template placed the system text somewhere the model does not treat as instructions, or folded it into the first user turn; 4. the model saw it and simply did not follow it. Only the formatted string tells you which. Request logs on the client side show step 1 at best. ## What `lms log stream` prints `lms log stream` connects to the running LM Studio instance (the desktop app or llmster) and subscribes to its diagnostic events. With the default source, model, each prediction produces: - an **input** event with `modelIdentifier`, `modelPath` and the formatted `input` string, the exact string LM Studio sends to the model; - an **output** event with the generated text, emitted once the message completes, plus stats when you pass `--stats`. | Invocation | What you see | |---|---| | `lms log stream` | input and output of every prediction (default `--source model`) | | `lms log stream --source model --filter input` | only the formatted prompts | | `lms log stream --source model --filter output --stats` | replies with prediction stats | | `lms log stream --source model --filter input,output --json` | newline-separated JSON for tooling | | `lms log stream --source server` | the server's own log lines | `--filter` and `--stats` only make sense with the model source; the `lms` source rejects them with `--source server`. Multiple sources and the filters arrived in LM Studio 0.3.26. ## Reading the evidence Put the stream in one terminal and replay the failing request from the app in another. Then: - **No system text in the input.** The fault is upstream of LM Studio. Fix the client or the framework that builds the messages. - **System text present, wrapped strangely or merged into the user turn.** The model's template is the suspect; compare with the template's expected roles, and try the same messages against another build of the model. - **Unexpected `modelIdentifier`.** The request named another model, or an identifier you did not mean; check what the client sends in its `model` field against `lms ps`. - **Everything looks right.** The model is not following the instruction; that is a prompt or model-choice problem, not plumbing. The same view settles other arguments: whether a tool definition actually reached the prompt, how long the rendered conversation history has grown, whether a stop string appears in the output. ## Things the stream is not - It is **not history**. It shows predictions made while it is attached; start it before reproducing. - It is **not the HTTP request**. It shows what the model received after formatting, which is the point. - It does not change the request. It observes the prediction; the client, the template and the model behave as they would without it. ## A worked diagnosis Suppose a coding assistant sends a system message telling the model to answer only with code, and the replies keep chatting. With the stream attached you resend once and read the input event. Three outcomes are common: - the formatted input starts straight at the user's text, so the extension never sent the system message and the fix is in its settings; - the input carries the instruction inside the template's system section, so the plumbing is fine and the model or the instruction's wording is the problem; - the input belongs to an identifier you did not expect, because the extension named a different model and the server loaded that one instead. Each outcome points to a different owner, which is why the formatted prompt is the first thing to look at rather than the last. ## Using it in automation `--json` turns the stream into a feed that a small script can tail during an integration test: assert that every input contains the expected system marker, or record outputs alongside the formatted prompts that produced them. Because the stream writes one JSON object per line, standard line-oriented tools can consume it while the test runs.
- How would you confirm that a tool definition your client sends actually reaches the model?Run `lms log stream --source model --filter input` and send the request. The formatted input shows whether the tool's name, description and parameters were rendered into the prompt; if they are absent, the client or the route dropped them before inference.
- Why read the formatted input rather than the HTTP request body when debugging this?The body shows what the client meant; the formatted input shows what the model got after LM Studio applied the chat template. Problems with role placement or merged system text only exist in the second.
- lms log stream replays requests that finished before you started it
- lms log stream shows the raw JSON request body
- --stats works with --source server
- If the client sent a system message, the model must have seen it
- --source server is the default and shows prompts
Assumes LM Studio 0.3.26 or newer, which added the --source and --filter options to lms log stream.