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