Skip to content

Commit 8665637

Browse files
google-genai-botcopybara-github
authored andcommitted
Properly track state update in callbacks.
PiperOrigin-RevId: 772593312
1 parent dc02503 commit 8665637

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

core/src/main/java/com/google/adk/agents/BaseAgent.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,7 @@ private Single<Optional<Event>> callCallback(
266266
.switchIfEmpty(
267267
Single.defer(
268268
() -> {
269-
boolean hasStateDelta = !callbackContext.eventActions().stateDelta().isEmpty();
270-
271-
if (hasStateDelta) {
269+
if (callbackContext.state().hasDelta()) {
272270
Event.Builder eventBuilder =
273271
Event.builder()
274272
.id(Event.generateEventId())

core/src/main/java/com/google/adk/sessions/State.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,4 +154,8 @@ public int size() {
154154
public Collection<Object> values() {
155155
return state.values();
156156
}
157+
158+
public boolean hasDelta() {
159+
return !delta.isEmpty();
160+
}
157161
}

0 commit comments

Comments
 (0)