Skip to content

Blocking chat reply nulls content and drops the rest of the answer when it opens with a refusal prefix (streamed path keeps it) #172

Closed

Description

@pulseandthread

Found while measuring refusal rates on GLM-5.3-Flash (two DGX Sparks, Enntity pin 72588541; file:line references below are against that tree, our fork at github.com/pulseandthread/atlas branch living has the same files unchanged).

What happens

In the blocking chat completion, when the answer text (after </think>) opens with one of 23 refusal prefixes, the first sentence is moved into message.refusal, message.content is set to null, and the rest of the answer is not returned. The streamed path sends every content piece and only appends a refusal delta at the end, so the same prompt gives a full answer when streamed and an empty content when not.

  • Classifier: crates/spark-server/src/refusal.rs:24-48 (the 23 prefixes, matched on the first 48 characters, lower-cased), :63-69, :72-86.
  • Blocking reply: crates/spark-server/src/api/chat_blocking_choice.rs:165-171 (content nulled, first sentence to refusal).
  • Streaming: crates/spark-server/src/api/chat_stream/handle_token.rs:691-698 (all pieces sent), chat_stream/done_finalization.rs:42-51 (refusal delta at the end).

Measured cost

On 200 held-out prompts from the public Arditi et al. refusal_direction splits (100 "harmful", 100 "harmless"), official nvidia/GLM-5.3-Flash-NVFP4, reasoning_effort: "low", greedy, max_tokens 1024, blocking vs streamed, same server:

  • 27 of 200 blocking replies came back with content: null and finish_reason: "stop"; all 27 had refusal set; all were on the "harmful" split. Streamed, all 200 had content.
  • Of replies whose answer opened with a listed prefix: 32 of 32 were nulled. Of replies whose answer opened without one: 82 of 82 came through intact. So the trigger is the prefix match, not the think state.
  • A client that reads only content (most do, for non-structured chat) loses about a quarter of the answers on this kind of prompt. Our first two measurement runs were wrong for exactly this reason.

The prefix list also cannot tell a refusal from sympathy: an answer that begins with "I'm sorry" for any reason is filed as a refusal and cut to one sentence.

Two related behaviours, for completeness (both documented, both surprised us)

  • /v1/completions runs with thinking off (api/completions.rs:334, completions_exec.rs:106), and a </think> emitted after the first token is dropped by scheduler/emit_step.rs:115-130. A completions call with the chat template's think-open prompt therefore never closes its reasoning. Expected once read, but worth a line in the completions docs.
  • Chat at reasoning_effort: "low" caps thinking at half of max_thinking_budget (128 of 256 here, api/chat/thinking.rs:155-171) and forces </think> at the next sentence end, at most 64 tokens later (logit_processors/forced_think_end.rs:35-65, confidence.rs:76).

Suggestion

Keep the full text in content and set refusal beside it, and/or run the classifier only when the request asked for structured output (the case the OpenAI refusal field exists for). That also makes blocking and streaming agree. We measured; we have not patched it.

Reproduction

Send any prompt whose answer begins with "I'm sorry, but" or "I can't help with" to /v1/chat/completions with stream: false, then with stream: true; compare content. Our measurement tooling (prompt rendering, five-outcome scoring, the parity check between blocking and streamed) is in github.com/pulseandthread/living-steer (tools/refusal_parity.py), published shortly.

Activity

  1. maplepaladin73 commented on Oct 21, 2026

    @maplepaladin73
    Contributor

    Checked this on our side. Two GB10s at TP=2, Qwen3.8-Flash-Next FP4-Local, thinking off, temperature 0, max_tokens 300. Each prompt was sent with stream: false and then stream: true.

    What we could test live: our production engine is the Enntity fidelity build (image 4618128c570b), not Atlas main. On that build, blocking and streamed replies are identical on all 5 prompts. Content is never nulled.

    • "I can't help with that request, but here are two tips for..." matches a prefix. refusal is set in both modes (to the whole one-sentence answer), and content is kept in full in both.
    • "I'm sorry, but the sky appears blue...", "I'm sorry for your loss...", "I'm sorry for the confusion..." and a control prompt don't match any prefix, so there's no refusal and the full content comes back in both modes.

    Main (4f2e3963) still has the behavior you describe: chat_blocking_choice.rs:152-160 sets msg_content = None whenever refusal::detect matches and no tool call fired. We didn't take a test window on main for this, so that part is from reading the code, not a measured run.

    One correction to the issue text: a bare "I'm sorry" doesn't trigger the classifier. The sorry-type prefixes in refusal.rs all need a can't/cannot after them ("i'm sorry, but i can't", "sorry, but i cannot", ...). Answers that open with plain sympathy come through intact. The prefixes that do misfire on benign answers are the broad ones: "i cannot ", "i'm not able to ", "i'm unable to ". For example, "I cannot stress enough how..." would be nulled on main.

    +1 to your suggestion: keep content and set refusal beside it. That's what the Enntity build already does, and blocking and streaming match there. ATLAS_DISABLE_REFUSAL_DETECTION=1 is the workaround on main until then.

  2. AzeezIsh commented on Oct 27, 2026

    @AzeezIsh
    Contributor

    Fix #205 rides integration train #212, which is being gated on GB10 FP4-Local now and merges once agentic-webserver 50 + BFCL ST-995 pass. Gate evidence for #205 alone (main + #205 + #206): BFCL 87.44 / 87.32 and agentic 50/50, 12.34 s/turn (run-1792760075267807876, run-1792764782219366004).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions