@@ -381,7 +381,7 @@ public Flowable<Event> runAsync(
381381 new IllegalArgumentException (
382382 String .format ("Session not found: %s for user %s" , sessionId , userId )));
383383 }))
384- .flatMapPublisher (session -> this .runAsync (session , newMessage , runConfig , stateDelta ));
384+ .flatMapPublisher (session -> this .runAsyncImpl (session , newMessage , runConfig , stateDelta ));
385385 }
386386
387387 /** See {@link #runAsync(String, String, Content, RunConfig, Map)}. */
@@ -415,6 +415,23 @@ public Flowable<Event> runAsync(
415415 Content newMessage ,
416416 RunConfig runConfig ,
417417 @ Nullable Map <String , Object > stateDelta ) {
418+ return runAsyncImpl (session , newMessage , runConfig , stateDelta );
419+ }
420+
421+ /**
422+ * Runs the agent asynchronously using a provided Session object.
423+ *
424+ * @param session The session to run the agent in.
425+ * @param newMessage The new message from the user to process.
426+ * @param runConfig Configuration for the agent run.
427+ * @param stateDelta Optional map of state updates to merge into the session for this run.
428+ * @return A Flowable stream of {@link Event} objects generated by the agent during execution.
429+ */
430+ protected Flowable <Event > runAsyncImpl (
431+ Session session ,
432+ Content newMessage ,
433+ RunConfig runConfig ,
434+ @ Nullable Map <String , Object > stateDelta ) {
418435 Span span =
419436 Tracing .getTracer ().spanBuilder ("invocation" ).setParent (Context .current ()).startSpan ();
420437 Context spanContext = Context .current ().with (span );
@@ -688,6 +705,7 @@ public Flowable<Event> runLive(
688705 *
689706 * @return stream of generated events.
690707 */
708+ @ Deprecated (since = "0.5.0" , forRemoval = true )
691709 public Flowable <Event > runWithSessionId (
692710 String sessionId , Content newMessage , RunConfig runConfig ) {
693711 // TODO(b/410859954): Add user_id to getter or method signature. Assuming "tmp-user" for now.
0 commit comments