@@ -56,6 +56,7 @@ public class InvocationContext {
5656 private final Map <String , Boolean > endOfAgents ;
5757 private final ResumabilityConfig resumabilityConfig ;
5858 @ Nullable private final EventsCompactionConfig eventsCompactionConfig ;
59+ @ Nullable private final ContextCacheConfig contextCacheConfig ;
5960 private final InvocationCostManager invocationCostManager ;
6061 private final Map <String , Object > callbackContextData ;
6162
@@ -81,6 +82,7 @@ protected InvocationContext(Builder builder) {
8182 this .endOfAgents = builder .endOfAgents ;
8283 this .resumabilityConfig = builder .resumabilityConfig ;
8384 this .eventsCompactionConfig = builder .eventsCompactionConfig ;
85+ this .contextCacheConfig = builder .contextCacheConfig ;
8486 this .invocationCostManager = builder .invocationCostManager ;
8587 this .callbackContextData = builder .callbackContextData ;
8688 }
@@ -400,6 +402,11 @@ public Optional<EventsCompactionConfig> eventsCompactionConfig() {
400402 return Optional .ofNullable (eventsCompactionConfig );
401403 }
402404
405+ /** Returns the context cache configuration for the current agent run. */
406+ public Optional <ContextCacheConfig > contextCacheConfig () {
407+ return Optional .ofNullable (contextCacheConfig );
408+ }
409+
403410 /** Returns whether to pause the invocation right after this [event]. */
404411 public boolean shouldPauseInvocation (Event event ) {
405412 if (!isResumable ()) {
@@ -472,6 +479,7 @@ private Builder(InvocationContext context) {
472479 this .endOfAgents = new ConcurrentHashMap <>(context .endOfAgents );
473480 this .resumabilityConfig = context .resumabilityConfig ;
474481 this .eventsCompactionConfig = context .eventsCompactionConfig ;
482+ this .contextCacheConfig = context .contextCacheConfig ;
475483 this .invocationCostManager = context .invocationCostManager ;
476484 this .callbackContextData = context .callbackContextData ;
477485 }
@@ -493,6 +501,7 @@ private Builder(InvocationContext context) {
493501 private Map <String , Boolean > endOfAgents = new ConcurrentHashMap <>();
494502 private ResumabilityConfig resumabilityConfig = new ResumabilityConfig ();
495503 @ Nullable private EventsCompactionConfig eventsCompactionConfig ;
504+ @ Nullable private ContextCacheConfig contextCacheConfig ;
496505 private InvocationCostManager invocationCostManager = new InvocationCostManager ();
497506 private Map <String , Object > callbackContextData = new ConcurrentHashMap <>();
498507
@@ -730,6 +739,18 @@ public Builder eventsCompactionConfig(@Nullable EventsCompactionConfig eventsCom
730739 return this ;
731740 }
732741
742+ /**
743+ * Sets the context cache configuration for the current agent run.
744+ *
745+ * @param contextCacheConfig the context cache configuration.
746+ * @return this builder instance for chaining.
747+ */
748+ @ CanIgnoreReturnValue
749+ public Builder contextCacheConfig (@ Nullable ContextCacheConfig contextCacheConfig ) {
750+ this .contextCacheConfig = contextCacheConfig ;
751+ return this ;
752+ }
753+
733754 /**
734755 * Sets the callback context data for the invocation.
735756 *
@@ -778,6 +799,7 @@ public boolean equals(Object o) {
778799 && Objects .equals (endOfAgents , that .endOfAgents )
779800 && Objects .equals (resumabilityConfig , that .resumabilityConfig )
780801 && Objects .equals (eventsCompactionConfig , that .eventsCompactionConfig )
802+ && Objects .equals (contextCacheConfig , that .contextCacheConfig )
781803 && Objects .equals (invocationCostManager , that .invocationCostManager )
782804 && Objects .equals (callbackContextData , that .callbackContextData );
783805 }
@@ -802,6 +824,7 @@ public int hashCode() {
802824 endOfAgents ,
803825 resumabilityConfig ,
804826 eventsCompactionConfig ,
827+ contextCacheConfig ,
805828 invocationCostManager ,
806829 callbackContextData );
807830 }
0 commit comments