adk-python icon indicating copy to clipboard operation
adk-python copied to clipboard

Code execution agent tries to load a generated artifact using non-existent URL prefix "sandbox:"

Open mstyer-google opened this issue 1 year ago • 1 comments

** Please make sure you read the contribution guide and file the issues in the right place. ** Contribution guide.

Describe the bug In the data science agent in adk-samples, the analytics sub-agent uses the Vertex AI Code Execution extension to generate graphs for data analytics. When the code execution extension generates a graph, the graph is returned and stored as a .png file in the artifact service. This all functions correctly.

However, the response from the code execution agent frequently contains something that looks like a link to the generated graphics file. Here's an example:

Excellent. Here is the bar chart visualizing the average departure and arrival delays per month.

![Bar chart of average departure and arrival delays](sandbox:/code_execution_image_1.png)

The name of the artifact is correct (code_excution_image_1.png), but the sandbox: URL prefix is non-existent, as far as I'm aware.

To Reproduce Steps to reproduce the behavior:

  1. Run the data-science sample agent from adk-samples
  2. Ask it to generate some kind of graphical analysis
  3. If the agent provides a link to the graphic, the link is broken.

Expected behavior Ideally there would be a way to do what the agent is trying to do, i.e. create a link to an artifact so the artifact would be displayed inline for the user. I don't think there is any way to do this, though, at least not how the agent is trying to do it.

Given that, the expected behavior should be that the agent tells the user the output has been generated and stored as an artifact.

Screenshots see attached

Desktop (please complete the following information):

  • OS: Debian
  • Python version(python -V): 3.12.2
  • ADK version(pip show google-adk): 1.7.0

Model Information: gemini-2.5-pro

Image

mstyer-google avatar Sep 02 '25 14:09 mstyer-google

Thanks for reporting this issue! Since this is an issue on the model side (the model is hallucinating the sandbox:/ prefix), we aren't able to fix anything within the ADK code. To workaround, you can do prompt engineering and adjust the prompt, i.e. add instructions such as:

Do not create direct Markdown links for files generated by code execution. Instead, to inform the user that the image has been generated and can be found in the "Artifacts" section, mentioning the filename (e.g., "I have generated the bar chart and saved it as code_execution_image_1.png in the Artifacts tab.").

wukath avatar Nov 03 '25 23:11 wukath