1414package io .quarkiverse .dapr .langchain4j .agent ;
1515
1616import java .lang .reflect .Method ;
17+ import java .util .Arrays ;
1718import java .util .Map ;
1819import java .util .concurrent .CompletableFuture ;
1920import java .util .concurrent .ConcurrentHashMap ;
@@ -32,11 +33,38 @@ public class AgentRunContext {
3233 * Holds all the information needed for {@code ToolCallActivity} to execute the tool
3334 * and unblock the waiting agent thread.
3435 */
36+ @ SuppressWarnings ("EI_EXPOSE_REP" )
3537 public record PendingCall (
3638 Object target ,
3739 Method method ,
3840 Object [] args ,
3941 CompletableFuture <Object > resultFuture ) {
42+
43+ /**
44+ * Creates a PendingCall with a defensive copy of args.
45+ *
46+ * @param target the object instance on which the method will be invoked
47+ * @param method the reflective method handle
48+ * @param args the arguments to pass to the method
49+ * @param resultFuture future to complete when the call finishes
50+ */
51+ public PendingCall (Object target , Method method , Object [] args ,
52+ CompletableFuture <Object > resultFuture ) {
53+ this .target = target ;
54+ this .method = method ;
55+ this .args = args == null ? null : Arrays .copyOf (args , args .length );
56+ this .resultFuture = resultFuture ;
57+ }
58+
59+ /**
60+ * Returns a defensive copy of args.
61+ *
62+ * @return copy of args array
63+ */
64+ @ Override
65+ public Object [] args () {
66+ return args == null ? null : Arrays .copyOf (args , args .length );
67+ }
4068 }
4169
4270 private final String agentRunId ;
0 commit comments