Skip to content

Commit

Permalink
serialize only at endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
malhotra5 committed Jan 28, 2025
1 parent 3534606 commit ea9411a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions openhands/events/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def get_matching_events(
start_id: int = 0,
limit: int = 100,
reverse: bool = False,
) -> list:
) -> list[type[Event]]:
"""Get matching events from the event stream based on filters.
Args:
Expand Down Expand Up @@ -414,7 +414,7 @@ def get_matching_events(
):
continue

matching_events.append(event_to_dict(event))
matching_events.append(event)

# Stop if we have enough events
if len(matching_events) >= limit:
Expand Down
4 changes: 3 additions & 1 deletion openhands/server/routes/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from openhands.core.logger import openhands_logger as logger
from openhands.events.event import Event
from openhands.events.serialization.event import event_from_dict
from openhands.events.serialization.event import event_from_dict, event_to_dict
from openhands.runtime.base import Runtime

app = APIRouter(prefix='/api/conversations/{conversation_id}')
Expand Down Expand Up @@ -156,6 +156,8 @@ async def search_events(
has_more = len(matching_events) > limit
if has_more:
matching_events = matching_events[:limit] # Remove the extra event

matching_events = [event_to_dict(event) for event in matching_events]
return {
'events': matching_events,
'has_more': has_more,
Expand Down

0 comments on commit ea9411a

Please sign in to comment.