Skip to content

Commit 81b6887

Browse files
Merge branch 'main' into contrib/database-session-service
2 parents a631ff1 + b48b194 commit 81b6887

27 files changed

Lines changed: 1792 additions & 210 deletions

core/src/main/java/com/google/adk/events/EventActions.java

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public class EventActions {
4141
private ConcurrentMap<String, ToolConfirmation> requestedToolConfirmations =
4242
new ConcurrentHashMap<>();
4343
private Optional<Boolean> endInvocation = Optional.empty();
44+
private Optional<EventCompaction> compaction = Optional.empty();
4445

4546
/** Default constructor for Jackson. */
4647
public EventActions() {}
@@ -139,6 +140,15 @@ public void setEndInvocation(boolean endInvocation) {
139140
this.endInvocation = Optional.of(endInvocation);
140141
}
141142

143+
@JsonProperty("compaction")
144+
public Optional<EventCompaction> compaction() {
145+
return compaction;
146+
}
147+
148+
public void setCompaction(Optional<EventCompaction> compaction) {
149+
this.compaction = compaction;
150+
}
151+
142152
public static Builder builder() {
143153
return new Builder();
144154
}
@@ -162,7 +172,8 @@ public boolean equals(Object o) {
162172
&& Objects.equals(escalate, that.escalate)
163173
&& Objects.equals(requestedAuthConfigs, that.requestedAuthConfigs)
164174
&& Objects.equals(requestedToolConfirmations, that.requestedToolConfirmations)
165-
&& Objects.equals(endInvocation, that.endInvocation);
175+
&& Objects.equals(endInvocation, that.endInvocation)
176+
&& Objects.equals(compaction, that.compaction);
166177
}
167178

168179
@Override
@@ -175,7 +186,8 @@ public int hashCode() {
175186
escalate,
176187
requestedAuthConfigs,
177188
requestedToolConfirmations,
178-
endInvocation);
189+
endInvocation,
190+
compaction);
179191
}
180192

181193
/** Builder for {@link EventActions}. */
@@ -190,6 +202,7 @@ public static class Builder {
190202
private ConcurrentMap<String, ToolConfirmation> requestedToolConfirmations =
191203
new ConcurrentHashMap<>();
192204
private Optional<Boolean> endInvocation = Optional.empty();
205+
private Optional<EventCompaction> compaction = Optional.empty();
193206

194207
public Builder() {}
195208

@@ -203,6 +216,7 @@ private Builder(EventActions eventActions) {
203216
this.requestedToolConfirmations =
204217
new ConcurrentHashMap<>(eventActions.requestedToolConfirmations());
205218
this.endInvocation = eventActions.endInvocation();
219+
this.compaction = eventActions.compaction();
206220
}
207221

208222
@CanIgnoreReturnValue
@@ -262,6 +276,13 @@ public Builder endInvocation(boolean endInvocation) {
262276
return this;
263277
}
264278

279+
@CanIgnoreReturnValue
280+
@JsonProperty("compaction")
281+
public Builder compaction(EventCompaction value) {
282+
this.compaction = Optional.ofNullable(value);
283+
return this;
284+
}
285+
265286
@CanIgnoreReturnValue
266287
public Builder merge(EventActions other) {
267288
if (other.skipSummarization().isPresent()) {
@@ -288,6 +309,9 @@ public Builder merge(EventActions other) {
288309
if (other.endInvocation().isPresent()) {
289310
this.endInvocation = other.endInvocation();
290311
}
312+
if (other.compaction().isPresent()) {
313+
this.compaction = other.compaction();
314+
}
291315
return this;
292316
}
293317

@@ -301,6 +325,7 @@ public EventActions build() {
301325
eventActions.setRequestedAuthConfigs(this.requestedAuthConfigs);
302326
eventActions.setRequestedToolConfirmations(this.requestedToolConfirmations);
303327
eventActions.setEndInvocation(this.endInvocation);
328+
eventActions.setCompaction(this.compaction);
304329
return eventActions;
305330
}
306331
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package com.google.adk.events;
2+
3+
import com.fasterxml.jackson.annotation.JsonCreator;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
6+
import com.google.auto.value.AutoValue;
7+
import com.google.genai.types.Content;
8+
9+
/** The compaction of the events. */
10+
@AutoValue
11+
@JsonDeserialize(builder = EventCompaction.Builder.class)
12+
public abstract class EventCompaction {
13+
14+
@JsonProperty("startTimestamp")
15+
public abstract long startTimestamp();
16+
17+
@JsonProperty("endTimestamp")
18+
public abstract long endTimestamp();
19+
20+
@JsonProperty("compactedContent")
21+
public abstract Content compactedContent();
22+
23+
public static Builder builder() {
24+
return new AutoValue_EventCompaction.Builder();
25+
}
26+
27+
/** Builder for {@link EventCompaction}. */
28+
@AutoValue.Builder
29+
public abstract static class Builder {
30+
31+
@JsonCreator
32+
static Builder create() {
33+
return builder();
34+
}
35+
36+
@JsonProperty("startTimestamp")
37+
public abstract Builder startTimestamp(long startTimestamp);
38+
39+
@JsonProperty("endTimestamp")
40+
public abstract Builder endTimestamp(long endTimestamp);
41+
42+
@JsonProperty("compactedContent")
43+
public abstract Builder compactedContent(Content compactedContent);
44+
45+
public abstract EventCompaction build();
46+
}
47+
}

0 commit comments

Comments
 (0)