Skip to content

Fix stream iterator #7384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 20, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions openhands/controller/agent_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -1206,14 +1206,13 @@ def _first_user_message(self) -> MessageAction | None:
Returns:
MessageAction | None: The first user message, or None if no user message found
"""
# Find the first user message from the appropriate starting point
user_messages = list(self.event_stream.get_events(start_id=self.state.start_id))

# Get and return the first user message
return next(
(
e
for e in user_messages
for e in self.event_stream.get_events(
start_id=self.state.start_id,
reverse=False,
)
if isinstance(e, MessageAction) and e.source == EventSource.USER
),
None,
Expand Down
Loading