OpenHands / OpenHands/software-agent-sdk

Migrate LocalConversation.emitEvent() to typed events, remove legacy format

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

LocalConversation has two event emission methods:

  1. emitTypedEvent(event: BaseEvent) — proper typed events matching events/types.ts interfaces
  2. emitEvent({ type, timestamp, data }) — legacy format that creates ad-hoc events

The legacy method creates events like { kind: 'user_message', content } and { kind: 'paused' } that don't match any typed event interface. It even has a @deprecated JSDoc tag but is still used in 10+ places.

// Legacy — creates untyped events
this.emitEvent({
  type: 'message',
  timestamp: Date.now(),
  data: { kind: 'user_message', content },
});

// Proper — uses typed interfaces
this.emitTypedEvent(stateEvent);

Consumers receiving these events via callbacks get inconsistent shapes depending on which code path emitted them.

Proposed Fix

  • Convert all emitEvent() calls to use emitTypedEvent() with proper BaseEvent subtypes
  • For events like user_message and paused that have no existing typed interface, either:
    • Map them to existing types (e.g., user_message -> MessageEvent)
    • Create new typed interfaces if needed
  • Delete emitEvent() entirely

Impact

Low — consistency improvement. All events will match documented typed interfaces.


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 with LocalConversation's emitEvent() and emitTypedEvent() methods, then read events/types.ts to inventory the available BaseEvent subtypes. Trace the 10+ legacy call sites, especially user_message and paused, and determine whether existing types fit or new interfaces are needed. Done means all calls use typed events and the legacy method is removed.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.