-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Feature: Strongly type Python events #1016
Description
Hi,
I was trying to build against the SDK in Python, and I got confused about which events carried what payloads. The Data class is a union of all possible data fields:
| class Data: |
SessionEvent largely a pair of enum and Data with a long docstring:
| class SessionEvent: |
Other bindings in dotnet, for example, strongly type the events, so you know what events carry what payloads:
| public partial class SessionStartEvent : SessionEvent |
I think stronger type hinting on the Python side would help make the SDK easier to consume by catching classes of bugs at IDE/Pyright/agent coding time. It has precedent on the Claude Agent SDK, which does adopt this pattern for its message type:
It's a breaking change to people using type hints, but I suspect we could do it in such a way that the only breaks would be people genuinely looking in the wrong place for payloads (i.e. silent bugs).