The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor: drop the dead _vision_supported flag
kshitijk4poor28a75285c4df
diff --git a/agent/turn_context.py b/agent/turn_context.pyindex 1a86573d538..3492e7f1865 100644--- a/agent/turn_context.py+++ b/agent/turn_context.py@@ -558,7 +558,7 @@ _PER_TURN_RESET_STATE: Tuple[Tuple[str, Any], ...] = (("_thinking_prefill_retries", 0), ("_post_tool_empty_retried", False),("_last_content_with_tools", None), ("_last_content_tools_all_housekeeping", False),("_mute_post_response", False), ("_unicode_sanitization_passes", 0),- ("_tool_guardrail_halt_decision", None), ("_vision_supported", True),+ ("_tool_guardrail_halt_decision", None),("_iteration_budget_warning_injected", False),("_run_budget_wrapup_injected", False), ("_verification_stop_nudges", 0),("_pre_verify_nudges", 0),diff --git a/agent/turn_recovery.py b/agent/turn_recovery.pyindex 017451e2f81..5c137c0533b 100644--- a/agent/turn_recovery.py+++ b/agent/turn_recovery.py@@ -244,14 +244,13 @@ def recover_before_classification(_err_status = getattr(api_error, "status_code", None)# 4xx-only gate: 5xx/timeouts are transient and take the retry path._status_ok = _err_status is None or (400 <= int(_err_status) < 500)- # Guarded PER MODEL, not by the turn-global ``_vision_supported``: in a fallback chain the next- # model can reject images too, and a turn-wide flag would skip its recovery and fail the turn.+ # Guarded PER MODEL, not by a turn-global flag: in a fallback chain the next model can reject+ # images too, and a turn-wide flag would skip its recovery and fail the turn._model_key = image_model_key(agent)_rejected = getattr(agent, "_image_rejecting_models", None)if not isinstance(_rejected, set):_rejected = agent._image_rejecting_models = set()if _model_key not in _rejected and _looks_like_image_content_rejection(_err_body) and _status_ok:- agent._vision_supported = False# Send-path only. A rejection says what THIS model accepts, not what the conversation# holds: stripping ``messages`` (canonical history) and forcing a flush deleted every# image — and every image-only message — from state.db for good, so a later switch to adiff --git a/tests/agent/test_image_rejection_fallback.py b/tests/agent/test_image_rejection_fallback.pyindex 3f610f40fd9..49d98053c84 100644--- a/tests/agent/test_image_rejection_fallback.py+++ b/tests/agent/test_image_rejection_fallback.py@@ -227,8 +227,8 @@ class TestStripImagesDropsStaleApiContent:previously sent for a message, and the next turn substitutes it back into``content``. Leaving it in place on a message this function rewrote wouldreplay the images the strip just removed — and the recovery cannot re-fire,- because it sets ``_vision_supported = False`` and gates itself on that. The- session would then send rejected images on every subsequent turn.+ because it records the model in ``_image_rejecting_models`` and gates itself+ on that. The session would then send rejected images on every subsequent turn.Same contract the other content-rewrite paths follow (stale-confirmationredaction in ``replay_cleanup``, compression rewrites, merge-into-tail):@@ -317,7 +317,7 @@ class TestRejectionNeverReachesPersistedHistory:from types import SimpleNamespacereturn SimpleNamespace(- provider=provider, model=model, _vision_supported=True, _force_ascii_payload=False,+ provider=provider, model=model, _force_ascii_payload=False,_image_rejecting_models=set(), _db_flush_scan_prefix=7, log_prefix="",_vprint=lambda *a, **k: None,)diff --git a/tests/agent/test_turn_context.py b/tests/agent/test_turn_context.pyindex 60644c46feb..09513f8e21b 100644--- a/tests/agent/test_turn_context.py+++ b/tests/agent/test_turn_context.py@@ -90,7 +90,6 @@ class _FakeAgent:self._stream_think_scrubber = None# Attributes the prologue assigns; recorded for assertions.self._invalid_tool_retries = -1- self._vision_supported = Noneself._persist_calls = 0self._session_messages = []self._pending_cli_user_message = None@@ -383,10 +382,9 @@ def test_turn_start_replaces_stale_parent_history_with_compression_child():def test_applies_agent_side_effects():agent = _FakeAgent()_build(agent)- # Retry counters reset, guardrails reset, vision re-armed, turn counted.+ # Retry counters reset, guardrails reset, turn counted.assert agent._invalid_tool_retries == 0assert agent._tool_guardrails.reset_called is True- assert agent._vision_supported is Trueassert agent._user_turn_count == 1# Crash-resilience persistence fired once.assert agent._persist_calls == 1