From 80adeda937394061e5efc2dab276fa8eb8eae0db Mon Sep 17 00:00:00 2001 From: Alexandre Teixeira <111787685+alteixeira20@users.noreply.github.com> Date: Sat, 3 Oct 2026 04:02:59 +0100 Subject: [PATCH] fix(agent): honor explicit no-web requests --- src/agent_loop.py | 5 +++++ tests/test_runtime_behavior_regressions.py | 9 +-------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/agent_loop.py b/src/agent_loop.py index 86c3418c2..091b33323 100644 --- a/src/agent_loop.py +++ b/src/agent_loop.py @@ -8647,6 +8647,11 @@ def _web_search_unavailable_for_turn( """ if "web" not in set(intent_domains or ()): return False + # Mentioning web only to forbid its use is not affirmative web demand. + # Keep the web tools disabled, but let the normal model-only path answer + # instead of claiming the request cannot proceed without web access. + if _explicitly_avoids_web_lookup(text): + return False # A turn is unavailable only when every public-web route is disabled. # Exact-URL turns intentionally expose web_fetch while keeping broad # web_search disabled; the former intersection check incorrectly diff --git a/tests/test_runtime_behavior_regressions.py b/tests/test_runtime_behavior_regressions.py index ed860dc23..73f9852c3 100644 --- a/tests/test_runtime_behavior_regressions.py +++ b/tests/test_runtime_behavior_regressions.py @@ -146,15 +146,8 @@ def test_negative_web_wording_withholds_the_web_tools(monkeypatch, phrasing): _assert_negative_web_turn(monkeypatch, phrasing) -@pytest.mark.xfail( - strict=True, - raises=_MemoryOnlyTurnBlocked, - reason="negative web wording is recognized but the memory-only turn is " - "misclassified as web-dependent and blocked before the model call; " - "production intent/short-circuit correction is outside test isolation", -) @pytest.mark.parametrize("phrasing", BLOCKED_MEMORY_ONLY) -def test_negative_web_wording_withholds_the_web_tools_unhandled(monkeypatch, phrasing): +def test_negative_web_wording_withholds_the_web_tools_memory_only(monkeypatch, phrasing): _assert_negative_web_turn(monkeypatch, phrasing)