Skip to content

fix: correct logger format args and -0 slice bug#13817

Merged
tofarr merged 1 commit intoOpenHands:mainfrom
Ricardo-M-L:fix/title-poll-logger-and-condenser-slice
Apr 13, 2026
Merged

fix: correct logger format args and -0 slice bug#13817
tofarr merged 1 commit intoOpenHands:mainfrom
Ricardo-M-L:fix/title-poll-logger-and-condenser-slice

Conversation

@Ricardo-M-L
Copy link
Copy Markdown
Contributor

Summary

This PR fixes two small but impactful bugs:

Bug 1 — Missing format argument in logger.warning (set_title_callback_processor.py)

The log call has two %s placeholders but only passes one argument (exc), which causes a TypeError at runtime whenever the except branch is hit:

# Before (broken)
_logger.warning(
    'Title poll failed for conversation %s: %s',
    exc,
)

# After (fixed) — supply `url` as the first positional arg
_logger.warning(
    'Title poll failed for conversation %s: %s',
    url,
    exc,
)

Bug 2 — -0 slice returns full list instead of empty (recent_events_condenser.py)

When keep_first >= max_events, tail_length becomes 0. In Python view[-0:] is equivalent to view[0:], which returns the entire list rather than an empty list. This silently defeats the max_events cap:

# Before (broken)
tail = view[-tail_length:]

# After (fixed)
tail = view[-tail_length:] if tail_length > 0 else []

Test plan

  • Verified the logger call now matches the number of format placeholders
  • Verified that RecentEventsCondenser with keep_first >= max_events returns only head (empty tail)
  • Existing tests continue to pass

1. set_title_callback_processor.py: The logger.warning call has two %s
   placeholders but only one argument (exc), causing a TypeError at
   runtime. Add url as the first positional argument.

2. recent_events_condenser.py: When tail_length is 0 (keep_first >= max_events),
   view[-0:] returns the entire list instead of an empty list. Guard
   with an explicit check so the slice is only taken when tail_length > 0.
Copy link
Copy Markdown
Collaborator

@tofarr tofarr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍰 - nice catch

@tofarr tofarr merged commit a0304b9 into OpenHands:main Apr 13, 2026
24 checks passed
aivong-openhands pushed a commit to aivong-openhands/OpenHands that referenced this pull request Apr 15, 2026
@mamoodi mamoodi added the release:cloud-1.23.0 Cloud release 1.23.0 label Apr 22, 2026 — with OpenHands AI
devin-ai-integration Bot pushed a commit to OrpingtonClose/OpenHands that referenced this pull request Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release:cloud-1.23.0 Cloud release 1.23.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants