Skip to content

Fix: Surface session_terminated event in CLI and Web UI - #351

Open
VectorCipher wants to merge 6 commits into
huggingface:mainfrom
VectorCipher:fix/issue_345
Open

Fix: Surface session_terminated event in CLI and Web UI#351
VectorCipher wants to merge 6 commits into
huggingface:mainfrom
VectorCipher:fix/issue_345

Conversation

@VectorCipher

Copy link
Copy Markdown

Fix: Issue #345
This PR fixes a critical bug where a context compaction failure would emit a session_terminated event that was completely unhandled by consumer layers, resulting in a silent hang/death for both CLI and Web UI users.

This PR implements the missing event handlers across the stack to ensure the agent fails loudly and gracefully.

Changes Made:

  1. Python CLI (agent/main.py):
    a) Added an explicit handler for session_terminated to stop the shimmer, print the user-facing error message, and correctly unblock the event loop.
    b) Regression Guard: Replaced the silent # Silently ignore other events fallback with a logger.warning to ensure any future unhandled event types are surfaced in the logs instead of failing silently.
  2. Frontend Types (frontend/src/types/events.ts):
    a) Added 'session_terminated' to the EventType union for end-to-end type safety.
  3. Frontend Transport (frontend/src/lib/sse-chat-transport.ts & useAgentChat.ts):
    a) Added the session_terminated case to the SSE event switch statement.
    b) Connected the event to the existing onError and onProcessingDone side-channels so the Web UI now correctly drops out of the loading state and displays the terminal error banner to the user.
  4. Tests:
    a)Added backend tests (test_session_terminated_dispatch.py) to verify the CLI explicitly handles the event and that unknown events trigger the new warning guard.
  5. Testing Instructions:
  6. Verified backend tests pass successfully.
  7. Verified ruff linting and formatting.
  8. Verified frontend TypeScript compiler exhaustiveness checks pass.

@VectorCipher VectorCipher changed the title Fix: Surface session_terminated event in CLI and Web UI Fix:session_terminated event is emitted but never surfaced in CLI or Web UI, causing silent agent death Jul 15, 2026
@VectorCipher VectorCipher changed the title Fix:session_terminated event is emitted but never surfaced in CLI or Web UI, causing silent agent death Fix: Surface session_terminated event in CLI and Web UI Jul 15, 2026
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.

1 participant