Commit a09f070
fix(genai): extract and include metadata (#941)
### **PR Description**
This pull request fixes an issue where grounding metadata from the
Google search tool responses was not preserved. It ensures that fields
such as `grounding_supports`, `grounding_chunks`, and
`web_search_queries` are extracted and included in `response_metadata`,
enabling citation tracking and improved traceability in search-augmented
responses.
---
### **Relevant issues**
Fixes #907
---
### **Type**
🐛 Bug Fix
---
### **Changes (optional)**
* Added `_extract_grounding_metadata()` helper function to safely
extract grounding data.
* Updated `_response_to_result()` to include `grounding_supports`,
`grounding_chunks`, and `web_search_queries` in `response_metadata`.
* Preserves backward compatibility with the existing response structure.
---
### **Testing (optional)**
* Manually verified that metadata is preserved across multiple Google
search tool responses.
* Confirmed presence of citation information in augmented responses.
---
### **Note (optional)**
This fix improves the reliability of citations and source tracking in
responses using Google search, supporting downstream systems relying on
structured grounding metadata.
---------
Co-authored-by: Mason Daugherty <[email protected]>
Co-authored-by: Mason Daugherty <[email protected]>1 parent c7cec1c commit a09f070
1 file changed
+67
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
738 | 738 | | |
739 | 739 | | |
740 | 740 | | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
741 | 801 | | |
742 | 802 | | |
743 | 803 | | |
| |||
800 | 860 | | |
801 | 861 | | |
802 | 862 | | |
803 | | - | |
804 | | - | |
805 | | - | |
806 | | - | |
807 | | - | |
808 | | - | |
809 | | - | |
| 863 | + | |
| 864 | + | |
810 | 865 | | |
811 | 866 | | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
812 | 872 | | |
813 | 873 | | |
814 | 874 | | |
| |||
0 commit comments