Skip to content

test: pin the enable_thinking precedence (top-level, kwarg, --thinking) - #271

Merged
solderzzc merged 1 commit into
SharpAI:mainfrom
HamedShams:test/thinking-precedence
Nov 16, 2026
Merged

solderzzc merged 1 commit into
SharpAI:mainfrom
HamedShams:test/thinking-precedence

Conversation

@HamedShams

Copy link
Copy Markdown
Contributor

Closes #263.

The order for enable_thinking (top-level field, then chat_template_kwargs, then --thinking) was written inline in the chat handler, so no test could see it. As the issue says, you could swap two of its branches and everything stayed green.

What changed:

  • The decision moved into a small pure function, resolveThinking(topLevel:kwarg:serverFlag:), and the handler just calls it. No behaviour change.
  • ThinkingPrecedenceTests (4 tests) covers each branch. Every case gives the lower levels the opposite value, including the conflict where the top-level field has to win over the kwarg.
  • tests/test-contract.sh gets block 19 with the same conflict end to end, both ways, plus a kwarg that beats --thinking. The CI model's template ignores enable_thinking, so the block reads the verdict from the slot_launch ... thinking= line the server logs, the way block 15 already reads the log.

To be sure it really guards the order, I swapped the first two branches locally: the conflict test fails and block 19 fails 2 of its 3 checks. Put back, everything passes.

swift test --filter SwiftLMTests: 369 tests, 0 failures. Contract suite against the CI model: 35 passed, 0 failed, 2 skipped (the two usual skips for the tiny model).

The order sat inline in the chat handler where no test saw it. It is now resolveThinking, with a unit test per branch and a contract block for the conflicting case.

Closes SharpAI#263.
@solderzzc
solderzzc merged commit dc59295 into SharpAI:main Nov 16, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test: cover enable_thinking precedence (top-level > kwarg > --thinking) at handler level

2 participants