Skip to content

[BUG] Feishu plugin: orphaned sessions continue looping after abort, causing sustained high CPU #33050

Closed as not planned

Description

@EdwQ

Problem

When a Feishu (飞书) session is aborted by the user (e.g., via cancel in the Feishu UI), the session is marked as orphan=true but its processing loop is not terminated. The opencode process continues to re-enter the loop (step=0 → step=1 → ...), making repeated LLM inference requests indefinitely.

If the parent terminal/process exits, the opencode main process becomes an orphan (PPID=1) and keeps consuming high CPU (observed 370-420% CPU, ~8.5GB RSS) with no way to stop it except manually killing the process.

Root Cause

The Feishu plugin's session.error handler logs orphan=true but does not properly clean up the session's pending tasks or prevent the session from re-entering the processing loop. This is distinct from the existing orphan session issues (#19023, #30683, #31787) which deal with DB records or project ID drift — this is specifically about the Feishu WebSocket channel triggering repeated loop restarts for aborted sessions.

Additionally, when the Feishu WebSocket connection drops (e.g., certificate verification errors), the reconnect logic may trigger re-processing of orphaned sessions.

Reproduction

  1. Start opencode with Feishu plugin configured
  2. Send a message from Feishu to trigger a session
  3. Cancel/abort the session from the Feishu UI
  4. Observe that the session is marked orphan=true but continues looping
  5. Close the terminal running opencode
  6. The opencode process becomes orphaned (PPID=1) and continues consuming high CPU

Observed Logs

level=ERROR message=process session.id=ses_xxx error=Aborted stack=undefined
level=WARN message="[feishu] 收到 session.error 事件" sessionId=ses_xxx errMsg=Aborted orphan=true
level=INFO message=loop session.id=ses_xxx step=0  // <-- loop restarts despite orphan=true
level=INFO message=stream providerID=omlx modelID=Qwen3___5-122B-A10B-4bit session.id=ses_xxx

Expected Behavior

When a session is aborted and marked as orphan, the Feishu plugin should:

  1. Remove the session from the active processing queue
  2. Not allow the session to re-enter the loop on subsequent iterations
  3. Clean up any pending message handlers for that session

Environment

  • Opencode version: 1.17.8
  • Platform: macOS ARM64 (Darwin)
  • Model: oMLX local (Qwen3.5-122B-A10B-4bit)
  • Feishu plugin: WebSocket mode (persistent connection)

Related Issues

Activity

  1. Necmttn commented on Jun 21, 2026

    @Necmttn

    Abort needs to be a terminal session state with cancellation propagated into the loop. When Feishu marks orphan=true, also cancel pending tasks, clear queued prompt work, and write session.aborted with source, channel id, final step, and cleanup result.

    The loop should check that terminal flag before re-entering step 0. Parent process death and WebSocket reconnect should not revive an aborted session unless a new user action explicitly resumes it. Add a max-loop guard as a final failsafe.


    Generated with ax.

  2. github-actions commented on Aug 21, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions