avichaym opened a new issue, #673:
URL: https://github.com/apache/flink-agents/issues/673

   ### Search before asking
   
   - [x] I searched in the 
[issues](https://github.com/apache/flink-agents/issues) and found nothing 
similar.
   
   ### Description
   
   ChatRequestEvent, ContextRetrievalResponseEvent, and ToolRequestEvent store 
their List<> constructor arguments by reference. When callers pass an immutable 
list (List.of(...), Arrays.asList(...), Collections.unmodifiableList(...)), 
Flink's Kryo serializer fails at runtime with an InaccessibleObjectException 
because JDK 17+ restricts reflective access to internal fields of 
java.util.Arrays$ArrayList and similar immutable list implementations.
   
   The failure is non-obvious: the event is constructed successfully, but the 
job crashes when the first record is serialized/cloned between operators.
   
   ### How to reproduce
   
   // In any agent action:
   ChatMessage msg = new ChatMessage(MessageRole.USER, "hello");
   ctx.sendEvent(new ChatRequestEvent("myModel", List.of(msg)));
   // ^^^ List.of() produces an immutable list
   
   Run the pipeline on JDK 17+ (the minimum for Flink 1.20). The job fails with:
   
   Caused by: java.lang.reflect.InaccessibleObjectException:
     Unable to make field private final java.lang.Object[]
     java.util.Arrays$ArrayList.a accessible: module java.base
     does not "opens java.util" to unnamed module @...
   
   **Expected Behaviour**
   
   Events should accept any valid List<T> regardless of mutability. The user 
should not need to know that Kryo requires mutable lists internally.
   Affected Classes
   
       org.apache.flink.agents.api.event.ChatRequestEvent
       org.apache.flink.agents.api.event.ContextRetrievalResponseEvent
       org.apache.flink.agents.api.event.ToolRequestEvent
   
   
   
   ### Version and environment
   
   Flink Agents: 0.3-SNAPSHOT (current main)
   Flink: 1.20.0
   Java: JDK 17+
   
   ### Are you willing to submit a PR?
   
   - [x] I'm willing to submit a PR!


-- 
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]

Reply via email to