From a1bccf3344bf2117fe9160abfb2fe31bf27e941c Mon Sep 17 00:00:00 2001 From: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com> Date: Tue, 6 Oct 2026 11:57:52 +0530 Subject: [PATCH] fix(agent): accept only a real bool provider-level answer_in_reasoning Gate C11 r4 quality: the `flags &= {True, False}` set filter let YAML `1` count as an opt-in because 1 == True in a set. Keep only bool values so a stray 1/0 never promotes private reasoning. New parametrize row (acme-int, value 1) is red without this. --- agent/reasoning_promotion.py | 4 ++-- tests/agent/test_empty_terminal_reasoning_surface.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/agent/reasoning_promotion.py b/agent/reasoning_promotion.py index 309ac62214..ad5d8fd6c5 100644 --- a/agent/reasoning_promotion.py +++ b/agent/reasoning_promotion.py @@ -58,8 +58,8 @@ def answer_in_reasoning_capability(agent: Any) -> bool: entries = list(_entries_for_route(base_url, custom_providers, None)) live = [e for e in entries if custom_provider_slug(str(e.get("name") or ""), str(e.get("provider_key") or "")) in ids] - flags = {(e.get("capabilities") or {}).get(_ANSWER_IN_REASONING_CAPABILITY) for e in live or entries} - flags &= {True, False} + flags = {v for e in live or entries + if isinstance(v := (e.get("capabilities") or {}).get(_ANSWER_IN_REASONING_CAPABILITY), bool)} if flags: return flags == {True} diff --git a/tests/agent/test_empty_terminal_reasoning_surface.py b/tests/agent/test_empty_terminal_reasoning_surface.py index 6b55aa0443..8f19c0decc 100644 --- a/tests/agent/test_empty_terminal_reasoning_surface.py +++ b/tests/agent/test_empty_terminal_reasoning_surface.py @@ -34,6 +34,7 @@ _OPTED_IN_PROVIDERS = [ {"name": "acme", "base_url": "https://llm.example.com/v1", "model": "acme/reasoner", "capabilities": {"answer_in_reasoning": True}}, {"name": "acme-plain", "base_url": "https://llm.example.com/v1"}, # same endpoint, no opt-in + {"name": "acme-int", "base_url": "https://int.example.com/v1", "capabilities": {"answer_in_reasoning": 1}}, # not a bool ] @@ -191,6 +192,7 @@ def test_length_cut_reasoning_is_not_promoted(tmp_path, monkeypatch): ("custom", "https://llm.example.com/v1", "acme/after-model-switch", "private thoughts that must not be shown", 1), ("custom", "https://fallback.example.com/v1", "acme/reasoner", "the visible answer", 2), (("custom", "custom:acme-plain"), "https://llm.example.com/v1", "acme/reasoner", "the visible answer", 2), + ("custom:acme-int", "https://int.example.com/v1", "acme/reasoner", "the visible answer", 2), ]) def test_reasoning_promotion_requires_a_trusted_route(tmp_path, monkeypatch, provider, base_url, model, final, calls): """Private reasoning on an untrusted route retries to the visible answer and never