Skip to content

v0.4.4 - Proper session lifecycle management

Choose a tag to compare

@yazelin yazelin released this 11 Feb 09:36
· 3 commits to main since this release

What's Changed

Fix: Unclosed client sessions

Added proper lifecycle management to ClaudeAcpAgent and ClaudeClient to prevent unclosed subprocess connections (and associated aiohttp session warnings).

New methods:

  • ClaudeAcpAgent.close() / close_session(session_id) — properly disconnects ClaudeSDKClient instances
  • ClaudeClient.close() — delegates to agent cleanup
  • Both now support async with context manager for automatic cleanup

Usage:

# Recommended: async context manager
async with ClaudeClient(cwd=".") as client:
    response = await client.query("Hello")

# Or manual cleanup
client = ClaudeClient(cwd=".")
try:
    response = await client.query("Hello")
finally:
    await client.close()

Also:

  • run() entry point now ensures agent.close() on shutdown via try/finally
  • Updated README examples to use async with pattern
  • Added unit tests for lifecycle methods