OpenHands / OpenHands/software-agent-sdk

Add limits and cancellation support to RemoteEventsList.getEvents()

Open
#4,737 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

RemoteEventsList.getEvents() fetches ALL events from the server with no upper bound:

async getEvents(start?: number, end?: number): Promise<Event[]> {
  const remote: Event[] = [];
  let pageId: string | undefined;

  while (true) {
    const params: any = { limit: 100 };
    if (pageId) params.page_id = pageId;
    const response = await this.client.get<EventPage>(...);
    remote.push(...data.items);
    if (!data.next_page_id) break;
    pageId = data.next_page_id;
  }
  // ...
}

For long conversations with thousands of events, this creates an unbounded waterfall of HTTP requests with no way to cancel. The start/end parameters only slice after all events are fetched.

Proposed Fix

  1. Accept a maxEvents parameter to cap total fetched events
  2. Accept an AbortSignal parameter for cancellation
  3. Make start/end work server-side (pass as query params if the API supports it)
  4. Consider returning an async iterator instead of loading everything into memory
async getEvents(options?: {
  start?: number;
  end?: number;
  maxEvents?: number;
  signal?: AbortSignal;
}): Promise<Event[]>

Impact

Low-Medium — prevents runaway network calls and OOM for long conversations.


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 at the RemoteEventsList.getEvents() entry point and inspect the client request and server pagination support. Clarify the options shape, maximum-fetch and cancellation behavior, and whether start/end can be sent as query parameters; done means bounded, cancellable fetching with the agreed API behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.