Skip to content

Python SDK: Event union missing thinking event types #752

@jens-gilion

Description

@jens-gilion

Bug Description

The Event union type in the Python SDK is missing the following event types that are defined as BaseEvent subclasses in the same module:

  • ThinkingStartEvent
  • ThinkingEndEvent
  • ThinkingTextMessageStartEvent
  • ThinkingTextMessageContentEvent
  • ThinkingTextMessageEndEvent

Steps to Reproduce

from pydantic import TypeAdapter
from ag_ui.core import Event

event_adapter = TypeAdapter(Event)
event_adapter.validate_python({'type': 'THINKING_START'})

This raises a validation error:

Input tag 'THINKING_START' found using 'type' does not match any of the expected tags...

Expected Behavior

The Event union should include all BaseEvent subclasses so that thinking events can be properly deserialized.

Impact

This prevents using TypeAdapter[Event] when working with models that emit thinking events (e.g., Claude with extended thinking), as used by pydantic-ai's AGUIEventStream.

Proposed Fix

Add the missing thinking event types to the Event union in sdks/python/ag_ui/core/events.py.

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