Skip to content

Commit b667812

Browse files
committed
fix: scope reasoning_effort=none to non-OpenAI targets, fix review findings
reasoning_effort="none" was being sent unconditionally to every OpenAI-compatible server, including real api.openai.com, where it is rejected by most current reasoning models. Gate it behind self._server_type != _ServerType.OPENAI on the OpenAI backend and the existing Ollama-provider-prefix check on the LiteLLM backend, matching the mechanism each backend already uses for equivalent divergence. Also, from the same review pass: - Add granite-4.2 entries to BASE_MODEL_TO_CANONICAL_NAME so intrinsic adapter-path resolution stays consistent with the 4.0/4.1 siblings. - Update onboarding docs (quickstart, installation, troubleshooting, tutorials, examples index) that still told new users to pull granite4.1:3b, now stale since start_session()'s default moved to granite4.2:3b. - Fix the CI context-window guard to check the exact num_ctx value instead of just line presence, so a silently-failed re-point to 8192 is actually caught. - Replace the test asserting the raw "max_tokens" key reaches the wire unmapped (it doesn't — both backends remap it to ModelOption.MAX_NEW_TOKENS and back out to max_completion_tokens regardless) with one that reflects actual behaviour. - Stop test_reasoning_effort_conditional_passing from being confounded by the shared fixture's default_extra_body, which forced enable_thinking=False regardless of what the mapping code did. - Fix test_thinking_false_sets_reasoning_effort_none_and_disable in test_litellm_thinking.py, which had been flipped to assert the regression itself against a vLLM target; split it into a non-Ollama case (reasoning_effort absent) and a new Ollama-routed case (sent). Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]>
1 parent 2ce9ea3 commit b667812

17 files changed

Lines changed: 173 additions & 56 deletions

File tree

‎.github/workflows/quality.yml‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,10 @@ jobs:
195195
printf 'FROM granite4.2:3b-128k\nPARAMETER num_ctx 8192\n' \
196196
> /tmp/MODELFILE-granite42-ci
197197
ollama create granite4.2:3b -f /tmp/MODELFILE-granite42-ci
198-
# grep exits non-zero (failing the step) if the parameter did not
199-
# land, so a silently-wrong build cannot pass CI.
200-
ollama show granite4.2:3b --modelfile | grep '^PARAMETER'
198+
# grep exits non-zero (failing the step) if num_ctx did not land at
199+
# exactly 8192 — matching only '^PARAMETER' would still pass on the
200+
# base tag's untouched 131072 value if `ollama create` silently no-oped.
201+
ollama show granite4.2:3b --modelfile | grep -qx 'PARAMETER num_ctx 8192'
201202
- name: Run Tests
202203
id: tests
203204
env:

‎docs/docs/examples/index.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,4 @@ uv run docs/examples/<folder>/<file>.py
130130

131131
**Default backend:** `start_session()` with no arguments connects to a local
132132
[Ollama](https://ollama.ai) instance running **IBM Granite 4 Micro**
133-
(`granite4.1:3b`). Make sure Ollama is running before you execute any example.
133+
(`granite4.2:3b`). Make sure Ollama is running before you execute any example.

‎docs/docs/getting-started/installation.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,5 @@ The default session connects to [Ollama](https://ollama.ai) running locally.
6262
Install Ollama and pull the default model before running any examples:
6363

6464
```bash
65-
ollama pull granite4.1:3b
65+
ollama pull granite4.2:3b
6666
```

‎docs/docs/getting-started/quickstart.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ description: "Run your first generative program in minutes."
1010
## Hello world
1111

1212
By default, `start_session()` connects to Ollama and uses **IBM Granite 4 Micro**
13-
(`granite4.1:3b`). Make sure Ollama is running before you run this:
13+
(`granite4.2:3b`). Make sure Ollama is running before you run this:
1414

1515
```python
1616
import mellea
@@ -205,7 +205,7 @@ Hugging Face, and WatsonX are also supported. See
205205

206206
## Troubleshooting
207207

208-
**`granite4.1:3b` not found** — run `ollama pull granite4.1:3b` before starting.
208+
**`granite4.2:3b` not found** — run `ollama pull granite4.2:3b` before starting.
209209

210210
**Python 3.13 `outlines` install failure** — `outlines` requires a Rust compiler.
211211
Either install [Rust](https://www.rust-lang.org/tools/install) or pin Python to 3.12.

‎docs/docs/troubleshooting/common-errors.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ description: "Common errors, diagnostic steps, and fixes for Mellea programs."
66

77
## Installation
88

9-
### `granite4.1:3b` not found
9+
### `granite4.2:3b` not found
1010

1111
```text
12-
Error: model "granite4.1:3b" not found
12+
Error: model "granite4.2:3b" not found
1313
```
1414

1515
Pull the model before running:
1616

1717
```bash
18-
ollama pull granite4.1:3b
18+
ollama pull granite4.2:3b
1919
```
2020

2121
### Python 3.13: `outlines` install failure

‎docs/docs/troubleshooting/faq.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ m = MelleaSession(
3838
)
3939
```
4040

41-
## How do I use a model other than `granite4.1:3b`?
41+
## How do I use a model other than `granite4.2:3b`?
4242

4343
Pass the `model_id` parameter to `start_session()`:
4444

‎docs/docs/tutorials/01-your-first-generative-program.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ By the end you will have covered:
2020
> see [Tutorial 03: Using Generative Stubs](../tutorials/using-generative-stubs).
2121
2222
**Prerequisites:** [Quick Start](../getting-started/quickstart) complete,
23-
Mellea installed (`uv add mellea`), Ollama running locally with `granite4.1:3b` downloaded.
23+
Mellea installed (`uv add mellea`), Ollama running locally with `granite4.2:3b` downloaded.
2424

2525
---
2626

‎docs/docs/tutorials/02-streaming-and-async.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ By the end you will have covered:
1616
- Context behaviour with concurrent async calls
1717

1818
**Prerequisites:** [Tutorial 01](./your-first-generative-program) complete,
19-
`pip install mellea`, Ollama running locally with `granite4.1:3b` downloaded.
19+
`pip install mellea`, Ollama running locally with `granite4.2:3b` downloaded.
2020

2121
---
2222

‎docs/docs/tutorials/03-using-generative-stubs.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ By the end you will have covered:
1616
- Precondition and postcondition validation patterns
1717

1818
**Prerequisites:** [Tutorial 01](./your-first-generative-program) complete,
19-
`pip install mellea`, Ollama running locally with `granite4.1:3b` downloaded.
19+
`pip install mellea`, Ollama running locally with `granite4.2:3b` downloaded.
2020

2121
---
2222

‎mellea/backends/litellm.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,11 +402,14 @@ async def _generate_from_chat_context_standard(
402402
extra_params["extra_body"] = ctk_body
403403
if thinking:
404404
reasoning_params["reasoning_effort"] = "medium"
405-
else:
405+
elif "ollama" in self._model_id.split("/")[0]:
406406
# Ollama-served thinking models (e.g. granite4.2) default to
407407
# thinking ON when reasoning_effort is absent; "none" is the
408408
# OpenAI enum value their /v1 endpoint maps to think=false
409-
# (Ollama >= 0.33.1).
409+
# (Ollama >= 0.33.1). Real OpenAI/other reasoning providers
410+
# reject "none", so this is scoped to Ollama-routed models
411+
# (same provider-prefix check used for the streaming
412+
# tool-call workaround above).
410413
reasoning_params["reasoning_effort"] = "none"
411414
else:
412415
reasoning_params["reasoning_effort"] = thinking

0 commit comments

Comments
 (0)