Skip to content

perf: Condensation.forgotten_event_ids is a list, not a set — O(V×F) per application #3150

@csmith49

Description

@csmith49

Problem

Condensation.forgotten_event_ids is list[EventID]. The apply() method does event.id not in self.forgotten_event_ids — an O(F) lookup per event where F is the number of forgotten events. Each condensation application is O(V×F). With K condensations over a conversation's lifetime, View.from_events replays all K, compounding to O(K×V×F).

Location: event/condenser.py:14, 91

Evidence

Code at event/condenser.py:91. The field is declared as list[EventID] at line 14.

Severity: Medium (will be addressed by incremental view work)

Impact of fix

Condensation application becomes O(V) instead of O(V×F).

Fix

Change list[EventID] to set[EventID]. Trivial.

Note: the planned incremental view work will make this less impactful since View.from_events won't replay the full history.

Related issues and PRs

Discovered during profiling investigation, May 2026. openhands-sdk v1.19.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingperformancePerformance issue

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions