File tree Expand file tree Collapse file tree
core/src/main/java/com/google/adk/sessions Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ public static Content encodeContent(Content content) {
5252 encodedParts .add (part );
5353 }
5454 }
55- return Content . builder (). parts ( encodedParts ). build ( );
55+ return toContent ( encodedParts , content . role () );
5656 }
5757
5858 public static Content decodeContent (Content content ) {
@@ -77,6 +77,12 @@ public static Content decodeContent(Content content) {
7777 decodedParts .add (part );
7878 }
7979 }
80- return Content .builder ().parts (decodedParts ).build ();
80+ return toContent (decodedParts , content .role ());
81+ }
82+
83+ private static Content toContent (List <Part > parts , Optional <String > role ) {
84+ Content .Builder contentBuilder = Content .builder ().parts (parts );
85+ role .ifPresent (contentBuilder ::role );
86+ return contentBuilder .build ();
8187 }
8288}
You can’t perform that action at this time.
0 commit comments