|
39 | 39 | import java.util.Optional; |
40 | 40 | import java.util.Set; |
41 | 41 | import java.util.UUID; |
42 | | -import javax.annotation.Nullable; |
| 42 | +import org.jspecify.annotations.Nullable; |
43 | 43 |
|
44 | 44 | // TODO - b/413761119 update Agent.java when resolved. |
45 | 45 | /** Represents an event in a session. */ |
@@ -344,11 +344,14 @@ public final String stringifyContent() { |
344 | 344 | /** Builder for {@link Event}. */ |
345 | 345 | public static class Builder { |
346 | 346 |
|
347 | | - private String id; |
348 | | - private String invocationId; |
349 | | - private String author; |
| 347 | + private static final String MISSING_INVOCATION_ID = "__adk__invocation__id__missing"; |
| 348 | + private static final String MISSING_AUTHOR = "__adk__author__unknown"; |
| 349 | + |
| 350 | + private @Nullable String id; |
| 351 | + private @Nullable String invocationId; |
| 352 | + private @Nullable String author; |
350 | 353 | private @Nullable Content content; |
351 | | - private EventActions actions; |
| 354 | + private @Nullable EventActions actions; |
352 | 355 | private @Nullable Set<String> longRunningToolIds; |
353 | 356 | private @Nullable Boolean partial; |
354 | 357 | private @Nullable Boolean turnComplete; |
@@ -522,9 +525,9 @@ public Builder modelVersion(@Nullable String value) { |
522 | 525 |
|
523 | 526 | public Event build() { |
524 | 527 | Event event = new Event(); |
525 | | - event.setId(id); |
526 | | - event.setInvocationId(invocationId); |
527 | | - event.setAuthor(author); |
| 528 | + event.setId(Optional.ofNullable(id).orElse(UUID.randomUUID().toString())); |
| 529 | + event.setInvocationId(Optional.ofNullable(invocationId).orElse(MISSING_INVOCATION_ID)); |
| 530 | + event.setAuthor(Optional.ofNullable(author).orElse(MISSING_AUTHOR)); |
528 | 531 | event.setContent(content); |
529 | 532 | event.setLongRunningToolIds(longRunningToolIds); |
530 | 533 | event.setPartial(partial); |
|
0 commit comments