Skip to content

Response includes raw SSE events (output, rate_limit_event) in Telegram messages #386

@eisen0419

Description

@eisen0419

Description

When Claude Code responds via HAPI Telegram bot, the end of each message includes raw JSON from internal SSE stream events that should be filtered out.

Reproduction

  1. Send a message to the HAPI Telegram bot
  2. Wait for Claude Code to respond
  3. The response text is correct, but at the end, raw JSON objects are appended

Expected Behavior

Only the assistant's text content should be forwarded to Telegram. Internal SSE control events should be filtered out.

Actual Behavior

Two types of internal events leak into the visible message:

{"type": "output", "data": {"parentUuid": "...", "isSidechain": false, "userType": "external", "cwd": "...", "sessionId": "...", "version": "0.0.0", "uuid": "...", "timestamp": "..."}}
{"type": "rate_limit_event", "rate_limit_info": {"status": "allowed", "resetsAt": ..., "rateLimitType": "five_hour", "overageStatus": "rejected", "overageDisabledReason": "org_level_disabled", "isUsingOverage": false, "session_id": "..."}}

Screenshot

screenshot

(See attached screenshot showing the leaked JSON at the end of a normal response)

Environment

  • HAPI version: 0.16.5
  • Platform: macOS (darwin-arm64)
  • Claude model: Opus 4.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions