Add pending message buffer to accumulate agent messages before classification. Improve event handling with better logging and support for additional event types. Add helper functions for text extraction and tool input processing. Handle turn failures and flush messages appropriately for thinking/text events. generated by llmgit Co-Authored-By: Claude <noreply@anthropic.com>