Skip to content

Auto Compact on first Query causes async message iterator to hang #288

Description

@jdmurray21

await claude_client.query(prompt=my_prompt)

async for message in client.receive_response():
....

One the first query (which does require a lot of thinking), the iterator will hang when claude code has to compact context.
Strangely enough, I do see claude continue on fine in the claude logs though after the context compaction.

Activity

  1. qing-ant commented on Mar 24, 2026

    @qing-ant
    Contributor

    Closing as stale. This was filed against an early SDK version (October 2025, CLI v2.0.26 era). The SDK is now at v0.1.50 / CLI 2.1.83, and the compaction system has been substantially reworked since then, including fixes for async iterator behavior (e.g., PR #648 for stream event parsing, PR #615 for encoding, PR #617 for signal handling).

    If you're still experiencing this issue on the current SDK version, please reopen with updated reproduction steps and version information.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions