-
Notifications
You must be signed in to change notification settings - Fork 998
Open
Description
Problem
When the Copilot CLI introduces new session event types before the SDK is updated, SessionEvent.FromJson() throws a JsonException because the generated SessionEvents.cs uses JsonUnknownDerivedTypeHandling.FailSerialization.
This breaks two call-sites:
GetMessagesAsync— the entire conversation history fails to load because
.Select(e => SessionEvent.FromJson(...))throws on the first unrecognized event.OnSessionEvent(real-time events) — the RPC handler crashes with no try-catch,
propagating the exception into theStreamJsonRpclayer.
Expected behavior
Unknown event types should be handled gracefully. The Python SDK already does this via a SessionEventType.UNKNOWN enum value with a _missing_() fallback — no events are lost and no exceptions are thrown.
Proposed solution
- Add an
UnknownSessionEventconcrete type that preserves the raw JSON and type discriminator for events the SDK can't deserialize. - Add a
SessionEvent.TryFromJsonmethod (via partial class, no generated code changes) that returnsUnknownSessionEventinstead of throwing. - Update
GetMessagesAsyncandOnSessionEventto useTryFromJson. - Log a warning when an unknown event is encountered.
Reproduction
Occurs whenever the CLI version is ahead of the SDK version and emits a new event type. Can be reproduced by manually injecting a JSON event with an unregistered "type"
value and calling GetMessagesAsync.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Give feedbackNo fields configured for issues without a type.