Skip to content

Commit b857f01

Browse files
google-genai-botcopybara-github
authored andcommitted
fix: Removing deprecated methods in Runner
PiperOrigin-RevId: 881608694
1 parent 444e0f0 commit b857f01

4 files changed

Lines changed: 26 additions & 56 deletions

File tree

contrib/langchain4j/src/test/java/com/google/adk/models/langchain4j/RunLoop.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ public static List<Event> runLoop(BaseAgent agent, boolean streaming, Object...
5353
allEvents.addAll(
5454
runner
5555
.runAsync(
56-
session,
56+
session.userId(),
57+
session.id(),
5758
messageContent,
5859
RunConfig.builder()
5960
.setStreamingMode(

contrib/spring-ai/src/test/java/com/google/adk/models/springai/SpringAIIntegrationTest.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import static org.junit.jupiter.api.Assertions.*;
1919

2020
import com.google.adk.agents.LlmAgent;
21+
import com.google.adk.agents.RunConfig;
2122
import com.google.adk.events.Event;
2223
import com.google.adk.models.springai.integrations.tools.WeatherTool;
2324
import com.google.adk.runner.InMemoryRunner;
@@ -73,14 +74,15 @@ public ChatResponse call(Prompt prompt) {
7374

7475
// when
7576
Runner runner = new InMemoryRunner(agent);
76-
Session session = runner.sessionService().createSession("test-app", "test-user").blockingGet();
77+
Session session =
78+
runner.sessionService().createSession(agent.name(), "test-user").blockingGet();
7779

7880
Content userMessage =
7981
Content.builder().role("user").parts(List.of(Part.fromText("What is a qubit?"))).build();
8082

8183
List<Event> events =
8284
runner
83-
.runAsync(session, userMessage, com.google.adk.agents.RunConfig.builder().build())
85+
.runAsync(session.userId(), session.id(), userMessage, RunConfig.builder().build())
8486
.toList()
8587
.blockingGet();
8688

@@ -149,7 +151,8 @@ public ChatResponse call(Prompt prompt) {
149151

150152
// when
151153
Runner runner = new InMemoryRunner(agent);
152-
Session session = runner.sessionService().createSession("test-app", "test-user").blockingGet();
154+
Session session =
155+
runner.sessionService().createSession(agent.name(), "test-user").blockingGet();
153156

154157
Content userMessage =
155158
Content.builder()
@@ -159,7 +162,7 @@ public ChatResponse call(Prompt prompt) {
159162

160163
List<Event> events =
161164
runner
162-
.runAsync(session, userMessage, com.google.adk.agents.RunConfig.builder().build())
165+
.runAsync(session.userId(), session.id(), userMessage, RunConfig.builder().build())
163166
.toList()
164167
.blockingGet();
165168

@@ -217,7 +220,8 @@ public Flux<ChatResponse> stream(Prompt prompt) {
217220

218221
// when
219222
Runner runner = new InMemoryRunner(agent);
220-
Session session = runner.sessionService().createSession("test-app", "test-user").blockingGet();
223+
Session session =
224+
runner.sessionService().createSession(agent.name(), "test-user").blockingGet();
221225

222226
Content userMessage =
223227
Content.builder()
@@ -228,11 +232,10 @@ public Flux<ChatResponse> stream(Prompt prompt) {
228232
List<Event> events =
229233
runner
230234
.runAsync(
231-
session,
235+
session.userId(),
236+
session.id(),
232237
userMessage,
233-
com.google.adk.agents.RunConfig.builder()
234-
.setStreamingMode(com.google.adk.agents.RunConfig.StreamingMode.SSE)
235-
.build())
238+
RunConfig.builder().setStreamingMode(RunConfig.StreamingMode.SSE).build())
236239
.toList()
237240
.blockingGet();
238241

contrib/spring-ai/src/test/java/com/google/adk/models/springai/TestUtils.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ public static List<Event> askAgent(BaseAgent agent, boolean streaming, Object...
4646
allEvents.addAll(
4747
runner
4848
.runAsync(
49-
session,
49+
session.userId(),
50+
session.id(),
5051
messageContent,
5152
RunConfig.builder()
5253
.setStreamingMode(
@@ -67,13 +68,17 @@ public static List<Event> askBlockingAgent(BaseAgent agent, Object... messages)
6768
}
6869

6970
Runner runner = new InMemoryRunner(agent);
70-
Session session = runner.sessionService().createSession("test-app", "test-user").blockingGet();
71+
Session session =
72+
runner.sessionService().createSession(agent.name(), "test-user").blockingGet();
7173

7274
List<Event> events = new ArrayList<>();
7375

7476
for (Content content : contents) {
7577
List<Event> batchEvents =
76-
runner.runAsync(session, content, RunConfig.builder().build()).toList().blockingGet();
78+
runner
79+
.runAsync(session.userId(), session.id(), content, RunConfig.builder().build())
80+
.toList()
81+
.blockingGet();
7782
events.addAll(batchEvents);
7883
}
7984

@@ -88,15 +93,17 @@ public static List<Event> askAgentStreaming(BaseAgent agent, Object... messages)
8893
}
8994

9095
Runner runner = new InMemoryRunner(agent);
91-
Session session = runner.sessionService().createSession("test-app", "test-user").blockingGet();
96+
Session session =
97+
runner.sessionService().createSession(agent.name(), "test-user").blockingGet();
9298

9399
List<Event> events = new ArrayList<>();
94100

95101
for (Content content : contents) {
96102
List<Event> batchEvents =
97103
runner
98104
.runAsync(
99-
session,
105+
session.userId(),
106+
session.id(),
100107
content,
101108
RunConfig.builder().setStreamingMode(RunConfig.StreamingMode.SSE).build())
102109
.toList()

core/src/main/java/com/google/adk/runner/Runner.java

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -415,35 +415,6 @@ public Flowable<Event> runAsync(String userId, String sessionId, Content newMess
415415
return runAsync(userId, sessionId, newMessage, RunConfig.builder().build());
416416
}
417417

418-
/**
419-
* See {@link #runAsync(Session, Content, RunConfig, Map)}.
420-
*
421-
* @deprecated Use runAsync with sessionId.
422-
*/
423-
@Deprecated(since = "0.4.0", forRemoval = true)
424-
public Flowable<Event> runAsync(Session session, Content newMessage, RunConfig runConfig) {
425-
return runAsync(session, newMessage, runConfig, /* stateDelta= */ null);
426-
}
427-
428-
/**
429-
* Runs the agent asynchronously using a provided Session object.
430-
*
431-
* @param session The session to run the agent in.
432-
* @param newMessage The new message from the user to process.
433-
* @param runConfig Configuration for the agent run.
434-
* @param stateDelta Optional map of state updates to merge into the session for this run.
435-
* @return A Flowable stream of {@link Event} objects generated by the agent during execution.
436-
* @deprecated Use runAsync with sessionId.
437-
*/
438-
@Deprecated(since = "0.4.0", forRemoval = true)
439-
public Flowable<Event> runAsync(
440-
Session session,
441-
Content newMessage,
442-
RunConfig runConfig,
443-
@Nullable Map<String, Object> stateDelta) {
444-
return runAsyncImpl(session, newMessage, runConfig, stateDelta);
445-
}
446-
447418
/**
448419
* Runs the agent asynchronously using a provided Session object.
449420
*
@@ -710,18 +681,6 @@ public Flowable<Event> runLive(
710681
return runLive(sessionKey.userId(), sessionKey.id(), liveRequestQueue, runConfig);
711682
}
712683

713-
/**
714-
* Runs the agent asynchronously with a default user ID.
715-
*
716-
* @return stream of generated events.
717-
*/
718-
@Deprecated(since = "0.5.0", forRemoval = true)
719-
public Flowable<Event> runWithSessionId(
720-
String sessionId, Content newMessage, RunConfig runConfig) {
721-
// TODO(b/410859954): Add user_id to getter or method signature. Assuming "tmp-user" for now.
722-
return this.runAsync("tmp-user", sessionId, newMessage, runConfig);
723-
}
724-
725684
/**
726685
* Checks if the agent and its parent chain allow transfer up the tree.
727686
*

0 commit comments

Comments
 (0)