From 5c6001d90fe6e1d15a2db6b30ecf9e7b6c26eee4 Mon Sep 17 00:00:00 2001 From: Yongsul Kim Date: Mon, 2 Jun 2025 09:18:39 -0700 Subject: [PATCH] fix(sample): Correct text artifact saving in artifact_save_text sample Copybara import of the project: -- 95292471f6dba29b55a17239670cdc6cc14619b5 by Yongsul Kim : COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/936 from ystory:fix/artifact-sample-save 7b0babc53266afadb8421ccafa0f3de092eeeae5 PiperOrigin-RevId: 766220649 --- contributing/samples/artifact_save_text/agent.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/contributing/samples/artifact_save_text/agent.py b/contributing/samples/artifact_save_text/agent.py index 1f62dcc..e8f05ff 100755 --- a/contributing/samples/artifact_save_text/agent.py +++ b/contributing/samples/artifact_save_text/agent.py @@ -19,8 +19,15 @@ from google.genai import types async def log_query(tool_context: ToolContext, query: str): - """Roll a die with the specified number of sides.""" - await tool_context.save_artifact('query', types.Part(text=query)) + """Saves the provided query string as a 'text/plain' artifact named 'query'.""" + query_bytes = query.encode('utf-8') + artifact_part = types.Part( + inline_data=types.Blob( + mime_type='text/plain', + data=query_bytes + ) + ) + await tool_context.save_artifact('query', artifact_part) root_agent = Agent(