OpenHands / OpenHands/software-agent-sdk

Add unit tests for Remote* classes and LocalConversation

Open
#4,740 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
1.1k
Forks
539
Avg merge
1d 19h
Merged PRs (30d)
137

Description

Problem

The following major classes have no unit tests — they're only covered by integration tests that require a running agent-server:

  • RemoteConversation (338 lines) — conversation lifecycle, message sending, WebSocket management
  • RemoteWorkspace (318 lines) — command execution, file upload/download, git operations
  • RemoteState (238 lines) — state caching, locking, event-driven updates
  • HttpClient (207 lines) — request building, error handling, URL construction
  • WebSocketCallbackClient (140 lines) — reconnection, message parsing, backoff
  • LocalConversation (953 lines) — agent loop, tool execution, all state management
  • RemoteEventsList (162 lines) — pagination, caching, merging
  • ConversationManager (166 lines) — multi-conversation CRUD

Furthermore, there are no tests for factory functions: createConversation, createWorkspace, createConversationAuto, createWorkspaceAuto.

The existing 157 unit tests cover hooks, events/types, security, stuck-detector, and secret-registry — which are pure logic modules. The core client functionality that actually talks to servers is untested at the unit level.

Proposed Fix

Add unit tests using a mock/stub HttpClient (or a lightweight fake that records calls):

  1. HttpClient: Test URL construction, query param handling, error parsing, timeout behavior
  2. RemoteConversation: Test start() creates correct request, sendMessage() formats messages, close() cleans up
  3. RemoteState: Test caching TTL, updateStateFromEvent(), unwrapState() normalization
  4. RemoteWorkspace: Test executeCommand() request format, fileUpload() FormData construction
  5. LocalConversation: Test agent loop iteration, tool dispatch, pause/resume, stuck detection integration
  6. Factory functions: Test type detection and error cases

Use a simple request-recording fake rather than heavy mocking frameworks. Assert on actual request shapes and response handling.

Impact

Medium — catches regressions in the most critical code paths without requiring a running server.


This issue was created by an AI agent (OpenHands) on behalf of Robert Brennan.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the named RemoteConversation, RemoteWorkspace, RemoteState, HttpClient, WebSocketCallbackClient, LocalConversation, RemoteEventsList, ConversationManager, and factory functions. Review the existing unit tests and integration coverage, then use a request-recording fake to test the listed request, state, lifecycle, factory, and agent-loop behaviors without a running server. Done means the proposed core paths have focused unit coverage and the tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.