|
13 | 13 |
|
14 | 14 | from openhands.sdk.agent.acp_agent import ( |
15 | 15 | ACPAgent, |
16 | | - _acp_command_supports_vision, |
17 | 16 | _build_session_meta, |
18 | 17 | _estimate_cost_from_tokens, |
19 | 18 | _extract_token_usage, |
@@ -2081,80 +2080,41 @@ def test_empty_name_defaults_to_full_access(self): |
2081 | 2080 |
|
2082 | 2081 |
|
2083 | 2082 | # --------------------------------------------------------------------------- |
2084 | | -# _acp_command_supports_vision + ACPAgent.supports_vision() |
| 2083 | +# ACPAgent.supports_vision() |
2085 | 2084 | # --------------------------------------------------------------------------- |
2086 | 2085 |
|
2087 | 2086 |
|
2088 | | -class TestACPCommandSupportsVision: |
| 2087 | +class TestACPAgentSupportsVision: |
2089 | 2088 | """All three ACP providers OpenHands supports — claude-agent-acp, |
2090 | 2089 | gemini-cli, codex-acp — declare prompt_capabilities.image=true and |
2091 | 2090 | forward images to a vision-capable underlying model.""" |
2092 | 2091 |
|
2093 | | - def test_claude_agent_acp_command(self): |
2094 | | - assert ( |
2095 | | - _acp_command_supports_vision( |
2096 | | - ["npx", "-y", "@agentclientprotocol/claude-agent-acp"], |
2097 | | - "", |
2098 | | - ) |
2099 | | - is True |
2100 | | - ) |
2101 | | - |
2102 | | - def test_claude_agent_acp_from_agent_name(self): |
2103 | | - assert _acp_command_supports_vision(["/some/opaque/binary"], "claude-agent-acp") |
2104 | | - assert _acp_command_supports_vision([], "claude-agent-acp") |
2105 | | - |
2106 | | - def test_gemini_cli_command(self): |
2107 | | - assert ( |
2108 | | - _acp_command_supports_vision(["gemini-cli", "--experimental-acp"], "") |
2109 | | - is True |
2110 | | - ) |
2111 | | - |
2112 | | - def test_gemini_cli_from_agent_name(self): |
2113 | | - assert _acp_command_supports_vision(["node", "server.js"], "gemini-cli") |
2114 | | - |
2115 | | - def test_codex_acp_command(self): |
2116 | | - assert _acp_command_supports_vision(["codex-acp"], "") is True |
2117 | | - |
2118 | | - def test_codex_acp_from_agent_name(self): |
2119 | | - assert _acp_command_supports_vision([], "codex-acp") |
2120 | | - |
2121 | | - def test_agent_name_takes_precedence_over_generic_command(self): |
2122 | | - # A user can launch any of our three servers via ``node`` or a |
2123 | | - # local path; the agent name from InitializeResponse still lets |
2124 | | - # us identify the provider. |
2125 | | - assert ( |
2126 | | - _acp_command_supports_vision( |
2127 | | - ["/usr/local/bin/node", "/opt/server.js"], |
2128 | | - "claude-agent-acp", |
2129 | | - ) |
2130 | | - is True |
2131 | | - ) |
2132 | | - |
2133 | | - def test_unknown_server_defaults_to_false(self): |
2134 | | - # Safe default: unknown servers may silently drop image blocks, |
2135 | | - # so advertise no-vision rather than send content that gets lost. |
2136 | | - assert _acp_command_supports_vision(["some-random-acp-server"], "") is False |
2137 | | - |
2138 | | - def test_empty_inputs_default_to_false(self): |
2139 | | - assert _acp_command_supports_vision([], "") is False |
2140 | | - |
2141 | | - |
2142 | | -class TestACPAgentSupportsVision: |
2143 | | - def test_claude_agent_supports_vision(self): |
| 2092 | + def test_claude_agent_via_command(self): |
2144 | 2093 | agent = ACPAgent( |
2145 | 2094 | acp_command=["npx", "-y", "@agentclientprotocol/claude-agent-acp"] |
2146 | 2095 | ) |
2147 | 2096 | assert agent.supports_vision() is True |
2148 | 2097 |
|
2149 | | - def test_gemini_cli_supports_vision(self): |
| 2098 | + def test_gemini_cli_via_command(self): |
2150 | 2099 | agent = ACPAgent(acp_command=["gemini-cli", "--experimental-acp"]) |
2151 | 2100 | assert agent.supports_vision() is True |
2152 | 2101 |
|
2153 | | - def test_codex_acp_supports_vision(self): |
| 2102 | + def test_codex_acp_via_command(self): |
2154 | 2103 | agent = ACPAgent(acp_command=["codex-acp"]) |
2155 | 2104 | assert agent.supports_vision() is True |
2156 | 2105 |
|
2157 | | - def test_unknown_acp_server_does_not_claim_vision(self): |
| 2106 | + def test_agent_name_resolves_opaque_launcher(self): |
| 2107 | + # A user can launch any of our three servers via ``node`` or a |
| 2108 | + # local path; the agent name from InitializeResponse still lets |
| 2109 | + # us identify the provider. |
| 2110 | + agent = ACPAgent(acp_command=["/usr/local/bin/node", "/opt/server.js"]) |
| 2111 | + assert agent.supports_vision() is False |
| 2112 | + agent._agent_name = "claude-agent-acp" |
| 2113 | + assert agent.supports_vision() is True |
| 2114 | + |
| 2115 | + def test_unknown_acp_server_defaults_to_false(self): |
| 2116 | + # Unknown servers may silently drop image blocks, so advertise |
| 2117 | + # no-vision rather than send content that gets lost. |
2158 | 2118 | agent = ACPAgent(acp_command=["echo", "test"]) |
2159 | 2119 | assert agent.supports_vision() is False |
2160 | 2120 |
|
|
0 commit comments