Skip to content

Add subprocess timeout to prevent hung Claude CLI processes #9

@chenhaot

Description

@chenhaot

All subprocess.run calls to the claude CLI in agent.py (lines 22-25, 125-128, 168-171) have no timeout set. If the CLI hangs (network issue, API outage, infinite loop), the bot's event loop will block indefinitely on these synchronous calls, making the entire bot unresponsive since they run in the main thread.

Similarly, worker.py uses asyncio.create_subprocess_exec (line 57) with await proc.wait() and no timeout — a hung Claude process will block that task forever.

Fix: Add timeout=600 (or configurable) to all subprocess.run calls in agent.py. For the async subprocess in worker.py, use asyncio.wait_for(proc.wait(), timeout=...) and kill the process on timeout. Also consider running the synchronous subprocess.run calls in agent.py via asyncio.to_thread() to avoid blocking the event loop.


Identified by minbot code review

Metadata

Metadata

Assignees

No one assigned

    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