Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

## [Unreleased]

### Fixed

- **Custom provider model ids with nested Gemini gateway routes (e.g. `vertex/gemini-…`, `gemini_cli/gemini-…`) now expose the reasoning effort selector when the underlying model supports thinking.** Extends the heuristic fallback used for bare and dot-separated custom names; embedding and image-only Gemini routes stay excluded. OpenRouter-style `x-ai/…` ids continue to use the existing slash-prefix list.

## [v0.51.406] — 2026-06-14 — Release NS (project-context file in the Memory tab, #3866)

### Added
Expand Down
36 changes: 36 additions & 0 deletions api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2482,6 +2482,37 @@ def _candidate_supports_reasoning(candidate: str) -> bool:
return False


def _nested_route_reasoning_denied(model: str) -> bool:
"""Hard deny for nested Gemini gateway routes that must never show a reasoning toggle."""
lower = str(model or "").strip().lower()
if not lower:
return False
for prefix in ("vertex/gemini-", "gemini_cli/gemini-"):
if lower.startswith(prefix):
tail = lower[len(prefix) :]
if tail.startswith("embedding") or "image" in tail or "imagine" in tail:
return True
return False


def _nested_gateway_route_reasoning(model: str) -> bool:
"""Recognize nested ``vertex/gemini-`` and ``gemini_cli/gemini-`` routes on custom providers.

The slash-prefix heuristic list includes ``google/gemini-2`` but not gateway-prefixed
Gemini ids, so capable models behind custom aggregators stayed hidden.
"""
lower = str(model or "").strip().lower()
if not lower:
return False
for prefix in ("vertex/gemini-", "gemini_cli/gemini-"):
if lower.startswith(prefix):
tail = lower[len(prefix) :]
if tail.startswith("embedding") or "image" in tail or "imagine" in tail:
return False
return True
return False
Comment on lines +2485 to +2513

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Duplicated exclusion criteria between the two helpers

_nested_route_reasoning_denied and _nested_gateway_route_reasoning each independently define the same embedding/image/imagine exclusion logic. If a new exclusion pattern (e.g. "audio") is added to _nested_gateway_route_reasoning but not to _nested_route_reasoning_denied, the early-deny guard in resolve_model_reasoning_efforts — which exists specifically to override registry false positives from _models_dev_reasoning_efforts — would silently fail to fire for that new pattern. Extracting the exclusion predicate into a single shared helper (e.g. _is_gemini_non_reasoning_tail(tail)) called by both functions would remove the coupling.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!



def _filter_reasoning_efforts_for_provider(
efforts: list[str],
model_id: str,
Expand Down Expand Up @@ -2535,6 +2566,8 @@ def _heuristic_reasoning_efforts(model_id: str, provider_id: str) -> list[str]:
)
if any(model.startswith(prefix) for prefix in prefixes):
return list(VALID_REASONING_EFFORTS)
if _nested_gateway_route_reasoning(model):
return list(VALID_REASONING_EFFORTS)
# Named custom providers often rewrite model ids with dots, underscores, or
# extra vendor namespaces. Normalize those shapes before applying family-level
# reasoning heuristics so "deepseek.v3.2", "deepseek_v4_flash", and
Expand Down Expand Up @@ -2602,6 +2635,9 @@ def resolve_model_reasoning_efforts(

hinted_model = _strip_provider_hint_for_reasoning(model)

if _nested_route_reasoning_denied(hinted_model):
return []

try:
from hermes_cli.models import (
github_model_reasoning_efforts,
Expand Down
35 changes: 35 additions & 0 deletions tests/test_custom_provider_bare_model_reasoning.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,38 @@ def test_deepseek_non_reasoning_variants_excluded(model_id):
)


# ── custom provider nested Gemini routes (vertex/, gemini_cli/) ───────────────


@pytest.mark.parametrize(
"model_id",
[
"vertex/gemini-3.1-pro-preview",
"vertex/gemini-3-pro-preview",
"gemini_cli/gemini-3-pro-preview",
],
)
def test_custom_nested_gemini_routes_expose_reasoning(model_id):
efforts = cfg.resolve_model_reasoning_efforts(
model_id,
provider_id="custom:newapi",
)
assert set(efforts) >= {"low", "medium", "high"}, (
f"{model_id} via custom:newapi should expose reasoning efforts"
)


@pytest.mark.parametrize(
"model_id",
[
"vertex/gemini-embedding-001",
"vertex/gemini-3-pro-image-preview",
],
)
Comment on lines +272 to +278

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 The negative parametrization only exercises the vertex/ branch of _nested_route_reasoning_denied; the gemini_cli/ branch is never exercised in the deny path. A regression that accidentally removed "gemini_cli/gemini-" from the deny loop would not be caught by these tests.

Suggested change
@pytest.mark.parametrize(
"model_id",
[
"vertex/gemini-embedding-001",
"vertex/gemini-3-pro-image-preview",
],
)
@pytest.mark.parametrize(
"model_id",
[
"vertex/gemini-embedding-001",
"vertex/gemini-3-pro-image-preview",
"gemini_cli/gemini-embedding-001",
"gemini_cli/gemini-3-pro-image-preview",
],
)

def test_custom_nested_gemini_routes_exclude_non_reasoning(model_id):
assert cfg.resolve_model_reasoning_efforts(
model_id,
provider_id="custom:newapi",
) == [], f"{model_id} must not expose reasoning efforts"


Loading