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

Get sources from google_search tool use

Open Alexheqingli opened this issue 1 year ago • 5 comments

Is there any way to get source urls as part of the output from an agent using google_search tool? Have tried to use instruction prompt, but it did not work. Appreciate your help re whether this is something supported now and any suggestions re workaround. Thx!

Alexheqingli avatar Apr 16 '25 04:04 Alexheqingli

The event returned from the agent has a grounding_metadata field which I have seen populated when the search tool is used. That doesn't get it into the actual response but maybe it can help?

forrestrice avatar Apr 16 '25 05:04 forrestrice

Hi all, don't worry we got you! With the next release update, UI web will show the sources of google search, and you can also click each chip to go to the page if you want!

(And @forrestrice is right, the grounding_metadata has groundingChunks that has this information!)

wyf7107 avatar Apr 16 '25 06:04 wyf7107

Something like this:

Image

wyf7107 avatar Apr 16 '25 06:04 wyf7107

Awesome! Great if you could have these in the event.content, for ease of picking this up in log / for further post-processing for citation. Looking forward to the next update. and thanks, @forrestrice !

Alexheqingli avatar Apr 18 '25 19:04 Alexheqingli

My recommendation is to read directly from event.grounding_metadata. If you want to include it in event.content, you can use a callback to read from event.grounding_metadata and format it however you want then insert into event.content. Since everyone presents this different in event.content, we leave this to developers.

boyangsvl avatar Apr 19 '25 01:04 boyangsvl