rosemarYuan commented on code in PR #869:
URL: https://github.com/apache/flink-agents/pull/869#discussion_r3523511913
##########
runtime/src/test/java/org/apache/flink/agents/runtime/actionstate/ActionStateSerdeTest.java:
##########
@@ -333,4 +344,63 @@ public void testKafkaSederDelegatesToActionStateSerde()
throws Exception {
assertNull(kafkaSeder.serialize("test-topic", null));
assertNull(kafkaSeder.deserialize("test-topic", null));
}
+
+ @Test
+ public void
testBuiltinChatToolAndContextEventsRoundTripThroughOutputEvents() throws
Exception {
+ ChatMessage msg = new ChatMessage(MessageRole.USER, "hello");
+ UUID requestId = UUID.randomUUID();
+ Document doc = new Document("doc content", Map.of("source",
"unit-test"), "doc-1");
+
+ // Built-in events are persisted both as the triggering taskEvent and
as
+ // outputEvents; cover both paths.
+ ActionState originalState = new ActionState(new
ChatRequestEvent("myModel", List.of(msg)));
+ originalState.addEvent(new ChatRequestEvent("myModel", List.of(msg)));
+ originalState.addEvent(new ChatResponseEvent(requestId, msg));
+ originalState.addEvent(new ToolRequestEvent("myModel",
List.of(Map.of("name", "myTool"))));
+ originalState.addEvent(
+ new ToolResponseEvent(
+ requestId,
+ Map.of("call-1", ToolResponse.success("result")),
+ Map.of("call-1", true),
+ Map.of()));
+ originalState.addEvent(new ContextRetrievalRequestEvent("query text",
"myVectorStore", 5));
+ originalState.addEvent(
+ new ContextRetrievalResponseEvent(requestId, "query text",
List.of(doc)));
+
+ byte[] serialized = ActionStateSerde.serialize(originalState);
Review Comment:
Thanks for you suggestion. Updated the PR based on your comments:
simplified the test name, kept only the base `Event` mixin in
`ActionStateSerde`, and added documentation for custom Java `Event` subclasses
to explain the required Jackson creator annotations during durable recovery.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]