Skip to content

Commit 49c0c00

Browse files
Debug Agentclaude
andcommitted
refactor(acp): honour explicit acp_model in supports_vision
Now that ACPAgent.model_post_init() writes acp_model into llm.model (merged in #2881), llm.vision_is_active() gives an authoritative answer for explicitly-configured models via LiteLLM. Use it when the user has set acp_model — even if they pick a non-vision variant, that choice wins over the server-identity default. The provider-identity fallback only kicks in when acp_model is unset and we can't know which default model the server will pick; for all three providers we support, that default is vision-capable. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 1590e6f commit 49c0c00

2 files changed

Lines changed: 33 additions & 9 deletions

File tree

openhands-sdk/openhands/sdk/agent/acp_agent.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -803,13 +803,17 @@ def agent_version(self) -> str:
803803
def supports_vision(self) -> bool:
804804
"""Whether the wrapped ACP server forwards images to a vision model.
805805
806-
The sentinel ``self.llm`` uses ``model="acp-managed"`` which LiteLLM
807-
does not recognise, so the base-class ``llm.vision_is_active()``
808-
always returns False for ACP agents. Resolve the real capability
809-
from the ACP server identity (launch command or the agent name
810-
reported by InitializeResponse) instead. Unknown servers fall back
811-
to False so we don't silently send images a server may drop.
806+
When ``acp_model`` is set, ``self.llm.model`` carries the real
807+
model name so ``llm.vision_is_active()`` gives an authoritative
808+
answer via LiteLLM — honour the user's explicit model choice even
809+
if it's a non-vision variant.
810+
811+
Without ``acp_model``, the ACP server picks a default we can't
812+
see from here, so fall back to the server's identity: all three
813+
ACP servers OpenHands supports default to vision-capable models.
812814
"""
815+
if self.acp_model:
816+
return self.llm.vision_is_active()
813817
probe = f"{self._agent_name} {' '.join(self.acp_command)}".lower()
814818
return any(marker in probe for marker in _VISION_CAPABLE_ACP_SERVERS)
815819

tests/sdk/agent/test_acp_agent.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2119,13 +2119,33 @@ def test_unknown_acp_server_defaults_to_false(self):
21192119
assert agent.supports_vision() is False
21202120

21212121
def test_vision_not_derived_from_sentinel_llm(self):
2122-
# The sentinel ``acp-managed`` model is unknown to LiteLLM, so
2123-
# the base-class llm.vision_is_active() reports False. The
2124-
# ACPAgent override must still return True for known providers.
2122+
# Without acp_model, llm.model stays "acp-managed" (unknown to
2123+
# LiteLLM), so the base-class llm.vision_is_active() reports
2124+
# False. The ACPAgent override must still return True for known
2125+
# providers via the server-identity fallback.
21252126
agent = ACPAgent(acp_command=["npx", "-y", "claude-agent-acp"])
21262127
assert agent.llm.vision_is_active() is False
21272128
assert agent.supports_vision() is True
21282129

2130+
def test_explicit_acp_model_honours_llm_vision_check(self):
2131+
# When acp_model is set, llm.model carries the real model name
2132+
# (via ACPAgent.model_post_init) so we trust LiteLLM's answer —
2133+
# even when the server marker says vision-capable, the user's
2134+
# explicit non-vision model choice wins.
2135+
vision_agent = ACPAgent(
2136+
acp_command=["npx", "-y", "claude-agent-acp"],
2137+
acp_model="claude-sonnet-4-5",
2138+
)
2139+
assert vision_agent.llm.vision_is_active() is True
2140+
assert vision_agent.supports_vision() is True
2141+
2142+
text_only_agent = ACPAgent(
2143+
acp_command=["codex-acp"],
2144+
acp_model="gpt-3.5-turbo",
2145+
)
2146+
assert text_only_agent.llm.vision_is_active() is False
2147+
assert text_only_agent.supports_vision() is False
2148+
21292149

21302150
# ---------------------------------------------------------------------------
21312151
# acp_session_mode field

0 commit comments

Comments
 (0)