Skip to content

Conversation

@jens-gilion
Copy link

Summary

Fixes #752

The Event union type was missing the following event types that are defined as BaseEvent subclasses:

  • ThinkingStartEvent
  • ThinkingEndEvent
  • ThinkingTextMessageStartEvent
  • ThinkingTextMessageContentEvent
  • ThinkingTextMessageEndEvent

This caused validation errors when using TypeAdapter[Event] to parse events from models that emit thinking events (e.g., Claude with extended thinking via pydantic-ai's AGUIEventStream).

Changes

  1. Added the 5 missing thinking event types to the Event union in events.py
  2. Added a test to ensure all BaseEvent subclasses are included in the Event union, preventing similar issues in the future

Test Plan

  • Ran python -m unittest tests.test_events.TestEvents.test_all_event_subclasses_in_event_union - passes
  • Verified thinking events can now be validated via TypeAdapter[Event]

The Event union type was missing the following event types that are
defined as BaseEvent subclasses:
- ThinkingStartEvent
- ThinkingEndEvent
- ThinkingTextMessageStartEvent
- ThinkingTextMessageContentEvent
- ThinkingTextMessageEndEvent

This caused validation errors when using TypeAdapter[Event] to parse
events from models that emit thinking events (e.g., Claude with
extended thinking).

Also adds a test to ensure all BaseEvent subclasses are included in
the Event union, preventing similar issues in the future.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python SDK: Event union missing thinking event types

2 participants