Skip to content

fix: Return empty events for resume with missing/cursorless session - #100

Merged
evansenter merged 2 commits into
mainfrom
fix/resume-flag-returns-empty-for-missing-session
Jan 31, 2026
Merged

fix: Return empty events for resume with missing/cursorless session#100
evansenter merged 2 commits into
mainfrom
fix/resume-flag-returns-empty-for-missing-session

Conversation

@evansenter

Copy link
Copy Markdown
Owner

Summary

  • Fix get_events(resume=True) to return empty events when session doesn't exist or has no saved cursor
  • Prevents flooding users with stale events from the beginning of time
  • Add debug logging for production visibility when resume is skipped

Problem

When --resume was used with a session that either:

  1. Doesn't exist in the database, OR
  2. Exists but has no saved last_cursor

The code would fall through to the default behavior, returning ALL events from the beginning (event #1 from December 2025). This broke the prompt-events.sh hook which relies on --resume for incremental polling.

Solution

Add an early return when resume=True but no cursor is available, returning empty events with a valid next_cursor for future polling. This treats the session as "caught up".

Test plan

  • Added test_resume_with_nonexistent_session_returns_empty
  • Added test_resume_with_session_without_cursor_returns_empty
  • All 265 existing tests pass
  • Manual verification with non-existent session ID

Fixes #99

🤖 Generated with Claude Code

When get_events() is called with resume=True but the session doesn't
exist or has no saved cursor, return empty events instead of falling
through to return all historical events from the beginning.

This fixes issue #99 where CLI --resume flag would flood users with
stale events from December when the session wasn't properly registered.

Fixes #99

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@claude

claude Bot commented Jan 31, 2026

Copy link
Copy Markdown

Prompt: evansenter/dotfiles/.../claude-review.md

Code Review

Summary

This PR fixes a bug where get_events(resume=True) would return all events from the beginning of time when a session doesn't exist or has no saved cursor. The fix adds an early return that returns empty events with a valid next_cursor for future polling, treating the session as "caught up".

Issues Found

Critical

None

Important

None

Suggestions

None

Verdict

APPROVE - Code looks good, no issues found. The fix is minimal and targeted, correctly addressing the bug described in #99. The two new tests provide good coverage for both failure scenarios (nonexistent session and session without cursor). The debug logging is properly guarded since session_id is verified truthy before the slicing operation.


Automated review by Claude Code

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@claude

claude Bot commented Jan 31, 2026

Copy link
Copy Markdown

Prompt: evansenter/dotfiles/.../claude-review.md

Code Review

Summary

This PR fixes a bug where get_events(resume=True) would flood users with stale events from the beginning of time when a session doesn't exist or has no saved cursor. The fix adds an early return that treats the session as "caught up", returning empty events with a valid next_cursor for future polling.

Issues Found

Critical

None

Important

None

Suggestions

None

Verdict

APPROVE - The fix is minimal and correctly addresses the issue described in #99. Key observations:

  1. Correct behavior: Returning empty events with a valid next_cursor allows future polling to work properly - the session will start receiving only new events from that point forward.

  2. Good test coverage: Two new tests cover both failure scenarios (nonexistent session and session without cursor), and verify both the empty events and valid next_cursor behavior.

  3. Safe string slicing: The session_id[:8] in the logging is safe because the condition if resume and session_id and cursor is None ensures session_id is truthy before the else branch executes.

  4. Consistent with existing patterns: The return structure matches the normal return at line 456-458, maintaining API consistency.


Automated review by Claude Code

@evansenter
evansenter merged commit ae49b09 into main Jan 31, 2026
5 checks passed
@evansenter
evansenter deleted the fix/resume-flag-returns-empty-for-missing-session branch January 31, 2026 08:13
evansenter added a commit that referenced this pull request Feb 7, 2026
- Raw API responses moved to top (data model first)
- Conversations reordered by research interest: collaborative
  debugging, cross-repo negotiation, planning/delegation/verification
- Added full performance debugging thread (14 events over 3 days)
- Added ingestion automation planning + data validation conversation
- Added cascading bug chain (#99 -> #100 -> #102) as own section
- Pattern annotations explain emergent dynamics (fan-out, escalation,
  hypothesis elimination, asymmetric channel targeting)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
evansenter added a commit that referenced this pull request Feb 7, 2026
* docs: add example agent communications with raw API responses

Real conversations between Claude Code sessions extracted from the live
event bus. Includes curated examples organized by communication pattern
(coordination, debugging, cross-repo collaboration, knowledge sharing,
infrastructure setup, social) plus raw JSON API responses for agent
researchers showing the actual get_events, list_sessions, and
list_channels formats.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* docs: restructure for multi-agent dynamics researchers

- Raw API responses moved to top (data model first)
- Conversations reordered by research interest: collaborative
  debugging, cross-repo negotiation, planning/delegation/verification
- Added full performance debugging thread (14 events over 3 days)
- Added ingestion automation planning + data validation conversation
- Added cascading bug chain (#99 -> #100 -> #102) as own section
- Pattern annotations explain emergent dynamics (fan-out, escalation,
  hypothesis elimination, asymmetric channel targeting)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* docs: address reviewer feedback on EXAMPLE_COMMS.md

- Add note about pre-rename repo names (claude-event-bus → agent-event-bus)
- Redact infrastructure identifiers (hostnames, Tailscale URLs, paths)
- Fix methodology contradiction (Status Broadcasts noted as supplementary)
- Consolidate duplicate Infrastructure Setup content
- Replace Python pseudocode with actual MCP tool parameters

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI --resume flag returns events from beginning instead of saved cursor position

1 participant