[api][runtime][test] Add @JsonCreator to built-in event subclasses for ActionStateSerde durable recovery#869
Open
rosemarYuan wants to merge 1 commit into
Conversation
…r ActionStateSerde durable recovery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked issue: #868
Purpose of change
ActionStateSerdeuses Jackson polymorphic deserialization (@JsonTypeInfo(Id.CLASS)) to restore the concreteEventsubclasses persisted inActionState(taskEvent/outputEvents) for durable execution recovery. Jackson requires each concrete subclass to declare its own creator — the@JsonCreatoron the baseEventconstructor is not inherited.Only
InputEvent/OutputEventannotate their(UUID, Map<String, Object>)constructors with@JsonCreator/@JsonProperty. The six built-in event subclasses underorg.apache.flink.agents.api.event.*(ChatRequestEvent,ChatResponseEvent,ToolRequestEvent,ToolResponseEvent,ContextRetrievalRequestEvent,ContextRetrievalResponseEvent) have the same constructors but lack the annotations, so deserializing any of them from a persistedActionStatefails with:This PR annotates the
(UUID, Map<String, Object>)constructor of all six classes, consistent withInputEvent/OutputEvent.Tests
Added
ActionStateSerdeTest#testBuiltinChatToolAndContextEventsRoundTripThroughOutputEvents, which:ActionStateSerdeboth astaskEventand insideoutputEvents, asserting the concrete class is restored (fails with the exception above without the fix);fromEvent()consumption path used by the built-in actions (ChatMessage,ToolResponse,Document, andUUIDrequest ids), not raw maps.Verified with
mvn -pl runtime test -Dtest=ActionStateSerdeTest(11/11 pass) and the fullapimodule test suite.API
No signature changes. Adds Jackson annotations to existing public constructors of the six built-in event classes; serialized JSON format is unchanged.
Documentation
doc-neededdoc-not-neededdoc-included