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
Original file line number Diff line number Diff line change
Expand Up @@ -1230,6 +1230,13 @@ def pause(self) -> None:
f"{self._conversation_action_base_path}/{self._id}/pause",
)

def interrupt(self) -> None:
_send_request(
self._client,
"POST",
f"{self._conversation_action_base_path}/{self._id}/interrupt",
)

def update_secrets(self, secrets: Mapping[str, SecretValue]) -> None:
from openhands.sdk.secret.secrets import SecretSource

Expand Down
26 changes: 26 additions & 0 deletions tests/sdk/conversation/remote/test_remote_conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,32 @@ def test_remote_conversation_pause(self, mock_ws_client):
]
assert len(request_calls) >= 1, "Should have made a POST call to pause endpoint"

@patch(
"openhands.sdk.conversation.impl.remote_conversation.WebSocketCallbackClient"
)
def test_remote_conversation_interrupt(self, mock_ws_client):
"""interrupt() must POST to /interrupt, not degrade to /pause."""
conversation_id = str(uuid.uuid4())
mock_client_instance = self.setup_mock_client(conversation_id=conversation_id)

mock_ws_instance = Mock()
mock_ws_client.return_value = mock_ws_instance

conversation = RemoteConversation(agent=self.agent, workspace=self.workspace)
conversation.interrupt()

posts = [
call[0][1]
for call in mock_client_instance.request.call_args_list
if call[0][0] == "POST"
]
assert any(
f"/api/conversations/{conversation_id}/interrupt" in url for url in posts
), "Should have made a POST call to interrupt endpoint"
assert not any(
f"/api/conversations/{conversation_id}/pause" in url for url in posts
), "interrupt() must not degrade to the pause endpoint"

@patch(
"openhands.sdk.conversation.impl.remote_conversation.WebSocketCallbackClient"
)
Expand Down
Loading