test: add integration-level test coverage for ModelOption.THINKING on OllamaModelBackend - #1613
Merged
Merged
Conversation
Covers per-call suppression, per-call enablement, and construction-time default suppression against a real Ollama model, closing the gap where only mocked unit tests existed for this behaviour. Fixes generative-computing#1553 Assisted-by: Claude Code Signed-off-by: Nigel Jones <jonesn@uk.ibm.com>
Code-review NIT/SUGGESTION follow-up: note why test_thinking_enabled_mot_field_nonempty is slow while its THINKING=False siblings aren't. Assisted-by: Claude Code Signed-off-by: Nigel Jones <jonesn@uk.ibm.com>
Second review round (qwen) follow-up: - Extract _start_ollama_session() so session and thinking_on_session share construction instead of duplicating it (was a verbatim clone with one flag flipped, risking silent divergence). - Move thinking_on_session next to session so the module's fixtures stay grouped, per test/README.md fixture-discipline guidance. - Split test_thinking_enabled_mot_field_nonempty's docstring into a single behavioural claim (test/README.md: one claim per test). - Include the resolved model id in the assertion message so a failure distinguishes plumbing regressions from a non-thinking model/runtime. - Document in-code why the slow-marked positive test is invisible to PR CI and the nightly script (both inherit pyproject.toml's default `-m "not slow"`), so the gap is visible without relying on a PR body. Assisted-by: Claude Code Signed-off-by: Nigel Jones <jonesn@uk.ibm.com>
quality.yml pulls granite4.2:3b, granite4:micro-h, and the granite-vision-4.1-4b GGUF — the doc still said granite4:micro and omitted the vision model. Assisted-by: Claude Code Signed-off-by: Nigel Jones <jonesn@uk.ibm.com>
The prior comment stated the nightly script never runs the slow test as fact. That's only verified for PR CI (quality.yml has no -m override) — the nightly script committed here has the same default, but is invoked by an external nightly.py not in this repo, so whether it passes -m slow is unverified, not ruled out. Assisted-by: Claude Code Signed-off-by: Nigel Jones <jonesn@uk.ibm.com>
psschwei
reviewed
Sep 8, 2026
| # think-block capture itself (the THINKING=False tests would pass vacuously in | ||
| # that case). A regression in the merge/override plumbing is still caught by | ||
| # the other two. | ||
| @pytest.mark.slow # generates a full think block, unlike its THINKING=False siblings |
Member
There was a problem hiding this comment.
fwiw, Claude did not like marking this as a "slow" test, saying that even though it took twice as long as the other tests, it still finished in under a second (at least when claude ran it). Good chance that Claude is being overly literal about the slow, but passing that feedback along.
Contributor
Author
There was a problem hiding this comment.
Confirmed — measured 0.83s. Dropped the marker, thanks.
markstur
approved these changes
Sep 9, 2026
markstur
left a comment
Contributor
There was a problem hiding this comment.
LGTM, see inline for one readability nit
|
|
||
|
|
||
| @pytest.fixture(scope="function") | ||
| def thinking_on_session(): |
Contributor
There was a problem hiding this comment.
I think this would read better if s/thinking_on_session/thinking_session/
but author's choice
…dability test_thinking_enabled_mot_field_nonempty runs in 0.83s (measured against a live granite4.2:3b Ollama call) — nowhere near the >1 minute threshold test/README.md documents for `slow`. It now runs in default/PR CI like its siblings, and the CI-blind-spot comment justifying the marker is removed along with it. Also renames the thinking_on_session fixture to thinking_session per review nit (redundant "on"). Assisted-by: Claude Code Signed-off-by: Nigel Jones <jonesn@uk.ibm.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Issue
Fixes #1553
Description
ModelOption.THINKINGwas only tested against a mocked backend — nothingexercised it against a live model. That's a real gap: structured-output
examples using
@generativestubs can intermittently fail because the parserreceives combined think+answer text, and only
THINKING: Falsesuppressionprevents it. Nothing was guarding that suppression from silently regressing.
Adds three live-model tests to
test/backends/test_ollama.py:test_thinking_suppressed_per_callTHINKING: Falseoverrides aTHINKING: Trueconstruction-time defaulttest_thinking_enabled_mot_field_nonemptyTHINKING: Trueoverrides aTHINKING: Falseconstruction-time default (slow— generates a real think block)test_construction_time_thinking_default_suppressesTHINKING: Falseholds with no per-call overrideEach override test flips the construction-time default in the opposite
direction from what it sets per-call, so it's actually falsifiable rather than
just agreeing with the default.
Known gap, documented in-line:
pyproject.toml's defaultaddoptsexcludes
slowtests. Verified: PR CI (quality.yml) never overrides-m, so it never runs the positive-direction test. Unverified: thenightly script committed in this repo also has no override by default, but
it's driven by an external
nightly.pynot present here — I can't confirmwhether that driver passes
-m slow, so nightly coverage is unknown ratherthan ruled out. Worth a maintainer confirming.
A regression in think-block capture itself would only be caught by that one
test; a regression in the override plumbing is still caught by the other two
on every CI run. I ran the positive test manually for this PR (see Testing) —
that's its only verification unless nightly does invoke
-m slow.Also included: a one-line fix for
test/README.md's stale CI model list(said
granite4:micro;quality.ymlactually pullsgranite4.2:3b+granite4:micro-h+ the vision GGUF) — found while verifying the gap above.Testing
Both run live against a warm
granite4.2:3bon Ollama 0.33.2.ruff format --check,ruff check, andmypyall clean.Attribution
Adding a new component, requirement, sampling strategy, or tool?
If your PR adds or modifies one of the types below, check the matching box. A checklist of type-specific review items will be posted as a comment.
NOTE: Please ensure you have an issue that has been acknowledged by a core contributor and routed you to open a pull request against this repository. Otherwise, please open an issue before continuing with this pull request.