[PR #5189] [Engine] opt in to answer room for short thinking replies #5338

Open
opened 2026-11-07 16:34:27 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/5189
Author: @midhatn
Created: 11/4/2026
Status: 🔄 Open

Base: main ← Head: fix/ws1-short-answer-room-20261104


📝 Commits (1)

  • e48f9c4 [Engine] allow answer room for short thinking replies

📊 Changes

3 files changed (+64 additions, -5 deletions)

View changed files

📝 docs/DETAILS.md (+1 -0)
📝 serve/server.py (+6 -5)
📝 serve/test_server.py (+57 -0)

📄 Description

Problem and result

With thinking enabled, a Qwen request with a small output limit can spend the entire limit in reasoning and return an empty visible answer. On a dual-V100 Ubuntu host using Qwen3.8-Flash-Next Unsloth UD-Q4_K_XL, two 64-token and two 180-token requests all ended this way.

This adds an opt-in config setting, short_answer_room: true, that extends the existing short-cap wrap-up to other families. It is off by default. When answer_room is enabled, thinking is on, no positive thinking budget applies, and the output cap is 48–1,023 tokens, the server reserves half the cap for the wrap-up and answer. DeepSeek-V4.1's existing behavior is unchanged. answer_room: false disables the new guard; an explicit positive budget still takes precedence.

Related: #5039. That report discusses several possible fixes; this PR takes an opt-in approach to preserve the current default.

Validation

At e48f9c4a, Windows 11, Python 3.11, with the mock engine:

  • python -m unittest serve.test_server -q: 362 tests run, 3 skipped, no failures.
  • python -m unittest serve.test_server.ThinkingBudget serve.test_dsv41.SmallCap -q: 30 tests passed.
  • python -m unittest discover -s serve -t . -p 'test_*.py' -q: 1,388 tests run, 30 skipped, no failures. The run emitted a Python ResourceWarning about an unclosed file; its origin was not investigated.
  • The added checks cover the default-off path, the opt-in wrap, an explicit budget, answer_room: false, a cap below the guard's floor, and OpenAI/Anthropic streaming. git diff --check passed.

On the dual-V100 host, the same synthetic arithmetic prompt was sent twice at each output cap with temperature zero. The retained baseline used the unmodified frontend; the candidate used this server change with short_answer_room: true, alongside the same retained tool-parser and diagnostic-telemetry frontend changes. The model, engine, context capacity, and 200 W GPU limits were the same.

Case Unmodified frontend Opt-in candidate
Default thinking, 64-token limit 0/2 visible answers; both ended at the limit 2/2 visible answers; both ended normally
Default thinking, 180-token limit 0/2 visible answers; both ended at the limit 2/2 visible answers; both ended normally

All four visible candidate answers were numerically wrong. The probe demonstrates improved visibility on this one prompt, not an accuracy fix. As controls, the explicit 96-token-budget requests were visible in both trials on each frontend; one baseline answer and no candidate answers were correct. A no-thinking control was also wrong on both. These small samples do not establish an overall accuracy comparison.

Limits and remaining checks

This remains a draft. The wrap-up itself consumes output tokens, so a very small cap may still leave no answer, and ending thinking sooner can change or worsen the answer. More tasks, caps, models, and quality checks are needed before recommending the opt-in. Passing these checks does not establish general answer accuracy or byte-for-byte output parity. No native GPU code is changed, and no performance improvement is claimed.

AI assistance was used for the diagnosis, implementation and tests.


🔄 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/Niko1221/Strata/pull/5189 **Author:** [@midhatn](https://github.com/midhatn) **Created:** 11/4/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/ws1-short-answer-room-20261104` --- ### 📝 Commits (1) - [`e48f9c4`](https://github.com/Niko1221/Strata/commit/e48f9c4a1a771499f5f3db0b395c3402d51f7f3f) [Engine] allow answer room for short thinking replies ### 📊 Changes **3 files changed** (+64 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `docs/DETAILS.md` (+1 -0) 📝 `serve/server.py` (+6 -5) 📝 `serve/test_server.py` (+57 -0) </details> ### 📄 Description ## Problem and result With thinking enabled, a Qwen request with a small output limit can spend the entire limit in reasoning and return an empty visible answer. On a dual-V100 Ubuntu host using Qwen3.8-Flash-Next Unsloth UD-Q4_K_XL, two 64-token and two 180-token requests all ended this way. This adds an opt-in config setting, `short_answer_room: true`, that extends the existing short-cap wrap-up to other families. It is off by default. When `answer_room` is enabled, thinking is on, no positive thinking budget applies, and the output cap is 48–1,023 tokens, the server reserves half the cap for the wrap-up and answer. DeepSeek-V4.1's existing behavior is unchanged. `answer_room: false` disables the new guard; an explicit positive budget still takes precedence. Related: #5039. That report discusses several possible fixes; this PR takes an opt-in approach to preserve the current default. ## Validation At `e48f9c4a`, Windows 11, Python 3.11, with the mock engine: - `python -m unittest serve.test_server -q`: 362 tests run, 3 skipped, no failures. - `python -m unittest serve.test_server.ThinkingBudget serve.test_dsv41.SmallCap -q`: 30 tests passed. - `python -m unittest discover -s serve -t . -p 'test_*.py' -q`: 1,388 tests run, 30 skipped, no failures. The run emitted a Python `ResourceWarning` about an unclosed file; its origin was not investigated. - The added checks cover the default-off path, the opt-in wrap, an explicit budget, `answer_room: false`, a cap below the guard's floor, and OpenAI/Anthropic streaming. `git diff --check` passed. On the dual-V100 host, the same synthetic arithmetic prompt was sent twice at each output cap with temperature zero. The retained baseline used the unmodified frontend; the candidate used this server change with `short_answer_room: true`, alongside the same retained tool-parser and diagnostic-telemetry frontend changes. The model, engine, context capacity, and 200 W GPU limits were the same. | Case | Unmodified frontend | Opt-in candidate | |---|---|---| | Default thinking, 64-token limit | 0/2 visible answers; both ended at the limit | 2/2 visible answers; both ended normally | | Default thinking, 180-token limit | 0/2 visible answers; both ended at the limit | 2/2 visible answers; both ended normally | **All four visible candidate answers were numerically wrong.** The probe demonstrates improved visibility on this one prompt, not an accuracy fix. As controls, the explicit 96-token-budget requests were visible in both trials on each frontend; one baseline answer and no candidate answers were correct. A no-thinking control was also wrong on both. These small samples do not establish an overall accuracy comparison. ## Limits and remaining checks This remains a draft. The wrap-up itself consumes output tokens, so a very small cap may still leave no answer, and ending thinking sooner can change or worsen the answer. More tasks, caps, models, and quality checks are needed before recommending the opt-in. Passing these checks does not establish general answer accuracy or byte-for-byte output parity. No native GPU code is changed, and no performance improvement is claimed. AI assistance was used for the diagnosis, implementation and tests. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#5338
No description provided.