Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions openhands_cli/acp_impl/agent/base_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,14 @@
AuthenticateResponse,
AuthMethod,
AvailableCommandsUpdate,
ForkSessionResponse,
Implementation,
ListSessionsResponse,
LoadSessionResponse,
McpCapabilities,
PromptCapabilities,
ResumeSessionResponse,
SetSessionConfigOptionResponse,
SetSessionModelResponse,
SetSessionModeResponse,
TextContentBlock,
Expand Down Expand Up @@ -335,6 +338,36 @@ async def set_session_model(
logger.info(f"Set session model requested: {session_id}")
return SetSessionModelResponse()

async def set_config_option(
self,
config_id: str, # noqa: ARG002
session_id: str, # noqa: ARG002
value: str, # noqa: ARG002
**_kwargs: Any,
) -> SetSessionConfigOptionResponse | None:
"""Set config option (not supported)."""
return None

async def fork_session(
self,
cwd: str, # noqa: ARG002
session_id: str, # noqa: ARG002
mcp_servers: list[Any] | None = None, # noqa: ARG002
**_kwargs: Any,
) -> ForkSessionResponse:
"""Fork a session (not supported)."""
raise RequestError.method_not_found("session/fork")

async def resume_session(
self,
cwd: str, # noqa: ARG002
session_id: str, # noqa: ARG002
mcp_servers: list[Any] | None = None, # noqa: ARG002
**_kwargs: Any,
) -> ResumeSessionResponse:
"""Resume a session (not supported)."""
raise RequestError.method_not_found("session/resume")

async def ext_method(self, method: str, params: dict[str, Any]) -> dict[str, Any]:
"""Extension method (not supported)."""
logger.info(f"Extension method '{method}' requested with params: {params}")
Expand Down Expand Up @@ -397,7 +430,7 @@ async def cancel(self, session_id: str, **_kwargs: Any) -> None:
async def new_session(
self,
cwd: str, # noqa: ARG002
mcp_servers: list[Any],
mcp_servers: list[Any] | None = None,
working_dir: str | None = None,
**_kwargs: Any,
) -> NewSessionResponse:
Expand Down Expand Up @@ -567,8 +600,8 @@ async def prompt(
async def load_session(
self,
cwd: str, # noqa: ARG002
mcp_servers: list[Any], # noqa: ARG002
session_id: str,
mcp_servers: list[Any] | None = None, # noqa: ARG002
**_kwargs: Any,
) -> LoadSessionResponse | None:
"""Load an existing session and replay conversation history.
Expand Down
2 changes: 1 addition & 1 deletion openhands_cli/acp_impl/agent/local_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def sync_callback(event: Event) -> None:
async def new_session(
self,
cwd: str,
mcp_servers: list[Any],
mcp_servers: list[Any] | None = None,
working_dir: str | None = None,
**_kwargs: Any,
) -> NewSessionResponse:
Expand Down
4 changes: 2 additions & 2 deletions openhands_cli/acp_impl/agent/remote_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def sync_callback(event: Event) -> None:
async def new_session(
self,
cwd: str,
mcp_servers: list[Any],
mcp_servers: list[Any] | None = None,
working_dir: str | None = None,
**_kwargs: Any,
) -> NewSessionResponse:
Expand Down Expand Up @@ -299,8 +299,8 @@ async def prompt(
async def load_session(
self,
cwd: str, # noqa: ARG002
mcp_servers: list[Any], # noqa: ARG002
session_id: str,
mcp_servers: list[Any] | None = None, # noqa: ARG002
**_kwargs: Any,
) -> LoadSessionResponse | None:
"""Load an existing session (cloud mode has limited support)."""
Expand Down
6 changes: 3 additions & 3 deletions openhands_cli/acp_impl/utils/mcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

from acp.schema import (
HttpMcpServer,
McpServerStdio,
SseMcpServer,
StdioMcpServer,
)


ACPMCPServerType = StdioMcpServer | HttpMcpServer | SseMcpServer
ACPMCPServerType = McpServerStdio | HttpMcpServer | SseMcpServer


def _convert_env_to_dict(env: Sequence[dict[str, str]]) -> dict[str, str]:
Expand Down Expand Up @@ -64,7 +64,7 @@ def convert_acp_mcp_servers_to_agent_format(

# Add transport type based on server class
# StdioMcpServer -> stdio, HttpMcpServer -> http, SseMcpServer -> sse
if isinstance(server, StdioMcpServer):
if isinstance(server, McpServerStdio):
server_config["transport"] = "stdio"
elif isinstance(server, HttpMcpServer):
server_config["transport"] = "http"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ dependencies = [
"rich<14.3.0",
"textual>=8.0.0,<9.0.0",
"typer>=0.17.4",
"agent-client-protocol>=0.7.0,<0.8.0",
"agent-client-protocol>=0.8.1,<0.9.0",
"pydantic>=2.7",
"textual-autocomplete>=4.0.6",
"pyperclip>=1.9.0",
Expand Down
28 changes: 14 additions & 14 deletions tests/acp/events/test_event_subscriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

import pytest
from acp.schema import (
SessionUpdate2,
SessionUpdate3,
SessionUpdate4,
SessionUpdate5,
SessionUpdate6,
AgentMessageChunk,
AgentPlanUpdate,
AgentThoughtChunk,
ToolCallProgress,
ToolCallStart,
)

from openhands.sdk import Message, TextContent
Expand Down Expand Up @@ -57,7 +57,7 @@ async def test_handle_message_event(event_subscriber, mock_connection):
# Get the update parameter (second argument, first is session_id)
call_kwargs = mock_connection.session_update.call_args[1]
assert call_kwargs["session_id"] == "test-session"
assert isinstance(call_kwargs["update"], SessionUpdate2)
assert isinstance(call_kwargs["update"], AgentMessageChunk)
assert call_kwargs["update"].session_update == "agent_message_chunk"


Expand Down Expand Up @@ -110,7 +110,7 @@ class MockEvent:
for call in calls:
call_kwargs = call[1]
update = call_kwargs["update"]
if isinstance(update, SessionUpdate4):
if isinstance(update, ToolCallStart):
tool_call_found = True
assert update.session_update == "tool_call"
assert update.tool_call_id == "test-call-123"
Expand Down Expand Up @@ -145,7 +145,7 @@ async def test_handle_observation_event(event_subscriber, mock_connection):
call_kwargs = mock_connection.session_update.call_args[1]
assert call_kwargs["session_id"] == "test-session"
update = call_kwargs["update"]
assert isinstance(update, SessionUpdate5)
assert isinstance(update, ToolCallProgress)
assert update.session_update == "tool_call_update"
assert update.tool_call_id == "test-call-123"
assert update.status == "completed"
Expand Down Expand Up @@ -197,7 +197,7 @@ async def test_handle_system_prompt_event(event_subscriber, mock_connection):
call_kwargs = mock_connection.session_update.call_args[1]
assert call_kwargs["session_id"] == "test-session"
update = call_kwargs["update"]
assert isinstance(update, SessionUpdate3)
assert isinstance(update, AgentThoughtChunk)
assert update.session_update == "agent_thought_chunk"


Expand All @@ -215,7 +215,7 @@ async def test_handle_pause_event(event_subscriber, mock_connection):
call_kwargs = mock_connection.session_update.call_args[1]
assert call_kwargs["session_id"] == "test-session"
update = call_kwargs["update"]
assert isinstance(update, SessionUpdate3)
assert isinstance(update, AgentThoughtChunk)
assert update.session_update == "agent_thought_chunk"


Expand All @@ -238,7 +238,7 @@ async def test_handle_condensation_event(event_subscriber, mock_connection):
call_kwargs = mock_connection.session_update.call_args[1]
assert call_kwargs["session_id"] == "test-session"
update = call_kwargs["update"]
assert isinstance(update, SessionUpdate3)
assert isinstance(update, AgentThoughtChunk)
assert update.session_update == "agent_thought_chunk"


Expand All @@ -256,7 +256,7 @@ async def test_handle_condensation_request_event(event_subscriber, mock_connecti
call_kwargs = mock_connection.session_update.call_args[1]
assert call_kwargs["session_id"] == "test-session"
update = call_kwargs["update"]
assert isinstance(update, SessionUpdate3)
assert isinstance(update, AgentThoughtChunk)
assert update.session_update == "agent_thought_chunk"


Expand Down Expand Up @@ -308,7 +308,7 @@ async def test_handle_task_tracker_observation(event_subscriber, mock_connection
assert call_kwargs["session_id"] == "test-session"
update = call_kwargs["update"]

assert isinstance(update, SessionUpdate6)
assert isinstance(update, AgentPlanUpdate)
# Verify plan structure
assert update.session_update == "plan"
assert len(update.entries) == 3
Expand Down Expand Up @@ -357,7 +357,7 @@ async def test_handle_task_tracker_with_empty_list(event_subscriber, mock_connec
call_kwargs = mock_connection.session_update.call_args[1]
assert call_kwargs["session_id"] == "test-session"
update = call_kwargs["update"]
assert isinstance(update, SessionUpdate6)
assert isinstance(update, AgentPlanUpdate)
assert update.entries == []


Expand Down
4 changes: 2 additions & 2 deletions tests/acp/test_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,10 +528,10 @@ async def test_initialize_reports_image_capability(acp_agent):
@pytest.mark.asyncio
async def test_new_session_with_mcp_servers(acp_agent, tmp_path):
"""Test creating a new session with MCP servers transforms env correctly."""
from acp.schema import StdioMcpServer
from acp.schema import McpServerStdio

# Create MCP server with env as array (ACP format)
mcp_server = StdioMcpServer(
mcp_server = McpServerStdio(
name="test-server",
command="/usr/bin/node",
args=["server.js"],
Expand Down
10 changes: 5 additions & 5 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from argparse import Namespace
from unittest.mock import patch

from acp.schema import EnvVariable, StdioMcpServer
from acp.schema import EnvVariable, McpServerStdio

from openhands.sdk.event import MessageEvent, SystemPromptEvent
from openhands.sdk.llm import Message, TextContent
Expand Down Expand Up @@ -79,7 +79,7 @@ def test_convert_acp_mcp_servers_empty_list():
def test_convert_acp_mcp_servers_with_empty_env():
"""Test converting MCP server with empty env array."""
servers = [
StdioMcpServer(
McpServerStdio(
name="test-server",
command="/usr/bin/node",
args=["server.js"],
Expand All @@ -99,7 +99,7 @@ def test_convert_acp_mcp_servers_with_empty_env():
def test_convert_acp_mcp_servers_with_env_variables():
"""Test converting MCP server with env variables."""
servers = [
StdioMcpServer(
McpServerStdio(
name="test-server",
command="/usr/bin/python",
args=["-m", "server"],
Expand All @@ -121,13 +121,13 @@ def test_convert_acp_mcp_servers_with_env_variables():
def test_convert_acp_mcp_servers_multiple_servers():
"""Test converting multiple MCP servers."""
servers = [
StdioMcpServer(
McpServerStdio(
name="server1",
command="/usr/bin/node",
args=["server1.js"],
env=[],
),
StdioMcpServer(
McpServerStdio(
name="server2",
command="/usr/bin/python",
args=["-m", "server2"],
Expand Down
8 changes: 4 additions & 4 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading