@@ -928,25 +928,41 @@ func isResponsesWebSearchToolCall(toolCallPart fantasy.ToolCallPart) bool {
928928// metadata, which unlike the call input keeps the status and the
929929// deprecated single query. The item has no id: history from a stored turn
930930// or another credential carries real ids, and the API replaces the sent
931- // action with the stored item of that id. Sources are left out because
932- // the API ignores them on input.
931+ // action with the stored item of that id.
933932func unstoredWebSearchCallItem (meta * WebSearchCallMetadata ) (responses.ResponseInputItemUnionParam , error ) {
934933 if meta .Action == nil {
935- return responses.ResponseInputItemUnionParam {}, errors .New ("it has no action" )
934+ return responses.ResponseInputItemUnionParam {}, errors .New ("metadata has no action" )
936935 }
937936 // The API rejects the whole request for any other action type.
938937 switch meta .Action .Type {
939938 case "search" , "open_page" , "find_in_page" :
940939 default :
941940 return responses.ResponseInputItemUnionParam {}, fmt .Errorf ("action type %q cannot be replayed" , meta .Action .Type )
942941 }
943- action := * meta .Action
944- action .Sources = nil
942+ // Only fields the API takes are sent, so a field added to the stored
943+ // metadata cannot break replay.
944+ type action struct {
945+ Type string `json:"type"`
946+ Queries []string `json:"queries,omitempty"`
947+ Query string `json:"query,omitempty"`
948+ URL string `json:"url,omitempty"`
949+ Pattern string `json:"pattern,omitempty"`
950+ }
945951 item := param.Override [responses.ResponseFunctionWebSearchParam ](struct {
946- Type string `json:"type"`
947- Status string `json:"status,omitempty"`
948- Action * WebSearchAction `json:"action"`
949- }{Type : "web_search_call" , Status : meta .Status , Action : & action })
952+ Type string `json:"type"`
953+ Status string `json:"status,omitempty"`
954+ Action action `json:"action"`
955+ }{
956+ Type : "web_search_call" ,
957+ Status : meta .Status ,
958+ Action : action {
959+ Type : meta .Action .Type ,
960+ Queries : meta .Action .Queries ,
961+ Query : meta .Action .Query ,
962+ URL : meta .Action .URL ,
963+ Pattern : meta .Action .Pattern ,
964+ },
965+ })
950966 return responses.ResponseInputItemUnionParam {OfWebSearchCall : & item }, nil
951967}
952968
0 commit comments