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.
This commit is contained in:
@@ -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}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user